Class: GoNative::Plugins::IOS::EmbedScripts
- Inherits:
-
Object
- Object
- GoNative::Plugins::IOS::EmbedScripts
- Extended by:
- DSL::Serviceable
- Defined in:
- lib/gonative/plugins/ios/embed_scripts.rb
Constant Summary collapse
- TARGET_SCRIPTS_FILE_NAME =
'target_scripts.yml'
Instance Attribute Summary collapse
-
#scripts ⇒ Object
readonly
Returns the value of attribute scripts.
Instance Method Summary collapse
Instance Attribute Details
#scripts ⇒ Object (readonly)
Returns the value of attribute scripts.
15 16 17 |
# File 'lib/gonative/plugins/ios/embed_scripts.rb', line 15 def scripts @scripts end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 |
# File 'lib/gonative/plugins/ios/embed_scripts.rb', line 17 def call prepare_scripts return unless scripts? end |
#embed_in_project ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gonative/plugins/ios/embed_scripts.rb', line 35 def proj = Xcodeproj::Project.open('MedianIOS.xcodeproj') app_target = proj.native_targets.first scripts.each do |script| app_target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase).tap do |phase| phase.name = script['name'] || 'New Run Script Phase' phase.input_paths = script['input_paths'] phase.output_paths = script['output_paths'] phase.shell_path = script['shell_path'] phase.shell_script = script['shell_script'] app_target.build_phases << phase end end proj.save end |
#prepare_scripts ⇒ Object
28 29 30 31 32 33 |
# File 'lib/gonative/plugins/ios/embed_scripts.rb', line 28 def prepare_scripts scripts_paths = `find ./Pods -name #{TARGET_SCRIPTS_FILE_NAME}`.split("\n") @scripts = scripts_paths .map { |path| YAML.load_file(path)['scripts'] } .flatten end |
#scripts? ⇒ Boolean
24 25 26 |
# File 'lib/gonative/plugins/ios/embed_scripts.rb', line 24 def scripts? !scripts.empty? end |