Class: MetaModel::Installer
- Inherits:
-
Object
- Object
- MetaModel::Installer
- Includes:
- Config::Mixin
- Defined in:
- lib/metamodel/installer.rb,
lib/metamodel/installer/renderer.rb
Defined Under Namespace
Classes: Renderer
Constant Summary collapse
- BUILD_PRODUCTS_FOLDER =
"./metamodel/Build/Products"
Instance Attribute Summary collapse
-
#associations ⇒ Object
Returns the value of attribute associations.
-
#current_model ⇒ Object
Returns the value of attribute current_model.
-
#metafile ⇒ Object
readonly
Returns the value of attribute metafile.
-
#models ⇒ Object
Returns the value of attribute models.
Instance Method Summary collapse
- #build_framework_on_iphoneos ⇒ Object
- #build_framework_on_iphonesimulator ⇒ Object
- #build_metamodel_framework ⇒ Object
- #copy_framework_swiftmodule_files ⇒ Object
-
#initialize(metafile) ⇒ Installer
constructor
A new instance of Installer.
- #install! ⇒ Object
- #lipo_frameworks_on_different_archs ⇒ Object
- #update_initialize_method ⇒ Object
- #update_packing_file ⇒ Object
Methods included from Config::Mixin
Constructor Details
#initialize(metafile) ⇒ Installer
Returns a new instance of Installer.
15 16 17 |
# File 'lib/metamodel/installer.rb', line 15 def initialize() @metafile = end |
Instance Attribute Details
#associations ⇒ Object
Returns the value of attribute associations.
11 12 13 |
# File 'lib/metamodel/installer.rb', line 11 def associations @associations end |
#current_model ⇒ Object
Returns the value of attribute current_model.
13 14 15 |
# File 'lib/metamodel/installer.rb', line 13 def current_model @current_model end |
#metafile ⇒ Object (readonly)
Returns the value of attribute metafile.
8 9 10 |
# File 'lib/metamodel/installer.rb', line 8 def @metafile end |
#models ⇒ Object
Returns the value of attribute models.
10 11 12 |
# File 'lib/metamodel/installer.rb', line 10 def models @models end |
Instance Method Details
#build_framework_on_iphoneos ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/metamodel/installer.rb', line 55 def build_framework_on_iphoneos build_iphoneos = "xcodebuild -scheme MetaModel \ -project MetaModel/MetaModel.xcodeproj \ -configuration Release -sdk iphoneos \ -derivedDataPath './metamodel' \ BITCODE_GENERATION_MODE=bitcode \ ONLY_ACTIVE_ARCH=NO \ CODE_SIGNING_REQUIRED=NO \ CODE_SIGN_IDENTITY= \ clean build" result = system "#{build_iphoneos} > /dev/null" raise Informative, 'Building framework on iphoneos failed.' unless result end |
#build_framework_on_iphonesimulator ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/metamodel/installer.rb', line 69 def build_framework_on_iphonesimulator build_iphonesimulator = "xcodebuild -scheme MetaModel \ -project MetaModel/MetaModel.xcodeproj \ -configuration Release -sdk iphonesimulator \ -derivedDataPath './metamodel' \ ONLY_ACTIVE_ARCH=NO \ CODE_SIGNING_REQUIRED=NO \ CODE_SIGN_IDENTITY= \ clean build" result = system "#{build_iphonesimulator} > /dev/null" raise Informative, 'Building framework on iphonesimulator failed.' unless result end |
#build_metamodel_framework ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/metamodel/installer.rb', line 45 def UI.section "Generating MetaModel.framework" do build_framework_on_iphoneos build_framework_on_iphonesimulator copy_framework_swiftmodule_files lipo_frameworks_on_different_archs end UI. "-> ".green + "MetaModel.framework located in current folder" end |
#copy_framework_swiftmodule_files ⇒ Object
84 85 86 87 88 89 |
# File 'lib/metamodel/installer.rb', line 84 def copy_framework_swiftmodule_files copy_command = "cp -rf #{BUILD_PRODUCTS_FOLDER}/Release-iphoneos/MetaModel.framework . && \ cp -rf #{BUILD_PRODUCTS_FOLDER}/Release-iphonesimulator/MetaModel.framework/Modules/MetaModel.swiftmodule/* \ MetaModel.framework/Modules/MetaModel.swiftmodule/" system copy_command end |
#install! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/metamodel/installer.rb', line 19 def install! @models = .models @associations = .associations Renderer.new(@models, @associations).tap do |renderer| renderer.render! end update_initialize_method update_packing_file unless config.skip_build? end |
#lipo_frameworks_on_different_archs ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/metamodel/installer.rb', line 91 def lipo_frameworks_on_different_archs lipo_command = "lipo -create -output MetaModel.framework/MetaModel \ #{BUILD_PRODUCTS_FOLDER}/Release-iphonesimulator/MetaModel.framework/MetaModel \ #{BUILD_PRODUCTS_FOLDER}/Release-iphoneos/MetaModel.framework/MetaModel" result = system "#{lipo_command}" raise Informative, 'Copy framework to current folder failed.' unless result end |
#update_initialize_method ⇒ Object
31 32 33 34 35 36 |
# File 'lib/metamodel/installer.rb', line 31 def update_initialize_method template = File.read File.(File.join(File.dirname(__FILE__), "./template/metamodel.swift")) result = ErbalTemplate::render_from_hash(template, { :models => @models, :associations => @associations }) model_path = Pathname.new("./metamodel/MetaModel/MetaModel.swift") File.write model_path, result end |
#update_packing_file ⇒ Object
38 39 40 41 42 43 |
# File 'lib/metamodel/installer.rb', line 38 def update_packing_file template = File.read File.(File.join(File.dirname(__FILE__), "./template/packing.swift")) result = ErbalTemplate::render_from_hash(template, { :models => @models, :associations => @associations }) model_path = Pathname.new("./metamodel/MetaModel/Packing.swift") File.write model_path, result end |