Module: Plutil::JSON

Defined in:
lib/tm_bundle/plutil.rb

Class Method Summary collapse

Class Method Details

.call(*args) ⇒ Object



11
12
13
# File 'lib/tm_bundle/plutil.rb', line 11

def self.call(*args)
  load(*args)
end

.dump(object, options = {}) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/tm_bundle/plutil.rb', line 15

def self.dump(object, options = {})
  Plutil.convert :stdin, options.reverse_merge(to: :xml) do |io|
    io.write ::JSON.dump(object.to_h)
    io.close_write
    io.read
  end
end

.load(plist) ⇒ Object



5
6
7
8
9
# File 'lib/tm_bundle/plutil.rb', line 5

def self.load(plist)
  Plutil.convert plist, to: :json do |converted_io|
    ::JSON.load(converted_io)
  end
end