Sha256: b52ab02e2b4d3ace56768ca50f7997755bce679255d31e055a5d924fd2f4fe82

Contents?: true

Size: 493 Bytes

Versions: 23

Compression:

Stored size: 493 Bytes

Contents

require 'plist'
require 'shellwords'

module Hackmac
  module Plist
    def plist(*cmd)
      @plist = ::Plist.parse_xml(`#{Shellwords.join(cmd)}`)
    end

    def as_hash(*)
      @plist.dup
    end

    def each(&block)
      as_hash.each(&block)
    end

    def to_json(*a)
      as_hash.to_json(*a)
    end

    def method_missing(name, *a)
      n = name.to_s
      if n =~ /(.+)=\z/
        @plist[$1] = a.first
      elsif @plist.key?(n)
        @plist[n]
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
hackmac-1.8.0 lib/hackmac/plist.rb
hackmac-1.7.1 lib/hackmac/plist.rb
hackmac-1.7.0 lib/hackmac/plist.rb
hackmac-1.6.1 lib/hackmac/plist.rb
hackmac-1.6.0 lib/hackmac/plist.rb
hackmac-1.5.1 lib/hackmac/plist.rb
hackmac-1.5.0 lib/hackmac/plist.rb
hackmac-1.4.2 lib/hackmac/plist.rb
hackmac-1.4.1 lib/hackmac/plist.rb
hackmac-1.4.0 lib/hackmac/plist.rb
hackmac-1.3.0 lib/hackmac/plist.rb
hackmac-1.2.1 lib/hackmac/plist.rb
hackmac-1.2.0 lib/hackmac/plist.rb
hackmac-1.1.3 lib/hackmac/plist.rb
hackmac-1.1.2 lib/hackmac/plist.rb
hackmac-1.1.1 lib/hackmac/plist.rb
hackmac-1.1.0 lib/hackmac/plist.rb
hackmac-1.0.5 lib/hackmac/plist.rb
hackmac-1.0.4 lib/hackmac/plist.rb
hackmac-1.0.3 lib/hackmac/plist.rb