Class: MetaModel::Installer
- Inherits:
-
Object
- Object
- MetaModel::Installer
show all
- Includes:
- Config::Mixin
- Defined in:
- lib/metamodel/installer.rb,
lib/metamodel/installer/renderer.rb,
lib/metamodel/installer/validator.rb
Defined Under Namespace
Classes: Renderer, Validator
Constant Summary
collapse
- BUILD_PRODUCTS_FOLDER =
"./metamodel/Build/Products"
Instance Attribute Summary collapse
Instance Method Summary
collapse
#config
Constructor Details
#initialize(metafile) ⇒ Installer
Returns a new instance of Installer.
15
16
17
|
# File 'lib/metamodel/installer.rb', line 15
def initialize(metafile)
@metafile = 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
|
Returns the value of attribute metafile.
8
9
10
|
# File 'lib/metamodel/installer.rb', line 8
def metafile
@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
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/metamodel/installer.rb', line 47
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
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/metamodel/installer.rb', line 61
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
|
37
38
39
40
41
42
43
44
45
|
# File 'lib/metamodel/installer.rb', line 37
def build_metamodel_framework
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.message "-> ".green + "MetaModel.framework located in current folder"
end
|
#copy_framework_swiftmodule_files ⇒ Object
76
77
78
79
80
81
|
# File 'lib/metamodel/installer.rb', line 76
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
|
# File 'lib/metamodel/installer.rb', line 19
def install!
@models = metafile.models
@associations = metafile.associations
Renderer.new(@models, @associations).tap do |renderer|
renderer.render!
end
update_initialize_method
build_metamodel_framework unless config.skip_build?
end
|
#lipo_frameworks_on_different_archs ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/metamodel/installer.rb', line 83
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
30
31
32
33
34
35
|
# File 'lib/metamodel/installer.rb', line 30
def update_initialize_method
template = File.read File.expand_path(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
|