dutiful 0.0.10 → 1.0.0

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
  SHA1:
3
- metadata.gz: 77661dc7c89c798e383b4866921f2d12d10e4c63
4
- data.tar.gz: 4e7a2cc9951499ab8761dbd8547a56bd1e1f50d6
3
+ metadata.gz: 903940d65db5375e44a2f68fa7b4efcae43a24ae
4
+ data.tar.gz: 46f46b34e4a4ac06d0a9847d16f10f55bdc257ac
5
5
  SHA512:
6
- metadata.gz: e3febcb417b4a94930ddad87562e7d013481848eaa2ae6f83e9a822a39a76bcdf905f7e722ab8d5fbfa80212066b1608dd6d36f6ef5e4ba6e4eae8db5601df49
7
- data.tar.gz: 60f80377d514e640f756b942901a6f8ccd2d8fbc869d9fa5f0e69347c18f6922fce176ce9eab9a2e1279d84a4b14ccb598e2e3aa91197f9436e33cdbbfe060c5
6
+ metadata.gz: e9a5aae2f42b8464067e41f2bb55cbbb7f4f44d95f19c100f182d35b0eaa7813b03c51fedee458fdaec69950efce309eb716c163883131bbccebfd8585854959
7
+ data.tar.gz: 882ac0bb2c305bccf38791afb1bbe634b29da49591e93238f094c42c6e91780e20b3904b9e0993c9956709a4909bb3a03aed4e8224395fab8142300264311972
@@ -0,0 +1,8 @@
1
+ [application]
2
+ name = 'OSX Finder'
3
+
4
+ [[default]]
5
+ description = 'Set default view mode for Finder: `icnv`, `clmv`, `Flwv`, `Nlsv`'
6
+ domain = 'com.apple.finder'
7
+ key = 'FXPreferredViewStyle'
8
+ type = '-string'
@@ -0,0 +1,20 @@
1
+ [application]
2
+ name = 'OSX Global Domain'
3
+
4
+ [[default]]
5
+ description = 'Disable press-and-hold for keys in favor of key repeat'
6
+ domain = 'NSGlobalDomain'
7
+ key = 'ApplePressAndHoldEnabled'
8
+ type = '-bool'
9
+
10
+ [[default]]
11
+ description = 'Set the keyboard repeat rate'
12
+ domain = 'NSGlobalDomain'
13
+ key = 'KeyRepeat'
14
+ type = '-int'
15
+
16
+ [[default]]
17
+ description = 'Set the keyboard repeat delay'
18
+ domain = 'NSGlobalDomain'
19
+ key = 'InitialKeyRepeat'
20
+ type = '-int'
data/db/osx-print.toml ADDED
@@ -0,0 +1,8 @@
1
+ [application]
2
+ name = 'OSX Print'
3
+
4
+ [[default]]
5
+ description = 'Automatically quit printer app once the print jobs complete'
6
+ domain = 'com.apple.print.PrintingPrefs'
7
+ key = '"Quit When Finished"'
8
+ type = '-bool'
@@ -5,6 +5,7 @@ class Dutiful::ApplicationDefault
5
5
  @description = hash[:description]
6
6
  @domain = hash[:domain]
7
7
  @key = hash[:key]
8
+ @type = hash[:type]
8
9
  end
9
10
 
10
11
  def backup
@@ -17,30 +18,36 @@ class Dutiful::ApplicationDefault
17
18
  end
18
19
 
19
20
  def backup_value
20
- value = nil
21
- File.open(backup_path) { |file| value = file.read }
21
+ File.read(backup_path)
22
+ end
22
23
 
23
- value
24
+ def parsed_backup_value
25
+ case @type
26
+ when '-bool'
27
+ backup_value == '1' ? true : false
28
+ else
29
+ backup_value
30
+ end
24
31
  end
25
32
 
26
33
  def restore
27
- `defaults write #{@domain} #{@key} #{backup_value}`
34
+ `defaults write #{@domain} #{@key} #{@type} #{parsed_backup_value}`
28
35
  Result.new nil, true
29
36
  rescue => ex
30
37
  Result.new ex.message, false
31
38
  end
32
39
 
33
40
  def name
34
- "#{@domain} #{@key}"
41
+ @key
35
42
  end
36
43
 
37
44
  def value
38
- @value ||= `defaults read #{@domain} #{@key} 2>/dev/null`
45
+ @value ||= `defaults read #{@domain} #{@key} 2>/dev/null`.strip
39
46
  end
