class Polites::Plist

Read macos binary .plist files into a Hash by converting them to JSON format using the macos native `plutil` program. This only works on macos.

Public Class Methods

new(path) click to toggle source

@param [#to_s] path

# File lib/polites/plist.rb, line 11
def initialize(path)
  @path = path
end

Public Instance Methods

to_h() click to toggle source

@return [Hash]

# File lib/polites/plist.rb, line 16
def to_h
  @content ||= read_plist
end

Private Instance Methods

read_plist() click to toggle source
# File lib/polites/plist.rb, line 22
def read_plist
  "plutil -convert json -o - #{@path}"
    .then { |s| Open3.capture2(s) }
    .then { |(json, _)| JSON.parse(json) }
end