dutiful 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c142c67f340f829180610527d671d12f3d94caca
4
- data.tar.gz: c4dfcb8159c02cb28d97a61a5b78df61ab81c35b
3
+ metadata.gz: 7c4ff77357fdd7e791b53d6f82c7cbef2940a2f1
4
+ data.tar.gz: 2d3bcf04350bb48e0f41f8ad04395b54024547bc
5
5
  SHA512:
6
- metadata.gz: aed637c66c65c152a6b0ce3ce61ba031708dae7a2ea58adf27857d0e7dab2d44f6363ab6133f300fd9a3c806ad6a037051d20e453376f998813fa3c8fa099666
7
- data.tar.gz: af82d91d168afa3a261e9618f2678e233af6e5f0b972f19a67c705b4bd75dd9cd460b1fe95b59798d4eee2ad1182c5e9f495e7650aeced89b538fbf16b16ec9a
6
+ metadata.gz: 80a690af56ded5e3278396feda4da1aa49744012f7169b19089673492a9a8cade27a8a6ee2c757bb5d2e6d17ebd1209671f28ba5942ec67c71f8cb143d05e907
7
+ data.tar.gz: 3f0234c53031fc8020aa4ed1c43356f830606aec3651b1e23521d2264a8e8f13a01eee3b702d81e7a4bb1c4d0ac070062aea29c277582ba4e4b2d07d9def0bcc
data/db/alfred.toml ADDED
@@ -0,0 +1,22 @@
1
+ [application]
2
+ name = 'Alfred'
3
+
4
+ [[file]]
5
+ path = 'Library/Preferences/com.runningwithcrayons.Alfred-2.plist'
6
+
7
+ [[file]]
8
+ path = 'Library/Preferences/com.runningwithcrayons.Alfred-Preferences.plist'
9
+
10
+ [[file]]
11
+ path = 'Library/Application Support/Alfred 2/license.plist'
12
+
13
+ [file.condition]
14
+ command = 'defaults read-type com.runningwithcrayons.Alfred-Preferences syncfolder 2>&1'
15
+ expected_output = 'Type is string'
16
+
17
+ [[file]]
18
+ path = 'Library/Application Support/Alfred 2/'
19
+
20
+ [file.condition]
21
+ command = 'defaults read-type com.runningwithcrayons.Alfred-Preferences syncfolder 2>&1'
22
+ expected_status = 1
data/db/brew.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [application]
2
2
  name = 'Brew'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = 'Brewfile'
data/db/bundler.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [application]
2
2
  name = 'Bundler'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = '.bundle/config'
data/db/dash.toml CHANGED
@@ -1,14 +1,14 @@
1
1
  [application]
2
2
  name = 'Dash'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = 'Library/Application Support/Dash/library.dash'
6
6
 
7
- [[files]]
7
+ [[file]]
8
8
  path = 'Library/Application Support/Dash/License/license.dash-license'
9
9
 
10
- [[files]]
10
+ [[file]]
11
11
  path = 'Library/Preferences/com.kapeli.dash.plist'
12
12
 
13
- [[files]]
13
+ [[file]]
14
14
  path = 'Library/Preferences/com.kapeli.dashdoc.plist'
data/db/dutiful.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [application]
2
2
  name = 'Dutiful'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = '.dutiful/config.toml'
data/db/fish.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [application]
2
2
  name = 'Fish'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = '.config/fish/config.fish'
data/db/git.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [application]
2
2
  name = 'Git'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = '.gitconfig'
6
6
  path = '.gitignore'
data/db/iterm2.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [application]
2
2
  name = 'iTerm2'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = 'Library/Preferences/com.googlecode.iterm2.plist'
data/db/oh-my-zsh.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [application]
2
2
  name = 'Oh My Zsh'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = '.oh-my-zsh/'
data/db/popcorn-time.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [application]
2
2
  name = 'Popcorn-Time'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = 'Library/Application Support/Popcorn-Time/data/'
