dotify 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,16 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'thor'
4
- gem 'multi_json'
5
- gem 'git'
6
-
7
- group :test, :development do
8
- gem 'rspec', '~> 2.11.0'
9
- gem 'simplecov'
10
- gem 'cucumber'
11
- gem 'webmock'
12
- gem 'vcr'
13
-
14
- gem 'guard-rspec'
15
- gem 'guard-cucumber'
16
- end
3
+ gemspec
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/mattdbridges/dotify.png)](http://travis-ci.org/mattdbridges/dotify) [![Dependency Status](https://gemnasium.com/mattdbridges/dotify.png)](https://gemnasium.com/mattdbridges/dotify)
4
4
 
5
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/mattdbridges/dotify)
6
+
5
7
  Dotify is a simple CLI tool to make managing dotfiles on your system easy. When developing on a Linux/Unix-based system, keeping track of all of those dotfiles in the home directory can be pain. Some developers do not even bother managing them and many have come up with their own static or even dynamic way of managing them. This is a need in the community, and this tool makes managing these crazy files a breeze.
6
8
 
7
9
  ## Ruby Version Support
data/dotify.gemspec CHANGED
@@ -14,4 +14,17 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "dotify"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Dotify::VERSION
17
+
18
+ gem.add_runtime_dependency "thor", "~> 0.15.4"
19
+ gem.add_runtime_dependency "multi_json", "~> 1.3.6"
20
+ gem.add_runtime_dependency "git", "~> 1.2.5"
21
+
22
+ gem.add_development_dependency 'rspec', '~> 2.11.0'
23
+ gem.add_development_dependency 'simplecov'
24
+ gem.add_development_dependency 'cucumber'
25
+ gem.add_development_dependency 'webmock'
26
+ gem.add_development_dependency 'vcr'
27
+
28
+ gem.add_development_dependency 'guard-rspec'
29
+ gem.add_development_dependency 'guard-cucumber'
17
30
  end
@@ -8,5 +8,7 @@ Given /^I have setup Dotify$/i do
8
8
  end
9
9
 
10
10
  When /^I try to setup Dotify$/ do
11
- Dotify::CLI.new.setup
11
+ @cli.stub(:say)
12
+ @cli.stub(:invoke).with(:edit, [Dotify::Config.file]).once
13
+ @cli.setup
12
14
  end
@@ -4,9 +4,15 @@ require 'fileutils'
4
4
 
5
5
  $:.unshift(File.dirname(__FILE__) + '/../../lib')
6
6
  require 'dotify'
7
+ require 'cucumber/rspec/doubles'
7
8
 
8
9
  Before do
9
10
  @__orig_home = ENV["HOME"]
11
+
12
+ # Stub CLI say method
13
+ @cli = Dotify::CLI.new
14
+ @cli.stub(:say)
15
+
10
16
  ENV["HOME"] = "/tmp"
11
17
  `rm -rf #{File.join(ENV["HOME"], '.bash_profile')}`
12
18
  `rm -rf #{File.join(ENV["HOME"], '.gemrc')}`
data/lib/dotify/cli.rb CHANGED
@@ -9,9 +9,6 @@ require 'dotify/version_checker'
9
9
 
10
10
  module Dotify
11
11
 
12
- class Git
13
- include ::Git
14
- end
15
12
  class CLI < Thor
16
13
  include Thor::Actions
17
14
  default_task :help
@@ -50,9 +47,8 @@ module Dotify
50
47
  repo.commit(message)
51
48
  else
52
49
  say "No files have been changed in Dotify.", :blue
53
- @push = true
54
50
  end
55
- if @push == true || options[:push] || yes?("Would you like to push these changed to Github (or wherever your remote repo is located)? [Yn]", :blue)
51
+ if options[:push] || yes?("Would you like to push these changed to Github? [Yn]", :blue)
56
52
  say 'Pushing up to Github...', :blue
57
53
  begin
58
54
  repo.push
@@ -153,11 +149,11 @@ module Dotify
153
149
  def link(file = nil)
