Class: HMap::XcodeprojHelper
- Inherits:
-
Object
- Object
- HMap::XcodeprojHelper
- Defined in:
- lib/hmap/xc/target/xcconfig_helper.rb
Overview
A collection of xcodeproj Helper functions used throughout hmap.
Instance Attribute Summary collapse
-
#xcconfig_path ⇒ Object
readonly
Returns the value of attribute xcconfig_path.
Instance Method Summary collapse
- #add_build_setting(key, value, use_origin) ⇒ Object
- #add_build_settings(settings, use_origin) ⇒ Object
- #add_build_settings_and_save(settings, use_origin: true) ⇒ Object
-
#initialize(path) ⇒ XcodeprojHelper
constructor
A new instance of XcodeprojHelper.
- #remove_build_setting(setting) ⇒ Object
- #remove_build_settings(settings) ⇒ Object
- #remove_build_settings_and_save ⇒ Object
- #save_as(path = nil) ⇒ Object
- #save_build_setting(key) ⇒ Object
- #save_build_settings(settings) ⇒ Object
Constructor Details
#initialize(path) ⇒ XcodeprojHelper
Returns a new instance of XcodeprojHelper.
12 13 14 15 16 |
# File 'lib/hmap/xc/target/xcconfig_helper.rb', line 12 def initialize(path) xc = Pathname(path) @xcconfig_path = xc @xcconfig = Xcodeproj::Config.new(xc) end |
Instance Attribute Details
#xcconfig_path ⇒ Object (readonly)
Returns the value of attribute xcconfig_path.
10 11 12 |
# File 'lib/hmap/xc/target/xcconfig_helper.rb', line 10 def xcconfig_path @xcconfig_path end |
Instance Method Details
#add_build_setting(key, value, use_origin) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/hmap/xc/target/xcconfig_helper.rb', line 35 def add_build_setting(key, value, use_origin) return if value.nil? if key.start_with?(HMAP_XCKEY_START) @xcconfig.attributes[key] = value else save_origin = save_build_setting(key) e_value = value e_value = "#{e_value} ${#{save_xckey(key)}}" if use_origin && !save_origin.nil? @xcconfig.attributes[hmap_xckey(key)] = e_value @xcconfig.attributes[key] = "${#{hmap_xckey(key)}}" end end |
#add_build_settings(settings, use_origin) ⇒ Object
29 30 31 32 33 |
# File 'lib/hmap/xc/target/xcconfig_helper.rb', line 29 def add_build_settings(settings, use_origin) settings.each do |key, value| add_build_setting(key.to_s, value, use_origin) end end |
#add_build_settings_and_save(settings, use_origin: true) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/hmap/xc/target/xcconfig_helper.rb', line 18 def add_build_settings_and_save(settings, use_origin: true) add_build_settings(settings, use_origin) build_settings = [Constants::HEADER_SEARCH_PATHS, Constants::USER_HEADER_SEARCH_PATHS] if use_origin remove_build_settings(settings) else save_build_settings(settings) end save_as end |
#remove_build_setting(setting) ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/hmap/xc/target/xcconfig_helper.rb', line 78 def remove_build_setting(setting) save_origin = @xcconfig.attributes[save_xckey(setting)] origin = @xcconfig.attributes[setting] if save_origin.nil? && !origin.nil? && origin.include?(hmap_xckey(setting)) @xcconfig.attributes.delete(setting) end @xcconfig.attributes[setting] = save_origin unless save_origin.nil? @xcconfig.attributes.delete(hmap_xckey(setting)) @xcconfig.attributes.delete(save_xckey(setting)) end |
#remove_build_settings(settings) ⇒ Object
73 74 75 76 |
# File 'lib/hmap/xc/target/xcconfig_helper.rb', line 73 def remove_build_settings(settings) settings ||= [] settings.each { |setting| remove_build_setting(setting) } end |
#remove_build_settings_and_save ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/hmap/xc/target/xcconfig_helper.rb', line 63 def remove_build_settings_and_save hmap_ks = @xcconfig.attributes.keys.each_with_object([]) do |key, sum| sum << key[HMAP_XCKEY_START.length..-1] if key.start_with?(HMAP_XCKEY_START) sum << key[SAVE_XCKEY_START.length..-1] if key.start_with?(SAVE_XCKEY_START) end.compact remove_build_settings(hmap_ks) save_as end |
#save_as(path = nil) ⇒ Object
89 90 91 92 |
# File 'lib/hmap/xc/target/xcconfig_helper.rb', line 89 def save_as(path = nil) path = xcconfig_path if path.nil? @xcconfig.save_as(path) end |
#save_build_setting(key) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/hmap/xc/target/xcconfig_helper.rb', line 54 def save_build_setting(key) origin = @xcconfig.attributes[key] if origin.nil? || !origin.include?(hmap_xckey(key)) @xcconfig.attributes[save_xckey(key)] = origin unless origin.nil? @xcconfig.attributes.delete(key) end @xcconfig.attributes[save_xckey(key)] end |
#save_build_settings(settings) ⇒ Object
49 50 51 52 |
# File 'lib/hmap/xc/target/xcconfig_helper.rb', line 49 def save_build_settings(settings) settings ||= [] settings.each { |key| save_build_setting(key) } end |