data/db/rubymine.toml CHANGED
@@ -1,15 +1,15 @@
1
1
  [application]
2
2
  name = 'RubyMine'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = 'Library/Application Support/RubyMine60'
6
6
 
7
- [[files]]
7
+ [[file]]
8
8
  path = 'Library/Preferences/RubyMine60'
9
9
 
10
- [[files]]
10
+ [[file]]
11
11
  path = 'Library/Application Support/RubyMine70'
12
12
 
13
- [[files]]
13
+ [[file]]
14
14
  path = 'Library/Preferences/RubyMine70'
15
15
 
@@ -1,5 +1,5 @@
1
1
  [application]
2
2
  name = 'The Silver Seacher'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = '.agignore'
data/db/tmux.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [application]
2
2
  name = 'tmux'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = '.tmux.conf'
data/db/tmuxline.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [application]
2
2
  name = 'tmuxline.vim'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = '.tmuxline'
data/db/vim.toml CHANGED
@@ -1,8 +1,8 @@
1
1
  [application]
2
2
  name = 'Vim'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = '.vimrc'
6
6
 
7
- [[files]]
7
+ [[file]]
8
8
  path = '.gvimrc'
data/db/z.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [application]
2
2
  name = 'z'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = '.z'
data/db/zsh.toml CHANGED
@@ -1,17 +1,17 @@
1
1
  [application]
2
2
  name = 'Zsh'
3
3
 
4
- [[files]]
4
+ [[file]]
5
5
  path = '.zshenv'
6
6
 
7
- [[files]]
7
+ [[file]]
8
8
  path = '.zprofile'
9
9
 
10
- [[files]]
10
+ [[file]]
11
11
  path = '.zshrc'
12
12
 
13
- [[files]]
13
+ [[file]]
14
14
  path = '.zlogin'
15
15
 
16
- [[files]]
16
+ [[file]]
17
17
  path = '.zlogout'
@@ -8,7 +8,7 @@ class Dutiful::Application
8
8
  end
9
9
 
10
10
  def files
11
- content[:files].map { |file| Dutiful::ApplicationFile.new file[:path] }
11
+ content[:file].map { |file| Dutiful::ApplicationFile.new file[:path], file[:condition] }
12
12
  end
13
13
 
14
14
  def exist?
@@ -21,7 +21,7 @@ class Dutiful::Application
21
21
 
22
22
  def sync
23
23
  files.each do |file|
24
- if file.exist? || file.has_backup?
24
+ if file.should_sync?
25
25
  result = Dutiful::Config.storage.sync(file)
26
26
  yield file, result if block_given?
27
27
  else
@@ -30,6 +30,10 @@ class Dutiful::Application
30
30
  end
31
31
  end
32
32
 
33
+ def should_sync?
34
+ exist? || has_backup?
35
+ end
36
+
33
37
  def synced?
34
38
  files.all? &:synced?
35
39
  end
@@ -1,8 +1,11 @@
1
1
  class Dutiful::ApplicationFile
2
2
  attr_reader :full_path, :path
3
3
 
4
- def initialize(path)
5
- @path = path
4
+ def initialize(path, condition)
5
+ @command = condition[:command] if condition
6
+ @expected_output = condition[:expected_output] if condition
7
+ @expected_status = condition[:expected_status] if condition
8
+ @path = path
6
9
 
7
10
  if directory?
8
11
  @full_path = "#{File.expand_path "~/#{path}"}/"
@@ -23,6 +26,20 @@ class Dutiful::ApplicationFile
23
26
  File.mtime full_path if exist?
24
27
  end
25
28
 
29
+ def meets_conditions?
30
+ if has_condition?
31
+ output = `#{@command}`
32
+
33
+ if @expected_status
34
+ $?.exitstatus == @expected_status
35
+ else
36
+ $?.success? && output.strip == @expected_output
37
+ end
38
+ else
39
+ true
40
+ end
41
+ end
42
+
26
43
  def directory?
27
44
  path.chars.last == '/'
