Class: PlistParser

Inherits:
Object show all
Defined in:
lib/kanseishitsu/plist_parser.rb

Overview

Define class PlistParser

Constant Summary collapse

EMPTY_STRING =
''.freeze

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ PlistParser

Returns a new instance of PlistParser.



17
18
19
# File 'lib/kanseishitsu/plist_parser.rb', line 17

def initialize(file_path)
  @file_path = file_path
end

Instance Method Details

#parseObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/kanseishitsu/plist_parser.rb', line 21

def parse
  xml = File.read(@file_path)
  document = REXML::Document.new(xml)
  plist = parse_element(document.root.elements[1]) # the root <dict> inside <plist>
  LaunchAgentPlist.new(
    plist['Label'],
    plist['ProgramArguments'],
    plist['StartInterval'] || plist['CalendarStartInterval']
  )
end