Class: Geoffrey::Plist

Inherits:
Object
  • Object
show all
Defined in:
lib/geoffrey/plist.rb

Overview

This class helps you configure your Applications

Constant Summary collapse

FILES =
{
  :textmate => "#{ENV["HOME"]}/Library/Preferences/com.macromates.textmate.plist",
  :terminal => "#{ENV["HOME"]}/Library/Preferences/com.apple.Terminal.plist"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePlist

Returns a new instance of Plist.



15
16
17
# File 'lib/geoffrey/plist.rb', line 15

def initialize
  @changes = {}
end

Instance Attribute Details

#changesObject

Returns the value of attribute changes.



13
14
15
# File 'lib/geoffrey/plist.rb', line 13

def changes
  @changes
end

#dataObject

Returns the value of attribute data.



13
14
15
# File 'lib/geoffrey/plist.rb', line 13

def data
  @data
end

#file(file = nil) ⇒ Object

Set the file you’ll edit. if you pass a symbol then it’ll use the file defined in the FILES hash.



21
22
23
# File 'lib/geoffrey/plist.rb', line 21

def file
  @file
end

#processObject

Returns the value of attribute process.



13
14
15
# File 'lib/geoffrey/plist.rb', line 13

def process
  @process
end

Instance Method Details

#[](key) ⇒ Object



40
41
42
# File 'lib/geoffrey/plist.rb', line 40

def [](key)
  data[key]
end

#[]=(key, value) ⇒ Object



44
45
46
47
48
# File 'lib/geoffrey/plist.rb', line 44

def []=(key,value)
  old_value = data[key]
  data[key] = value
  @changes[key] = value if old_value != value
end

#affects(value) ⇒ Object

If a process must be killed before we change settings



32
33
34
# File 'lib/geoffrey/plist.rb', line 32

def affects(value)
  @process = value
end

#optionsObject



36
37
38
# File 'lib/geoffrey/plist.rb', line 36

def options
  self
end

#saveObject

Saves the changes defined into the file.



51
52
53
54
55
# File 'lib/geoffrey/plist.rb', line 51

def save
  kill
  data.save
  open
end