Sha256: 21c1ab68f7d92f7b233f5a8ff6d1b48c7b94968ce3ec38499db5e7ddc67d0236

Contents?: true

Size: 502 Bytes

Versions: 4

Compression:

Stored size: 502 Bytes

Contents

module Ambient
  class PlistHelper
    attr_reader :path

    def initialize(path)
      @path = path
    end

    def add_entry(key, value)
      plist_as_dictionary[key] = value
      puts "applying to plist: #{path} #{key}"
      save
    end

    private

    def plist_as_dictionary
      @plist_as_dictionary ||= Plist::parse_xml(path)
    end

    def to_plist
      plist_as_dictionary.to_plist
    end

    def save
      File.open(path, 'w') { |file| file.write(to_plist) }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ambient-xcode-0.8.1 lib/ambient/plist_helper.rb
ambient-xcode-0.8.0 lib/ambient/plist_helper.rb
ambient-xcode-0.7.1 lib/ambient/plist_helper.rb
ambient-xcode-0.7.0 lib/ambient/plist_helper.rb