dotify 0.5.0 → 0.5.1
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.
- data/dotify.gemspec +2 -0
- data/lib/dotify.rb +5 -1
- data/lib/dotify/cli.rb +43 -15
- data/lib/dotify/git.rb +22 -0
- data/lib/dotify/version.rb +1 -1
- data/lib/dotify/version_checker.rb +6 -2
- data/spec/dotify/git_spec.rb +5 -0
- metadata +37 -2
data/dotify.gemspec
CHANGED
@@ -16,7 +16,9 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = Dotify::VERSION
|
17
17
|
|
18
18
|
gem.add_dependency "thor"
|
19
|
+
gem.add_dependency "multi_json"
|
19
20
|
gem.add_dependency "json"
|
21
|
+
gem.add_dependency "git"
|
20
22
|
gem.add_development_dependency "rspec"
|
21
23
|
gem.add_development_dependency "webmock"
|
22
24
|
gem.add_development_dependency "vcr"
|
data/lib/dotify.rb
CHANGED
data/lib/dotify/cli.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require 'rubygems'
|
1
2
|
require 'thor'
|
2
3
|
require 'fileutils'
|
3
4
|
require 'json'
|
5
|
+
require 'git'
|
4
6
|
require 'net/http'
|
5
7
|
|
6
8
|
require 'dotify'
|
@@ -12,6 +14,10 @@ require 'dotify/version_checker'
|
|
12
14
|
Dotify::Config.load_config!
|
13
15
|
|
14
16
|
module Dotify
|
17
|
+
|
18
|
+
class Git
|
19
|
+
include ::Git
|
20
|
+
end
|
15
21
|
class CLI < Thor
|
16
22
|
include Thor::Actions
|
17
23
|
default_task :help
|
@@ -27,24 +33,44 @@ module Dotify
|
|
27
33
|
File.expand_path("../../../templates", __FILE__)
|
28
34
|
end
|
29
35
|
|
30
|
-
desc :save, "
|
36
|
+
desc :save, "Save Dotify files and push to Github."
|
31
37
|
method_option :message, :aliases => '-m', :type => :string, :required => false, :desc => "Git commit message to send to Github"
|
38
|
+
method_option :force, :aliases => '-f', :type => :boolean, :desc => "Do not ask for confirmation when adding files to the staging area."
|
39
|
+
method_option :debug, :aliases => '-d', :type => :boolean, :desc => "Show error messages if there is a Git failure."
|
40
|
+
method_option :verbose, :aliases => '-v', :type => :boolean, :default => true, :desc => "Show error messages if there is a Git failure."
|
41
|
+
method_option :push, :aliases => '-p', :type => :boolean, :default => false, :desc => "Force the push to the remote repository."
|
32
42
|
def save
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
if
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
system 'git push origin master'
|
43
|
+
if File.exists? Files.dotify('.git') # if the Dotify directory has been made a git repo
|
44
|
+
repo = ::Git.open(Config.path)
|
45
|
+
changed = repo.status.changed
|
46
|
+
if changed.size > 0
|
47
|
+
changed.each_pair do |file, status|
|
48
|
+
say_status :changed, status.path, :verbose => options[:verbose]
|
49
|
+
if options[:force] || yes?("Do you want to add '#{status.path}' to the Git index? [Yn]", :blue)
|
50
|
+
repo.add status.path
|
51
|
+
say_status :added, status.path, :verbose => options[:verbose]
|
52
|
+
end
|
44
53
|
end
|
54
|
+
message = !options[:message].nil? ? options[:message] : ask("Commit message:", :blue)
|
55
|
+
say message, :yellow, :verbose => options[:verbose]
|
56
|
+
repo.commit(message)
|
45
57
|
else
|
46
|
-
say
|
58
|
+
say "No files have been changed in Dotify.", :blue
|
59
|
+
@push = true
|
60
|
+
end
|
61
|
+
if @push == true || options[:push] || yes?("Would you like to push these changed to Github (or wherever your remote repo is located)? [Yn]", :blue)
|
62
|
+
say 'Pushing up to Github...', :blue
|
63
|
+
begin
|
64
|
+
repo.push
|
65
|
+
rescue Exception => e
|
66
|
+
say "There was a problem pushing to your remote repo.", :red
|
67
|
+
say("Grit Error: #{e.message}", :red) if options[:debug]
|
68
|
+
return
|
69
|
+
end
|
70
|
+
say "Successfully pushed!", :blue
|
47
71
|
end
|
72
|
+
else
|
73
|
+
say 'Dotify has nothing to save.', :blue
|
48
74
|
end
|
49
75
|
end
|
50
76
|
|
@@ -60,17 +86,19 @@ module Dotify
|
|
60
86
|
end
|
61
87
|
|
62
88
|
desc :version, "Check your Dotify version"
|
89
|
+
method_option :verbose, :aliases => '-v', :default => false, :type => :boolean, :desc => "Output any errors that occur during the Version check."
|
63
90
|
def version
|
64
91
|
if VersionChecker.out_of_date?
|
65
92
|
say "Your version of Dotify is out of date.", :yellow
|
66
|
-
say " Your Version: #{Dotify
|
93
|
+
say " Your Version: #{Dotify.version}", :blue
|
67
94
|
say " Latest Version: #{VersionChecker.version}", :blue
|
68
95
|
say "I recommend that you uninstall Dotify completely before updating", :yellow
|
69
96
|
else
|
70
97
|
say "Your version of Dotify is up to date: #{Dotify::VERSION}", :blue
|
71
98
|
end
|
72
|
-
rescue Exception
|
99
|
+
rescue Exception => e
|
73
100
|
say "There was an error checking your Dotify version. Please try again.", :red
|
101
|
+
say VersionChecker.handle_error(e) if options[:verbose] == true
|
74
102
|
end
|
75
103
|
|
76
104
|
desc :setup, "Setup your system for Dotify to manage your dotfiles"
|
data/lib/dotify/git.rb
ADDED
data/lib/dotify/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'multi_json'
|
2
2
|
require 'net/http'
|
3
3
|
|
4
4
|
module Dotify
|
@@ -7,7 +7,7 @@ module Dotify
|
|
7
7
|
def run_check!
|
8
8
|
if @version.nil?
|
9
9
|
resp = Net::HTTP.get('rubygems.org', '/api/v1/versions/dotify.json')
|
10
|
-
json =
|
10
|
+
json = MultiJson.load(resp)
|
11
11
|
@version = json.map { |v| v['number'] }.max
|
12
12
|
end
|
13
13
|
@version
|
@@ -24,6 +24,10 @@ module Dotify
|
|
24
24
|
def version
|
25
25
|
@version || self.run_check!
|
26
26
|
end
|
27
|
+
|
28
|
+
def handle_error(e)
|
29
|
+
"Version Check Error: #{e.message}\n#{e.backtrace.join("\n")}"
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: multi_json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: json
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,6 +59,22 @@ dependencies:
|
|
43
59
|
- - ! '>='
|
44
60
|
- !ruby/object:Gem::Version
|
45
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: git
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
46
78
|
- !ruby/object:Gem::Dependency
|
47
79
|
name: rspec
|
48
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,12 +146,14 @@ files:
|
|
114
146
|
- lib/dotify/errors.rb
|
115
147
|
- lib/dotify/file_list.rb
|
116
148
|
- lib/dotify/files.rb
|
149
|
+
- lib/dotify/git.rb
|
117
150
|
- lib/dotify/version.rb
|
118
151
|
- lib/dotify/version_checker.rb
|
119
152
|
- spec/dotify/cli_spec.rb
|
120
153
|
- spec/dotify/config_spec.rb
|
121
154
|
- spec/dotify/file_list_spec.rb
|
122
155
|
- spec/dotify/files_spec.rb
|
156
|
+
- spec/dotify/git_spec.rb
|
123
157
|
- spec/dotify/version_checker_spec.rb
|
124
158
|
- spec/fixtures/.dotrc-default
|
125
159
|
- spec/fixtures/vcr/version_check.yml
|
@@ -157,6 +191,7 @@ test_files:
|
|
157
191
|
- spec/dotify/config_spec.rb
|
158
192
|
- spec/dotify/file_list_spec.rb
|
159
193
|
- spec/dotify/files_spec.rb
|
194
|
+
- spec/dotify/git_spec.rb
|
160
195
|
- spec/dotify/version_checker_spec.rb
|
161
196
|
- spec/fixtures/.dotrc-default
|
162
197
|
- spec/fixtures/vcr/version_check.yml
|