Class: Mxrb::Writer
- Inherits:
-
Object
- Object
- Mxrb::Writer
- Defined in:
- lib/mxrb/writer.rb
Overview
Applies a DSL definition to a new or existing MPR. Names are used as the
stable key, making repeated mxrb generate runs idempotent.
Constant Summary collapse
- GLYPH_ICON_CODES =
{ 'home' => 57_377, 'pets' => 57_349, 'heart' => 57_349, 'calendar' => 57_609, 'calendar_today' => 57_609, 'user' => 57_352, 'search' => 57_347, 'settings' => 57_369, 'trash' => 57_376, 'file' => 57_378, 'time' => 57_379, 'shopping_cart' => 57_622 }.freeze
- LEGACY_NAVIGATION_PROFILES =
{ "Desktop" => "DesktopProfile", "Tablet" => "TabletProfile", "Phone" => "PhoneProfile", "OfflinePhone" => "OfflinePhoneProfile", "HybridPhone" => "HybridPhoneProfile6", "HybridTablet" => "HybridTabletProfile6" }.freeze
Instance Method Summary collapse
-
#initialize(path, definition) ⇒ Writer
constructor
A new instance of Writer.
- #write! ⇒ Object
Constructor Details
Instance Method Details
#write! ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/mxrb/writer.rb', line 37 def write! mpr = nil native_units = prepared_native_units asset_manifest = project_asset_manifest total = 4 + native_units.count { _1["containment"] != "Modules" } + @definition.fetch(:modules).size + Array(asset_manifest&.fetch("files", [])).size Progress.with("Generating #{File.basename(@path)}", total:) do |progress| @progress = progress create_project! unless File.exist?(@path) progress.advance(detail: "project container") mpr = IO::MprFile.open(@path) mpr.transaction do apply(mpr, native_units) mpr.write_architecture_definition(@definition) end progress.advance(detail: "model transaction") materialize_project_assets(asset_manifest) materialize_design_system progress.advance(detail: "design system") end self ensure @progress = Progress::NullTask.instance mpr&.close end |