28
45
  end
@@ -35,11 +52,21 @@ class Dutiful::ApplicationFile
35
52
  Dutiful::Config.storage.exist? self
36
53
  end
37
54
 
55
+ def has_condition?
56
+ @command
57
+ end
58
+
59
+ def should_sync?
60
+ (exist? || has_backup?) && meets_conditions?
61
+ end
62
+
38
63
  def synced?
39
64
  has_backup? && Dutiful::Config.storage.synced?(self)
40
65
  end
41
66
 
42
67
  def to_s
68
+ return "#{path} does not meet conditions (skipping)".yellow unless meets_conditions?
69
+
43
70
  if exist?
44
71
  if has_backup?
45
72
  if synced?
@@ -5,10 +5,10 @@ class Dutiful::Command::List < Clamp::Command
5
5
  puts "Storage: #{Dutiful::Config.storage.name}\n\n"
6
6
 
7
7
  Dutiful::Application.each do |application|
8
- puts "#{application.name}:\n" if application.exist? || application.has_backup? || verbose?
8
+ puts "#{application.name}:\n" if application.should_sync? || verbose?
9
9
 
10
10
  application.files.map do |file|
11
- puts " #{file}" if file.exist? || file.has_backup? || verbose?
11
+ puts " #{file}" if (file.should_sync?) || verbose?
12
12
  end.compact.join("\n")
13
13
  end
14
14
  end
@@ -5,7 +5,7 @@ class Dutiful::Command::Sync < Clamp::Command
5
5
  puts "Storage: #{Dutiful::Config.storage.name}\n\n"
6
6
 
7
7
  Dutiful::Application.each do |application|
8
- puts "#{application.name}:\n" if application.exist? || application.has_backup? || verbose?
8
+ puts "#{application.name}:\n" if application.should_sync? || verbose?
9
9
 
10
10
  application.sync do |file, result|
11
11
  if result
@@ -15,7 +15,7 @@ class Dutiful::Command::Sync < Clamp::Command
15
15
  puts " #{file.path} ✖ - #{result.error}".red
16
16
  end
17
17
  elsif verbose?
18
- puts " #{file.path} does not exist (skipping)".yellow
18
+ puts " #{file}"
19
19
  end
20
20
  end
21
21
  end
@@ -19,7 +19,7 @@ class Dutiful::Storage
19
19
 
20
20
  def create_dir(file)
21
21
  FileUtils.mkdir_p File.dirname "#{path}/#{file.path}"
22
- FileUtils.mkdir_p "/Users/bpinto/Dropbox/dutiful/Library/Application\ Support/Dash"
22
+ FileUtils.mkdir_p File.dirname "#{file.full_path}"
23
23
  end
24
24
 
25
25
  def exist?(file)
@@ -54,7 +54,9 @@ class Dutiful::Storage
54
54
  filename = File.basename(file_path)
55
55
  file_backup_path = path "#{file.path}#{filename}"
56
56
 
57
- FileUtils.identical? file_path, file_backup_path
57
+ File.exist?(file_path) &&
58
+ File.exist?(file_backup_path) &&
59
+ FileUtils.identical?(file_path, file_backup_path)
58
60
  end
59
61
  else
60
62
  FileUtils.identical? file.full_path, "#{path}/#{file.path}"
@@ -1,3 +1,3 @@
1
1
  module Dutiful
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dutiful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Pinto
@@ -104,6 +104,7 @@ files:
104
104
  - bin/dutiful
105
105
  - config/dropbox.toml
106
106
  - config/icloud.toml
107
+ - db/alfred.toml
107
108
  - db/brew.toml
108
109
  - db/bundler.toml
109
110
  - db/dash.toml
@@ -153,5 +154,5 @@ rubyforge_project:
153
154
  rubygems_version: 2.4.5
154
155
  signing_key:
155
156
  specification_version: 4
156
- summary: dutiful-0.0.6
157
+ summary: dutiful-0.0.7
157
158
  test_files: []