154
150
  return not_setup_warning unless Dotify.installed?
155
151
  # Link a single file
156
- return link_file Unit.new(file), options unless file.nil?
152
+ return file_action :link, Unit.new(file), options unless file.nil?
157
153
  # Relink the files
158
- return Dotify.collection.linked.each { |file| link_file(file, options) } if options[:relink]
154
+ return Dotify.collection.linked.each { |file| file_action(:link, file, options) } if options[:relink]
159
155
  # Link the files
160
- Dotify.collection.unlinked.each { |file| link_file(file, options) }
156
+ Dotify.collection.unlinked.each { |file| file_action(:link, file, options) }
161
157
  end
162
158
 
163
159
  desc 'unlink [[FILENAME]]', "Unlink one or all of your dotfiles (FILENAME is optional)"
@@ -171,9 +167,9 @@ module Dotify
171
167
  def unlink(file = nil)
172
168
  return not_setup_warning unless Dotify.installed?
173
169
  # Unlink a single file
174
- return unlink_file Unit.new(file), options unless file.nil?
170
+ return file_action :unlink, Unit.new(file), options unless file.nil?
175
171
  # Unlink the files
176
- Dotify.collection.linked.each { |file| unlink_file(file, options) }
172
+ Dotify.collection.linked.each { |file| file_action(:unlink, file, options) }
177
173
  end
178
174
 
179
175
  no_tasks do
@@ -182,20 +178,20 @@ module Dotify
182
178
  say "Dotify has not been setup yet! You need to run 'dotify setup' first.", :yellow
183
179
  end
184
180
 
185
- def unlink_file(file, options = {})
186
- say "'#{file}' does not exist in Dotify.", :blue unless file.linked?
187
- if options[:force] == true || yes?("Do you want to unlink #{file} from the home directory? [Yn]", :blue)
188
- file.unlink
189
- say_status :unlinked, file.home
181
+ def file_action(action, file, options = {})
182
+ case action.to_sym
183
+ when :link
184
+ return say "'#{file.dotfile}' does not exist.", :blue unless file.in_home_dir?
185
+ return say_status :linked, file.dotfile if file.linked?
186
+ when :unlink
187
+ return say "'#{file}' does not exist in Dotify.", :blue unless file.linked?
188
+ else
189
+ say "You can't run the action :#{action} on a file."
190
190
  end
191
- end
192
191
 
193
- def link_file(file, options = {})
194
- return say_status :linked, file.dotfile if file.linked?
195
- return say "'#{file}' does not exist in the home directory.", :blue unless file.in_home_dir?
196
- if options[:force] == true || yes?("Do you want to link #{file} to the home directory? [Yn]", :blue)
197
- file.link
198
- say_status :linked, file.home
192
+ if options[:force] == true || yes?("Do you want to #{action} #{file} #{action.to_sym == :link ? :to : :from} Dotify? [Yn]", :blue)
193
+ file.send(action) if file.respond_to? action
194
+ say_status "#{action}ed", file.dotfile
199
195
  end
200
196
  end
201
197
 
data/lib/dotify/unit.rb CHANGED
@@ -46,7 +46,6 @@ module Dotify
46
46
  def dotfile
47
47
  @dotfile ||= Config.home(@filename)
48
48
  end
49
- alias :home :dotfile
50
49
 
51
50
  def linked?
52
51
  in_dotify? && linked_to_dotify?
@@ -1,3 +1,3 @@
1
1
  module Dotify
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  end
@@ -5,12 +5,11 @@ module Dotify
5
5
  class VersionChecker
6
6
  class << self
7
7
  def run_check!
8
- if @version.nil?
9
- resp = Net::HTTP.get('rubygems.org', '/api/v1/versions/dotify.json')
10
- json = MultiJson.load(resp)
11
- @version = json.map { |v| v['number'] }.max
12
- end
13
- @version
8
+ return if !@version.nil?
9
+
10
+ resp = Net::HTTP.get('rubygems.org', '/api/v1/versions/dotify.json')
11
+ json = MultiJson.load(resp)
12
+ @version = json.map { |v| v['number'] }.max
14
13
  end
