Class: Mxrb::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/mxrb/exporter.rb

Overview

Exports an MPR into an editable, layered Ruby source tree.

Constant Summary collapse

LAYERS =
%w[domain application presentation infrastructure].freeze
MODULE_PROGRESS_WEIGHT =
10
MARKETPLACE_PROVENANCE =
[
  ".mxrb/marketplace.lock.json",
  ".mxrb/marketplace",
  ".mxrb/marketplace-originals"
].freeze
EDITABLE_FLOW_OBJECT_TYPES =
%w[
  Microflows$StartEvent
  Microflows$EndEvent
  Microflows$ActionActivity
  Microflows$ExclusiveSplit
  Microflows$InheritanceSplit
  Microflows$ExclusiveMerge
  Microflows$LoopedActivity
  Microflows$ErrorEvent
  Microflows$ContinueEvent
  Microflows$Annotation
  Microflows$MicroflowParameter
].freeze
EDITABLE_ACTION_TYPES =
%w[
  Microflows$CreateObjectAction
  Microflows$CreateChangeAction
  Microflows$ChangeObjectAction
  Microflows$ChangeAction
  Microflows$RetrieveAction
  Microflows$CommitObjectsAction
  Microflows$CommitAction
  Microflows$DeleteAction
  Microflows$MicroflowCallAction
  Microflows$CreateVariableAction
  Microflows$ChangeVariableAction
  Microflows$ShowMessageAction
  Microflows$LogMessageAction
  Microflows$ShowFormAction
  Microflows$CloseFormAction
  Microflows$JavaActionCallAction
  Microflows$JavaScriptActionCallAction
  Microflows$NanoflowCallAction
  Microflows$AppServiceCallAction
  Microflows$AggregateAction
  Microflows$RollbackAction
  Microflows$CastAction
  Microflows$CreateListAction
  Microflows$ListOperationsAction
  Microflows$ChangeListAction
  Microflows$ValidationFeedbackAction
  Microflows$RestCallAction
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(mpr_path, output_dir) ⇒ Exporter

Returns a new instance of Exporter.



61
62
63
64
# File 'lib/mxrb/exporter.rb', line 61

def initialize(mpr_path, output_dir)
  @mpr_path = File.expand_path(mpr_path)
  @output_dir = File.expand_path(output_dir)
end

Instance Method Details

#export!(parallel: true) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/mxrb/exporter.rb', line 66

def export!(parallel: true)
  Progress.with("Exporting #{File.basename(@mpr_path)}") do |progress|
    FileUtils.mkdir_p(@output_dir)
    Mxrb.open(@mpr_path) do |project|
      @architecture = project.architecture_definition
      units = project.all_units
      modules = project.modules
      assets = project_asset_files
      progress.update(
        current: 0,
        total: 4 + assets.size + (units.size * 2) + (modules.size * MODULE_PROGRESS_WEIGHT),
        detail: "preparing Ruby project"
      )
      export_app_structure
      progress.advance(detail: "project structure")
      export_project_assets(assets, progress)
      export_native_units(project, units, progress)
      export_security(project)
      progress.advance(detail: "project security")
      export_architecture_contracts(project)
      progress.advance(detail: "navigation and design system")
      export_modules(modules, progress, parallel:)
      write_project(project)
      progress.advance(detail: "project.rb")
    end
  end
  @output_dir
end