Class: Plister::Preferences
- Inherits:
-
Object
- Object
- Plister::Preferences
- Defined in:
- lib/plister/preferences.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #domains ⇒ Object
-
#initialize(path = nil) ⇒ Preferences
constructor
A new instance of Preferences.
- #set!(verbose: false) ⇒ Object
Constructor Details
#initialize(path = nil) ⇒ Preferences
Returns a new instance of Preferences.
5 6 7 |
# File 'lib/plister/preferences.rb', line 5 def initialize(path = nil) @path = path || "/Users/#{Plister.user}/.osx.yml" end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/plister/preferences.rb', line 3 def path @path end |
Instance Method Details
#domains ⇒ Object
20 21 22 |
# File 'lib/plister/preferences.rb', line 20 def domains @domains ||= data.map { |_k, v| v.keys }.flatten end |
#set!(verbose: false) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/plister/preferences.rb', line 9 def set!(verbose: false) data.each do |type, domains| domains.each do |domain, prefs| puts "Setting #{type} preferences for #{domain}" if verbose plist = Plist.new(domain, type: type) plist.merge(prefs) plist.write end end end |