15
14
 
16
15
  def current?
@@ -42,14 +42,14 @@ module Dotify
42
42
 
43
43
  describe CLI, "#link" do
44
44
  before do
45
- cli.stub(:link_file)
45
+ cli.stub(:file_action)
46
46
  end
47
47
  it "should loop through all unlinked files" do
48
48
  Dotify.collection.should_receive(:unlinked).and_return Dotify.collection.reject(&:linked?)
49
49
  cli.link
50
50
  end
51
51
  it "should call link_file on the right files" do
52
- cli.should_receive(:link_file).exactly(Dotify.collection.unlinked.size).times
52
+ cli.should_receive(:file_action).exactly(Dotify.collection.unlinked.size).times
53
53
  cli.link
54
54
  end
55
55
  it "should relink all of the files located in Dotify" do
@@ -59,7 +59,7 @@ module Dotify
59
59
  cli.link
60
60
  end
61
61
  it "attempt to link one single file" do
62
- cli.should_receive(:link_file).with(an_instance_of(Unit), {})
62
+ cli.should_receive(:file_action).with(:link, an_instance_of(Unit), {})
63
63
  cli.link('.vimrc')
64
64
  end
65
65
  it "should output a warning if Dotify is not installed" do
@@ -71,18 +71,18 @@ module Dotify
71
71
 
72
72
  describe CLI, "#unlink" do
73
73
  before do
74
- cli.stub(:unlink_file)
74
+ cli.stub(:file_action)
75
75
  end
76
76
  it "should loop through all unlinked files" do
77
77
  Dotify.collection.should_receive(:linked).and_return Dotify.collection.select(&:linked?)
78
78
  cli.unlink
79
79
  end
80
80
  it "should call CLI#unlink_file the right number of times" do
81
- cli.should_receive(:unlink_file).exactly(Dotify.collection.linked.size).times
81
+ cli.should_receive(:file_action).exactly(Dotify.collection.linked.size).times
82
82
  cli.unlink
83
83
  end
84
84
  it "attempt to link one single file" do
85
- cli.should_receive(:unlink_file).with(an_instance_of(Unit), {})
85
+ cli.should_receive(:file_action).with(:unlink, an_instance_of(Unit), {})
86
86
  cli.unlink('.vimrc')
87
87
  end
88
88
  it "should output a warning if Dotify is not installed" do
@@ -2,10 +2,9 @@ require 'spec_helper'
2
2
  require 'dotify/unit'
3
3
 
4
4
  class DummyUnit
5
- def home
5
+ def dotfile
6
6
  '.dummy'
7
7
  end
8
- alias :dotfile :home
9
8
  def dotify
10
9
  '.dotify/.dummy'
11
10
  end
@@ -38,13 +37,13 @@ module Dotify
38
37
  subject.link.should == false
39
38
  end
40
39
  it "should copy the file from the home directory if it is not in Dotify" do
41
- FileUtils.should_receive(:rm_rf).with(subject.home, :verbose => false)
42
- FileUtils.should_receive(:ln_sf).with(subject.dotify, subject.home, :verbose => false)
40
+ FileUtils.should_receive(:rm_rf).with(subject.dotfile, :verbose => false)
41
+ FileUtils.should_receive(:ln_sf).with(subject.dotify, subject.dotfile, :verbose => false)
43
42
  subject.link
44
43
  end
45
44
  it "should simply remove the file from the home and relink it" do
46
45
  subject.stub(:in_dotify?) { false }
47
- FileUtils.should_receive(:cp_r).with(subject.home, subject.dotify, :verbose => false)
46
+ FileUtils.should_receive(:cp_r).with(subject.dotfile, subject.dotify, :verbose => false)
48
47
  FileUtils.stub(:rm_rf)
49
48
  FileUtils.stub(:ln_sf)
50
49
  subject.link
@@ -60,8 +59,8 @@ module Dotify
60
59
  end