40
47
 
41
48
  def exist?
42
49
  @exists ||= begin
43
- @value = `defaults read #{@domain} #{@key} 2>/dev/null`
50
+ value
44
51
  $?.success?
45
52
  end
46
53
  end
@@ -67,12 +67,12 @@ class Dutiful::ApplicationFile
67
67
 
68
68
  def meets_conditions?
69
69
  if has_condition?
70
- output = `#{command}`
70
+ output = `#{command}`.strip
71
71
 
72
72
  if expected_status
73
73
  $?.exitstatus == expected_status
74
74
  else
75
- $?.success? && output.strip == expected_output
75
+ $?.success? && output == expected_output
76
76
  end
77
77
  else
78
78
  true
@@ -0,0 +1,13 @@
1
+ class Dutiful::Command::Init < Clamp::Command
2
+ def execute
3
+ if File.exist? Dutiful::Config::PATH
4
+ Dutiful::Logger.warning "Configuration file already exist: '~/.dutiful/config.toml'."
5
+ exit 1
6
+ end
7
+
8
+ FileUtils.mkdir_p Dutiful.dir
9
+ FileUtils.cp File.expand_path("#{Dutiful.dir}/template/config.toml"), Dutiful::Config::PATH
10
+
11
+ Dutiful::Logger.success "Configuration file successfully created: '~/.dutiful/config.toml'."
12
+ end
13
+ end
@@ -4,20 +4,8 @@ class Dutiful::Command::Main < Clamp::Command
4
4
  exit 0
5
5
  end
6
6
 
7
- option ['--init'], :flag, 'Initialize your computer with dutiful.' do
8
- if File.exist? Dutiful::Config::PATH
9
- Dutiful::Logger.warning "Configuration file already exist: '~/.dutiful/config.toml'."
10
- exit 1
11
- end
12
-
13
- FileUtils.mkdir_p Dutiful.dir
14
- FileUtils.cp File.expand_path("#{Dutiful.dir}/template/config.toml"), Dutiful::Config::PATH
15
-
16
- Dutiful::Logger.success "Configuration file successfully created: '~/.dutiful/config.toml'."
17
- exit 0
18
- end
19
-
20
- subcommand 'backup', 'Backup all preference files', Dutiful::Command::Backup
21
- subcommand 'list', 'List all preference files', Dutiful::Command::List
7
+ subcommand 'backup', 'Backup all preference files', Dutiful::Command::Backup
8
+ subcommand 'init', 'Initialize the configuration file', Dutiful::Command::Init
9
+ subcommand 'list', 'List all preference files', Dutiful::Command::List
22
10
  subcommand 'restore', 'Restore all preference files', Dutiful::Command::Restore
23
11
  end
@@ -2,6 +2,7 @@ module Dutiful::Command; end
2
2
 
3
3
  require 'clamp'
4
4
  require 'dutiful/commands/backup'
5
+ require 'dutiful/commands/init'
5
6
  require 'dutiful/commands/list'
6
7
  require 'dutiful/commands/restore'
7
8
  require 'dutiful/commands/main'
@@ -1,3 +1,3 @@
1
1
  module Dutiful
2
- VERSION = '0.0.10'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dutiful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Pinto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-06 00:00:00.000000000 Z
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -127,6 +127,9 @@ files:
127
127
  - db/git.toml
128
128
  - db/iterm2.toml
129
129
  - db/oh-my-zsh.toml
130
+ - db/osx-finder.toml
131
+ - db/osx-global-domain.toml
132
+ - db/osx-print.toml
130
133
  - db/osx-screencapture.toml
131
134
  - db/popcorn-time.toml
132
135
  - db/rubymine.toml
@@ -142,6 +145,7 @@ files:
142
145
  - lib/dutiful/application_file.rb
143
146
  - lib/dutiful/commands.rb
144
147
  - lib/dutiful/commands/backup.rb
148
+ - lib/dutiful/commands/init.rb
145
149
  - lib/dutiful/commands/list.rb
146
150
  - lib/dutiful/commands/main.rb
147
151
  - lib/dutiful/commands/restore.rb
@@ -173,5 +177,5 @@ rubyforge_project:
173
177
  rubygems_version: 2.4.5
174
178
  signing_key:
175
179
  specification_version: 4
176
- summary: dutiful-0.0.10
180
+ summary: dutiful-1.0.0
177
181
  test_files: []