Class: Fastlane::Helper::PlistBuddy
- Inherits:
-
Object
- Object
- Fastlane::Helper::PlistBuddy
- Defined in:
- lib/fastlane/plugin/facelift/helper/plist_buddy.rb
Instance Method Summary collapse
- #exec(command) ⇒ Object
-
#initialize(plist_file) ⇒ PlistBuddy
constructor
A new instance of PlistBuddy.
- #parse_dict_keys(entry) ⇒ Object
- #parse_scalar_array(result) ⇒ Object
Constructor Details
#initialize(plist_file) ⇒ PlistBuddy
Returns a new instance of PlistBuddy.
4 5 6 |
# File 'lib/fastlane/plugin/facelift/helper/plist_buddy.rb', line 4 def initialize(plist_file) @plist_file = plist_file end |
Instance Method Details
#exec(command) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fastlane/plugin/facelift/helper/plist_buddy.rb', line 8 def exec(command) UI.verbose("/usr/libexec/PlistBuddy -c \"#{command}\" \"#{@plist_file}\"") result = `/usr/libexec/PlistBuddy -c "#{command}" "#{@plist_file}"` if $?.exitstatus.nonzero? UI.important "PlistBuddy command failed: #{result}" raise "PlistBuddy command failed failed with exit code #{$?.exitstatus} - #{result}" end return result end |
#parse_dict_keys(entry) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fastlane/plugin/facelift/helper/plist_buddy.rb', line 34 def parse_dict_keys(entry) # This should probably use -x and parse the xml using Nokogiri result_lines = entry.lines.map(&:chop) raise "value is not an dict" unless result_lines.first == "Dict {" keys = result_lines .map { |l| l.match(/^\s{4}([^\s}]+)/) } .select { |l| l } .map { |l| l[1] } return keys end |
#parse_scalar_array(result) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fastlane/plugin/facelift/helper/plist_buddy.rb', line 20 def parse_scalar_array(result) # This should probably use -x and parse the xml using Nokogiri return [] unless result =~ /\S/ result_lines = result.lines.map(&:chop) raise "value is not an array" unless result_lines.first == "Array {" array_values = result_lines.drop(1).take(result_lines.size - 2) return array_values.map { |line| line[4..line.size] } end |