61
60
  it "should call the right FileUtils methods" do
62
61
  subject.stub(:linked?) { true }
63
- FileUtils.should_receive(:rm_rf).with(subject.home, :verbose => false)
64
- FileUtils.should_receive(:cp_r).with(subject.dotify, subject.home, :verbose => false)
62
+ FileUtils.should_receive(:rm_rf).with(subject.dotfile, :verbose => false)
63
+ FileUtils.should_receive(:cp_r).with(subject.dotify, subject.dotfile, :verbose => false)
65
64
  FileUtils.should_receive(:rm_rf).with(subject.dotify, :verbose => false)
66
65
  subject.unlink
67
66
  end
@@ -75,14 +74,14 @@ module Dotify
75
74
  it { should respond_to :filename }
76
75
  it { should respond_to :dotify }
77
76
  it { should respond_to :dotfile }
78
- it { should respond_to :home }
77
+ it { should respond_to :dotfile }
79
78
  it { should respond_to :linked? }
80
79
  it { should respond_to :linked }
81
80
 
82
81
  it "should set the attributes properly" do
83
82
  unit.filename.should == '.vimrc'
84
83
  unit.dotify.should == '/tmp/home/.dotify/.vimrc'
85
- unit.home.should == '/tmp/home/.vimrc'
84
+ unit.dotfile.should == '/tmp/home/.vimrc'
86
85
  end
87
86
  it "should puts the filename" do
88
87
  unit.to_s.should == unit.filename
@@ -92,11 +91,11 @@ module Dotify
92
91
  describe "existence in directories" do
93
92
  let(:unit) { Unit.new(".bashrc") }
94
93
  it "should check for the existence in the home directory" do
95
- File.stub(:exists?).with(unit.home).and_return true
94
+ File.stub(:exists?).with(unit.dotfile).and_return true
96
95
  unit.in_home_dir?.should == true
97
96
  end
98
97
  it "should return false if the file is not in the home directory" do
99
- File.stub(:exists?).with(unit.home).and_return false
98
+ File.stub(:exists?).with(unit.dotfile).and_return false
100
99
  unit.in_home_dir?.should_not == true
101
100
  end
102
101
  it "should check for the existence of the file in Dotify" do
@@ -120,7 +119,7 @@ module Dotify
120
119
  unit.linked_to_dotify?.should be_true
121
120
  end
122
121
  it "should return false if the dotfile is not linked to the Dotify file" do
123
- File.stub(:readlink).with(unit.home).and_return '/tmp/home/.another_file'
122
+ File.stub(:readlink).with(unit.dotfile).and_return '/tmp/home/.another_file'
124
123
  unit.linked_to_dotify?.should be_false
125
124
  end
126
125
  end
@@ -143,11 +142,11 @@ module Dotify
143
142
  describe Unit, "#symlink" do
144
143
  let!(:unit) { Unit.new(".symlinked") }
145
144
  it "should return the symlink for the file" do
146
- File.should_receive(:readlink).with(unit.home).once
145
+ File.should_receive(:readlink).with(unit.dotfile).once
147
146
  unit.symlink
148
147
  end
149
148
  it "should return NoSymlink if error or no symlink" do
150
- File.stub(:readlink).with(unit.home).and_raise(StandardError)
149
+ File.stub(:readlink).with(unit.dotfile).and_raise(StandardError)
151
150
  expect { unit.symlink }.not_to raise_error
152
151
  unit.symlink.should == NoSymlink
153
152
  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.6.3
4
+ version: 0.6.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,167 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-07-13 00:00:00.000000000 Z
13
- dependencies: []
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.15.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.15.4
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: 1.3.6
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: 1.3.6
46
+ - !ruby/object:Gem::Dependency
47
+ name: git
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.2.5
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.5
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.11.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.11.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: simplecov
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: cucumber
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: webmock
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: vcr
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: guard-rspec
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: guard-cucumber
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
14
174
  description: A CLI Tool for managing your dotfiles
15
175
  email:
16
176
  - mbridges.91@gmail.com