Class: XcodeArchiveCache::BuildSettings::Parser
- Inherits:
-
Object
- Object
- XcodeArchiveCache::BuildSettings::Parser
- Defined in:
- lib/build_settings/parser.rb
Instance Method Summary collapse
- #create_entry_regex(characters = SETTING_ALL_CHARACTERS) ⇒ Regexp
- #find_all_entries(string) ⇒ Array<String>
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse_name(string) ⇒ String
- #parse_value(string) ⇒ String
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
17 18 19 20 21 22 23 |
# File 'lib/build_settings/parser.rb', line 17 def initialize @setting_name_regex = Regexp.new("^(?<#{SETTING_NAME_GROUP}>#{SETTING_NAME_CHARACTERS})\s=") @setting_value_regex = Regexp.new("^#{SETTING_NAME_CHARACTERS}\s=\s(?<#{SETTING_VALUE_GROUP}>.+)$") @setting_entry_regex = create_entry_regex @setting_entry_part_regex = Regexp.new("#{SETTING_ENTRY_PART_CHARACTERS}") @setting_entry_name_regex = Regexp.new(SETTING_NAME_CHARACTERS) end |
Instance Method Details
#create_entry_regex(characters = SETTING_ALL_CHARACTERS) ⇒ Regexp
69 70 71 |
# File 'lib/build_settings/parser.rb', line 69 def create_entry_regex(characters = SETTING_ALL_CHARACTERS) Regexp.new("\\$[({]#{characters}[)}]") end |
#find_all_entries(string) ⇒ Array<String>
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/build_settings/parser.rb', line 29 def find_all_entries(string) return nil if string == nil string.scan(setting_entry_regex) .map {|entry| parts = entry.scan(setting_entry_part_regex) name = parts.first modifiers = parts.drop(1) name != nil ? SettingEntry.new(name, modifiers, entry) : nil } .compact end |
#parse_name(string) ⇒ String
47 48 49 50 51 52 |
# File 'lib/build_settings/parser.rb', line 47 def parse_name(string) match = setting_name_regex.match(string) return nil unless match match[SETTING_NAME_GROUP] end |
#parse_value(string) ⇒ String
58 59 60 61 62 63 |
# File 'lib/build_settings/parser.rb', line 58 def parse_value(string) match = setting_value_regex.match(string) return nil unless match match[SETTING_VALUE_GROUP] end |