Class: Geoffrey::Plist
- Inherits:
-
Object
- Object
- Geoffrey::Plist
- 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
-
#changes ⇒ Object
Returns the value of attribute changes.
-
#data ⇒ Object
Returns the value of attribute data.
-
#file(file = nil) ⇒ Object
Set the file you’ll edit.
-
#process ⇒ Object
Returns the value of attribute process.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#affects(value) ⇒ Object
If a process must be killed before we change settings.
-
#initialize ⇒ Plist
constructor
A new instance of Plist.
- #options ⇒ Object
-
#save ⇒ Object
Saves the changes defined into the file.
Constructor Details
#initialize ⇒ Plist
Returns a new instance of Plist.
15 16 17 |
# File 'lib/geoffrey/plist.rb', line 15 def initialize @changes = {} end |
Instance Attribute Details
#changes ⇒ Object
Returns the value of attribute changes.
13 14 15 |
# File 'lib/geoffrey/plist.rb', line 13 def changes @changes end |
#data ⇒ Object
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 |
#process ⇒ Object
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 |
#options ⇒ Object
36 37 38 |
# File 'lib/geoffrey/plist.rb', line 36 def self end |
#save ⇒ Object
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 |