Method: RunLoop::PlistBuddy#plist_read

Defined in:
lib/run_loop/plist_buddy.rb

#plist_read(key, file, opts = {}) ⇒ String

Reads key from file and returns the result.

Parameters:

  • key (String)

    the key to inspect (may not be nil or empty)

  • file (String)

    the plist to read

  • opts (Hash) (defaults to: {})

    options for controlling execution

Options Hash (opts):

  • :verbose (Boolean) — default: false

    controls log level

Returns:

  • (String)

    the value of the key

Raises:

  • (ArgumentError)

    if nil or empty key



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/run_loop/plist_buddy.rb', line 22

def plist_read(key, file, opts={})
  if key.nil? or key.length == 0
    raise(ArgumentError, "key '#{key}' must not be nil or empty")
  end
  cmd = build_plist_cmd(:print, {:key => key}, file)
  success, output = execute_plist_cmd(cmd, file, opts)
  if !success
    nil
  else
    output
  end
end