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.0.2 lib/hackmac/plist.rb
hackmac-1.0.1 lib/hackmac/plist.rb
hackmac-1.0.0 lib/hackmac/plist.rb