class MacAppSync::Defaults::Store
Attributes
domain[R]
plist[R]
Public Class Methods
new(domain)
click to toggle source
# File lib/mac_app_sync/defaults/store.rb, line 8 def initialize(domain) @domain = domain @plist = load_plist end
Public Instance Methods
plist_path()
click to toggle source
# File lib/mac_app_sync/defaults/store.rb, line 30 def plist_path @plist_path ||= prefs_file_path || container_file_path end
set(key, value)
click to toggle source
# File lib/mac_app_sync/defaults/store.rb, line 21 def set(key, value) new_value = PlistConverter.to_plist(value) current_value = plist.value.value[key] if Comparator.different?(current_value, new_value) plist.value.value[key] = new_value end end
to_binary()
click to toggle source
# File lib/mac_app_sync/defaults/store.rb, line 17 def to_binary plist.to_str(CFPropertyList::List::FORMAT_XML) end
values()
click to toggle source
# File lib/mac_app_sync/defaults/store.rb, line 13 def values PlistConverter.to_ruby(plist.value) end
Private Instance Methods
container_file_path()
click to toggle source
# File lib/mac_app_sync/defaults/store.rb, line 47 def container_file_path container_path = "~/Library/Containers/#{domain}/Data/Library/Preferences/#{domain}.plist" container_file = Pathname.new(container_path).expand_path container_file.to_s if container_file.exist? end
load_plist()
click to toggle source
# File lib/mac_app_sync/defaults/store.rb, line 36 def load_plist CFPropertyList::List.new(file: plist_path).tap do |list| list.value = CFPropertyList::CFDictionary.new if plist_path.nil? end end
prefs_file_path()
click to toggle source
# File lib/mac_app_sync/defaults/store.rb, line 42 def prefs_file_path prefs_file = Pathname.new("~/Library/Preferences/#{domain}.plist").expand_path prefs_file.to_s if prefs_file.exist? end