mac_app_sync 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1717db820f1c9e2db8c533c7e021e2f05d5ac49767b7dd2dd3c2d8a3d5202f3e
4
- data.tar.gz: ad833b483a788eb5a349b8b80a26fa3ceba40298b4948b446b143d0eb51026c3
3
+ metadata.gz: c81824aaa3d35ca555cf96f1558d3639bc67b40d02342ce22af39b944b202512
4
+ data.tar.gz: 11de35c2498fe43bad82e6d199c9ff660ec776c8f15a1aae74144b956303b9b8
5
5
  SHA512:
6
- metadata.gz: 10f35cf3e51c518c544bbfb7bb8160d61fab4efdc3da9548f771257f851349f323ce75daee53b263bead250ebfaa1694268b9b31dbb668aa3c874e6903a89bf7
7
- data.tar.gz: 179e85fce3ed7ad65126e44368564db4036889a5a5199b6d7c9dcbbe78bc80d00f1c8e738d22647b49278050f88f30f1b6de5b278ff5b06d99243c37c54da4cd
6
+ metadata.gz: 34b1863093717d3586457c005a1489ffbeb7b528361f0e7a51eb2e3f63c2d98b27446b4e5af4aecfd99623ab68cfd790f8f4da06303a6827a4fe90d52cb04f14
7
+ data.tar.gz: c153faf13f0e47c601e85a09ec4282e8baca583bd3f4c98384caacd8ef2edf7cc2c05a9fb6f6ce0f66d5564ab2d0bb822bb1e3343c0067c12224df7cfe6db39d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mac_app_sync (0.1.0)
4
+ mac_app_sync (0.1.1)
5
5
  CFPropertyList
6
6
 
7
7
  GEM
@@ -3,10 +3,11 @@ require "pathname"
3
3
  module MacAppSync
4
4
  module Defaults
5
5
  class Store
6
- attr_reader :domain
6
+ attr_reader :domain, :plist
7
7
 
8
8
  def initialize(domain)
9
9
  @domain = domain
10
+ @plist = load_plist
10
11
  end
11
12
 
12
13
  def values
@@ -17,10 +18,6 @@ module MacAppSync
17
18
  plist.to_str(CFPropertyList::List::FORMAT_XML)
18
19
  end
19
20
 
20
- def plist
21
- @plist ||= CFPropertyList::List.new(file: plist_path)
22
- end
23
-
24
21
  def set(key, value)
25
22
  new_value = PlistConverter.to_plist(value)
26
23
  current_value = plist.value.value[key]
@@ -36,6 +33,12 @@ module MacAppSync
36
33
 
37
34
  private
38
35
 
36
+ def load_plist
37
+ CFPropertyList::List.new(file: plist_path).tap do |list|
38
+ list.value = CFPropertyList::CFDictionary.new if plist_path.nil?
39
+ end
40
+ end
41
+
39
42
  def prefs_file_path
40
43
  prefs_file = Pathname.new("~/Library/Preferences/#{domain}.plist").expand_path
41
44
  prefs_file.to_s if prefs_file.exist?
@@ -7,7 +7,8 @@ module MacAppSync
7
7
  def update(domain, store)
8
8
  with_tempfile(store.to_binary) do |file|
9
9
  if system("plutil -lint #{file.path}")
10
- system("defaults import #{store.plist_path} #{file.path}")
10
+ destination = store.plist_path || domain
11
+ system("defaults import '#{destination}' #{file.path}")
11
12
  else
12
13
  raise "Invalid plist for #{domain}"
13
14
  end
@@ -1,3 +1,3 @@
1
1
  module MacAppSync
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mac_app_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wean
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-03 00:00:00.000000000 Z
11
+ date: 2018-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler