dotify 0.6.2 → 0.6.3
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/.travis.yml +1 -0
- data/Gemfile +14 -2
- data/Guardfile +7 -1
- data/dotify.gemspec +0 -8
- data/features/linking_files.feature +13 -0
- data/features/setting_up_dotify.feature +10 -0
- data/features/step_definitions/linking_files.rb +25 -0
- data/features/step_definitions/setting_up_dotify.rb +12 -0
- data/features/support/env.rb +17 -0
- data/lib/dotify.rb +5 -1
- data/lib/dotify/cli.rb +12 -9
- data/lib/dotify/collection.rb +4 -6
- data/lib/dotify/config.rb +52 -53
- data/lib/dotify/{list.rb → filter.rb} +1 -1
- data/lib/dotify/unit.rb +4 -6
- data/lib/dotify/version.rb +1 -1
- data/spec/dotify/cli_spec.rb +22 -18
- data/spec/dotify/collection_spec.rb +14 -4
- data/spec/dotify/config_spec.rb +37 -5
- data/spec/dotify/{list_spec.rb → filter_spec.rb} +18 -18
- data/spec/dotify/unit_spec.rb +10 -0
- data/spec/dotify/version_checker_spec.rb +6 -8
- data/spec/dotify_spec.rb +18 -0
- data/spec/spec_helper.rb +8 -7
- metadata +18 -121
- data/spec/support/with_constants.rb +0 -49
- data/templates/.gitkeep +0 -0
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
|
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
|
data/Guardfile
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
|
-
guard 'rspec', :version => 2 do
|
4
|
+
guard 'rspec', :all_on_start => false, :all_after_pass => false, :notification => false, :version => 2 do
|
5
5
|
watch(%r{^spec/.+_spec\.rb$})
|
6
6
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
7
7
|
watch('spec/spec_helper.rb') { "spec" }
|
8
8
|
end
|
9
9
|
|
10
|
+
|
11
|
+
guard 'cucumber', :cli => '--no-profile --color', :notification => false, :all_on_pass => false, :all_on_start => false do
|
12
|
+
watch(%r{^features/.+\.feature$})
|
13
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
14
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
15
|
+
end
|
data/dotify.gemspec
CHANGED
@@ -14,12 +14,4 @@ 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_dependency "thor"
|
19
|
-
gem.add_dependency "multi_json"
|
20
|
-
gem.add_dependency "git"
|
21
|
-
gem.add_development_dependency "guard-rspec"
|
22
|
-
gem.add_development_dependency "rspec"
|
23
|
-
gem.add_development_dependency "webmock"
|
24
|
-
gem.add_development_dependency "vcr"
|
25
17
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: linking files to Dotify
|
2
|
+
|
3
|
+
In order to manage dotfiles
|
4
|
+
we need to be able to link files
|
5
|
+
from the home directory -> ~/.dotify.
|
6
|
+
|
7
|
+
Scenario: Linking a file
|
8
|
+
Given I have setup Dotify
|
9
|
+
And the following files are in home:
|
10
|
+
| .bash_profile |
|
11
|
+
| .gemrc |
|
12
|
+
When they get linked by Dotify
|
13
|
+
Then they are all linked to the dotify path
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Given /^the following files are in home:$/i do |table|
|
2
|
+
@files_to_link = table.raw.flatten
|
3
|
+
@files_to_link.each { |file| `touch #{Dotify::Config.home(file)}` }
|
4
|
+
end
|
5
|
+
|
6
|
+
Given /^(.*) does not exist in (home|dotify)$/i do |file, location|
|
7
|
+
location = location == 'home' ? :home : :path
|
8
|
+
puts `rm -rf #{Dotify::Config.send(location, file)}`
|
9
|
+
end
|
10
|
+
|
11
|
+
When /^they get linked by Dotify$/ do
|
12
|
+
@files_to_link.each { |file| Dotify::Unit.new(file).link }
|
13
|
+
end
|
14
|
+
|
15
|
+
Then /^they are all linked to the dotify path$/i do
|
16
|
+
@files_to_link.each do |file|
|
17
|
+
File.exists?(Dotify::Config.path(file)).should == true
|
18
|
+
File.readlink(Dotify::Config.home(file)).should == Dotify::Config.path(file)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Then /^\.(\S*) should exist in (home|dotify)$/ do |file, location|
|
23
|
+
where = location == "home" ? :home : :path
|
24
|
+
File.exists?(Dotify::Config.send(where, "." + file)).should == true
|
25
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Given /^Dotify is not setup$/ do
|
2
|
+
system "rm -rf #{File.join(ENV["HOME"], ".dotify")}"
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^I have setup Dotify$/i do
|
6
|
+
system "mkdir -p #{Dotify::Config.path}"
|
7
|
+
system "touch #{Dotify::Config.home(".dotrc")}"
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^I try to setup Dotify$/ do
|
11
|
+
Dotify::CLI.new.setup
|
12
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'thor/util'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
6
|
+
require 'dotify'
|
7
|
+
|
8
|
+
Before do
|
9
|
+
@__orig_home = ENV["HOME"]
|
10
|
+
ENV["HOME"] = "/tmp"
|
11
|
+
`rm -rf #{File.join(ENV["HOME"], '.bash_profile')}`
|
12
|
+
`rm -rf #{File.join(ENV["HOME"], '.gemrc')}`
|
13
|
+
end
|
14
|
+
|
15
|
+
After do
|
16
|
+
ENV["HOME"] = @__orig_home
|
17
|
+
end
|
data/lib/dotify.rb
CHANGED
@@ -7,7 +7,7 @@ module Dotify
|
|
7
7
|
|
8
8
|
autoload :Config, 'dotify/config'
|
9
9
|
autoload :Collection, 'dotify/collection'
|
10
|
-
autoload :
|
10
|
+
autoload :Filter, 'dotify/filter'
|
11
11
|
autoload :Unit, 'dotify/unit'
|
12
12
|
autoload :CLI, 'dotify/cli'
|
13
13
|
|
@@ -18,4 +18,8 @@ module Dotify
|
|
18
18
|
def self.version
|
19
19
|
VERSION
|
20
20
|
end
|
21
|
+
|
22
|
+
def self.collection
|
23
|
+
@collection ||= Collection.new
|
24
|
+
end
|
21
25
|
end
|
data/lib/dotify/cli.rb
CHANGED
@@ -7,8 +7,6 @@ require 'net/http'
|
|
7
7
|
require 'dotify'
|
8
8
|
require 'dotify/version_checker'
|
9
9
|
|
10
|
-
Dotify::Config.load_config!
|
11
|
-
|
12
10
|
module Dotify
|
13
11
|
|
14
12
|
class Git
|
@@ -70,6 +68,15 @@ module Dotify
|
|
70
68
|
end
|
71
69
|
end
|
72
70
|
|
71
|
+
desc :list, "List the installed dotfiles"
|
72
|
+
def list
|
73
|
+
say "Dotify is managing #{Dotify.collection.linked.count} files:\n", :blue
|
74
|
+
Dotify.collection.linked.each do |unit|
|
75
|
+
say " * #{unit.filename}", :yellow
|
76
|
+
end
|
77
|
+
$stdout.write "\n"
|
78
|
+
end
|
79
|
+
|
73
80
|
desc 'edit [FILE]', "Edit a dotify file"
|
74
81
|
method_option :save, :aliases => '-s', :default => false, :type => :boolean, :require => true, :desc => "Save Dotify files and push to Github"
|
75
82
|
def edit(file)
|
@@ -148,9 +155,9 @@ module Dotify
|
|
148
155
|
# Link a single file
|
149
156
|
return link_file Unit.new(file), options unless file.nil?
|
150
157
|
# Relink the files
|
151
|
-
return collection.linked.each { |file| link_file(file, options) } if options[:relink]
|
158
|
+
return Dotify.collection.linked.each { |file| link_file(file, options) } if options[:relink]
|
152
159
|
# Link the files
|
153
|
-
collection.unlinked.each { |file| link_file(file, options) }
|
160
|
+
Dotify.collection.unlinked.each { |file| link_file(file, options) }
|
154
161
|
end
|
155
162
|
|
156
163
|
desc 'unlink [[FILENAME]]', "Unlink one or all of your dotfiles (FILENAME is optional)"
|
@@ -166,15 +173,11 @@ module Dotify
|
|
166
173
|
# Unlink a single file
|
167
174
|
return unlink_file Unit.new(file), options unless file.nil?
|
168
175
|
# Unlink the files
|
169
|
-
collection.linked.each { |file| unlink_file(file, options) }
|
176
|
+
Dotify.collection.linked.each { |file| unlink_file(file, options) }
|
170
177
|
end
|
171
178
|
|
172
179
|
no_tasks do
|
173
180
|
|
174
|
-
def collection
|
175
|
-
@collection ||= Collection.new
|
176
|
-
end
|
177
|
-
|
178
181
|
def not_setup_warning
|
179
182
|
say "Dotify has not been setup yet! You need to run 'dotify setup' first.", :yellow
|
180
183
|
end
|
data/lib/dotify/collection.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
Dotify::Config.load_config!
|
2
|
-
|
3
1
|
module Dotify
|
4
2
|
class Collection
|
5
3
|
|
@@ -10,12 +8,12 @@ module Dotify
|
|
10
8
|
# Pulls an array of Units from the home
|
11
9
|
# directory.
|
12
10
|
def initialize
|
13
|
-
@units ||=
|
11
|
+
@units ||= Filter.home
|
14
12
|
end
|
15
13
|
|
16
14
|
# Defined each method for Enumerable
|
17
15
|
def each(&block)
|
18
|
-
|
16
|
+
units.each(&block)
|
19
17
|
end
|
20
18
|
|
21
19
|
# Linked files are those files which have a
|
@@ -32,11 +30,11 @@ module Dotify
|
|
32
30
|
end
|
33
31
|
|
34
32
|
def to_s
|
35
|
-
|
33
|
+
units.to_s
|
36
34
|
end
|
37
35
|
|
38
36
|
def inspect
|
39
|
-
|
37
|
+
units.map(&:inspect)
|
40
38
|
end
|
41
39
|
|
42
40
|
end
|
data/lib/dotify/config.rb
CHANGED
@@ -3,71 +3,70 @@ require 'thor/util'
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
module Dotify
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
:
|
13
|
-
:
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
module Config
|
7
|
+
|
8
|
+
extend self
|
9
|
+
|
10
|
+
DEFAULTS = {
|
11
|
+
:dirname => '.dotify',
|
12
|
+
:file => '.dotrc',
|
13
|
+
:editor => 'vim',
|
14
|
+
:ignore => {
|
15
|
+
:dotify => %w[.DS_Store .git .gitmodule],
|
16
|
+
:dotfiles => %w[.DS_Store .Trash .dropbox .dotify]
|
17
|
+
}
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
def dirname
|
21
|
+
@dirname ||= DEFAULTS[:dirname]
|
22
|
+
end
|
17
23
|
|
18
|
-
|
19
|
-
|
20
|
-
|
24
|
+
def home(file_or_path = nil)
|
25
|
+
file_or_path.nil? ? user_home : File.join(user_home, file_or_path)
|
26
|
+
end
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
28
|
+
def path(file_or_path = nil)
|
29
|
+
joins = [self.home, dirname]
|
30
|
+
joins << file_or_path unless file_or_path.nil?
|
31
|
+
File.join *joins
|
32
|
+
end
|
25
33
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
File.join *joins
|
30
|
-
end
|
34
|
+
def installed?
|
35
|
+
File.exists?(path) && File.directory?(path)
|
36
|
+
end
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
def editor
|
39
|
+
retrieve.fetch(:editor, DEFAULTS[:editor])
|
40
|
+
end
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
|
42
|
+
def ignore(what)
|
43
|
+
(retrieve.fetch(:ignore, {}).fetch(what, []) + DEFAULTS[:ignore].fetch(what, [])).uniq
|
44
|
+
end
|
39
45
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
46
|
+
def retrieve
|
47
|
+
@hash ||= File.exists?(file) ? YAML.load_file(file) : {}
|
48
|
+
symbolize_keys! @hash
|
49
|
+
rescue TypeError
|
50
|
+
{}
|
51
|
+
end
|
44
52
|
|
45
|
-
|
46
|
-
|
47
|
-
|
53
|
+
def file
|
54
|
+
File.join(home, DEFAULTS[:file])
|
55
|
+
end
|
48
56
|
|
49
|
-
|
50
|
-
@config || load_config!
|
51
|
-
end
|
57
|
+
private
|
52
58
|
|
53
|
-
def
|
54
|
-
|
59
|
+
def user_home
|
60
|
+
Thor::Util.user_home
|
55
61
|
end
|
56
62
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
def symbolize_keys!(opts)
|
64
|
-
sym_opts = {}
|
65
|
-
opts.each do |key, value|
|
66
|
-
sym_opts[key.to_sym] = value.is_a?(Hash) ? symbolize_keys!(value) : value
|
67
|
-
end
|
68
|
-
sym_opts
|
63
|
+
def symbolize_keys!(opts)
|
64
|
+
sym_opts = {}
|
65
|
+
opts.each do |key, value|
|
66
|
+
sym_opts[key.to_sym] = value.is_a?(Hash) ? symbolize_keys!(value) : value
|
69
67
|
end
|
68
|
+
sym_opts
|
69
|
+
end
|
70
70
|
|
71
|
-
end
|
72
71
|
end
|
73
72
|
end
|
data/lib/dotify/unit.rb
CHANGED
@@ -65,7 +65,7 @@ module Dotify
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def inspect
|
68
|
-
"#<Dotify::Unit
|
68
|
+
"#<Dotify::Unit filename: '#{@filename}' linked: #{linked?}>"
|
69
69
|
end
|
70
70
|
|
71
71
|
def linked_to_dotify?
|
@@ -73,11 +73,9 @@ module Dotify
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def symlink
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
NoSymlink
|
80
|
-
end
|
76
|
+
File.readlink dotfile
|
77
|
+
rescue
|
78
|
+
NoSymlink
|
81
79
|
end
|
82
80
|
|
83
81
|
end
|
data/lib/dotify/version.rb
CHANGED
data/spec/dotify/cli_spec.rb
CHANGED
@@ -7,13 +7,23 @@ module Dotify
|
|
7
7
|
let!(:cli) { CLI.new }
|
8
8
|
before do
|
9
9
|
Dotify.stub(:installed?).and_return true
|
10
|
-
|
11
|
-
|
10
|
+
vimrc = Unit.new('.zshrc')
|
11
|
+
vimrc.stub(:linked?).and_return(true)
|
12
|
+
bash_profile = Unit.new('.bash_profile')
|
13
|
+
bash_profile.stub(:linked?).and_return(true)
|
14
|
+
gitconfig = Unit.new('.gitconfig')
|
15
|
+
gitconfig.stub(:linked?).and_return(false)
|
16
|
+
zshrc = Unit.new('.zshrc')
|
17
|
+
zshrc.stub(:linked?).and_return(false)
|
18
|
+
Filter.stub(:home).and_return([vimrc, bash_profile, gitconfig, zshrc])
|
12
19
|
end
|
13
20
|
|
14
21
|
describe CLI, "#edit" do
|
15
22
|
let(:unit) { double('unit', :linked? => true, :dotify => '/tmp/dotify/.vimrc') }
|
16
|
-
before
|
23
|
+
before do
|
24
|
+
Unit.stub(:new).and_return(unit)
|
25
|
+
cli.stub(:exec)
|
26
|
+
end
|
17
27
|
it "should open the editor with the passed file" do
|
18
28
|
cli.should_receive(:exec).with([Config.editor, unit.dotify].join(" "))
|
19
29
|
cli.edit('.vimrc')
|
@@ -32,22 +42,19 @@ module Dotify
|
|
32
42
|
|
33
43
|
describe CLI, "#link" do
|
34
44
|
before do
|
35
|
-
cli.stub(:collection).and_return(
|
36
|
-
double('collection', {
|
37
|
-
:unlinked => [double('.zshrc', :in_home_dir? => true, :linked? => false), double('.gitconfig', :in_home_dir? => true, :linked? => false)],
|
38
|
-
:linked => [double('.vimrc', :in_home_dir? => true, :linked? => true)]
|
39
|
-
})
|
40
|
-
)
|
41
45
|
cli.stub(:link_file)
|
42
46
|
end
|
43
47
|
it "should loop through all unlinked files" do
|
44
|
-
|
45
|
-
cli.
|
48
|
+
Dotify.collection.should_receive(:unlinked).and_return Dotify.collection.reject(&:linked?)
|
49
|
+
cli.link
|
50
|
+
end
|
51
|
+
it "should call link_file on the right files" do
|
52
|
+
cli.should_receive(:link_file).exactly(Dotify.collection.unlinked.size).times
|
46
53
|
cli.link
|
47
54
|
end
|
48
55
|
it "should relink all of the files located in Dotify" do
|
49
|
-
|
50
|
-
|
56
|
+
Dotify.collection.should_not_receive(:unlinked)
|
57
|
+
Dotify.collection.should_receive(:linked).and_return []
|
51
58
|
cli.stub(:options).and_return({ :relink => true })
|
52
59
|
cli.link
|
53
60
|
end
|
@@ -64,17 +71,14 @@ module Dotify
|
|
64
71
|
|
65
72
|
describe CLI, "#unlink" do
|
66
73
|
before do
|
67
|
-
cli.stub(:collection).and_return double(:linked => [double('.vimrc', :linked? => true), double('.bashrc', :linked? => true)])
|
68
74
|
cli.stub(:unlink_file)
|
69
75
|
end
|
70
76
|
it "should loop through all unlinked files" do
|
71
|
-
|
77
|
+
Dotify.collection.should_receive(:linked).and_return Dotify.collection.select(&:linked?)
|
72
78
|
cli.unlink
|
73
79
|
end
|
74
80
|
it "should call CLI#unlink_file the right number of times" do
|
75
|
-
cli.
|
76
|
-
cli.stub(:unlink_file)
|
77
|
-
cli.should_receive(:unlink_file).exactly(cli.collection.linked.size).times
|
81
|
+
cli.should_receive(:unlink_file).exactly(Dotify.collection.linked.size).times
|
78
82
|
cli.unlink
|
79
83
|
end
|
80
84
|
it "attempt to link one single file" do
|
@@ -19,15 +19,15 @@ module Dotify
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
it "should pull the right files from
|
22
|
+
it "should pull the right files from Filter.home" do
|
23
23
|
files = [stub, stub, stub]
|
24
|
-
|
24
|
+
Filter.stub(:home).and_return files
|
25
25
|
collection.units.should == files
|
26
26
|
end
|
27
27
|
|
28
28
|
describe Collection, "#linked" do
|
29
29
|
before do
|
30
|
-
|
30
|
+
collection.stub(:units).and_return home_files
|
31
31
|
end
|
32
32
|
let(:linked) { collection.linked }
|
33
33
|
it "should return the right Units" do
|
@@ -42,7 +42,7 @@ module Dotify
|
|
42
42
|
|
43
43
|
describe Collection, "#unlinked" do
|
44
44
|
before do
|
45
|
-
|
45
|
+
collection.stub(:units).and_return home_files
|
46
46
|
end
|
47
47
|
let(:unlinked) { collection.unlinked }
|
48
48
|
it "should return the right Units" do
|
@@ -55,5 +55,15 @@ module Dotify
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
it "should call #to_s on the units" do
|
59
|
+
collection.units.should_receive(:to_s)
|
60
|
+
collection.to_s
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should call #inspect on the units" do
|
64
|
+
collection.units.each { |u| u.should_receive(:inspect) }
|
65
|
+
collection.inspect
|
66
|
+
end
|
67
|
+
|
58
68
|
end
|
59
69
|
end
|
data/spec/dotify/config_spec.rb
CHANGED
@@ -2,6 +2,38 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Dotify
|
4
4
|
describe Config do
|
5
|
+
|
6
|
+
describe Config, "#load_config!" do
|
7
|
+
it "should not raise a TypeError if the .dotrc file is empty (this is a problem with Psych not liking loading empty files)" do
|
8
|
+
system "mkdir -p #{Config.home}"
|
9
|
+
system "touch #{Config.home(".fake-dotrc")}"
|
10
|
+
Config.stub(:file).and_return Config.home(".fake-dotrc")
|
11
|
+
expect { Config.retrieve }.not_to raise_error TypeError
|
12
|
+
end
|
13
|
+
context "unit tests" do
|
14
|
+
before do
|
15
|
+
Config.instance_variable_set("@hash", nil)
|
16
|
+
File.stub(:exists?).with(Config.file).and_return true
|
17
|
+
end
|
18
|
+
it "should return an empty hash" do
|
19
|
+
YAML.stub(:load_file).with(Config.file).and_return({})
|
20
|
+
Config.retrieve.should == {}
|
21
|
+
end
|
22
|
+
it "should return an the hash returned by YAML#load_file" do
|
23
|
+
YAML.stub(:load_file).and_return({ :test => 'example' })
|
24
|
+
Config.retrieve.should == { :test => 'example' }
|
25
|
+
end
|
26
|
+
it "should symbolize the keys returned" do
|
27
|
+
YAML.stub(:load_file).and_return({ 'test' => 'example' })
|
28
|
+
Config.retrieve.should == { :test => 'example' }
|
29
|
+
end
|
30
|
+
it "should only try to set config from the config file once" do
|
31
|
+
YAML.should_receive(:load_file).with(Config.file).once.and_return({ 'test' => 'example' })
|
32
|
+
5.times { Config.retrieve }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
5
37
|
describe Config, "#installed?" do
|
6
38
|
it "should return true if Dotify has been setup" do
|
7
39
|
File.should_receive(:exists?).with(Config.path).and_return(true)
|
@@ -34,15 +66,15 @@ module Dotify
|
|
34
66
|
|
35
67
|
describe "options" do
|
36
68
|
before do
|
37
|
-
Config.stub(:
|
69
|
+
Config.stub(:retrieve) do
|
38
70
|
{ :ignore => { :dotfiles => %w[.gemrc], :dotify => %w[.gitmodule] } }
|
39
71
|
end
|
40
72
|
end
|
41
73
|
it "should set a default editor" do
|
42
|
-
Config.editor.should == Config::
|
74
|
+
Config.editor.should == Config::DEFAULTS[:editor]
|
43
75
|
end
|
44
76
|
it "should allow a custom editor" do
|
45
|
-
Config.stub(:
|
77
|
+
Config.stub(:retrieve) do
|
46
78
|
{ :editor => 'subl' }
|
47
79
|
end
|
48
80
|
Config.editor.should == 'subl'
|
@@ -57,12 +89,12 @@ module Dotify
|
|
57
89
|
|
58
90
|
describe "ignore files" do
|
59
91
|
before do
|
60
|
-
Config.stub(:
|
92
|
+
Config.stub(:retrieve) do
|
61
93
|
{ :ignore => { :dotfiles => %w[.gemrc], :dotify => %w[.gitmodule] } }
|
62
94
|
end
|
63
95
|
end
|
64
96
|
it "should have a default set of dotfiles" do
|
65
|
-
Config.stub(:
|
97
|
+
Config.stub(:retrieve).and_return({})
|
66
98
|
Config.ignore(:dotify).should include '.git'
|
67
99
|
Config.ignore(:dotify).should include '.gitmodule'
|
68
100
|
Config.ignore(:dotfiles).should include '.dropbox'
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Dotify
|
4
|
-
describe
|
4
|
+
describe Filter do
|
5
5
|
|
6
|
-
describe
|
7
|
-
it "should call
|
8
|
-
|
9
|
-
|
6
|
+
describe Filter, "#home" do
|
7
|
+
it "should call Filter#units with the correct path" do
|
8
|
+
Filter.should_receive(:units).with("/tmp/home/.*").once.and_return([])
|
9
|
+
Filter.home
|
10
10
|
end
|
11
11
|
it "should drop files that have been specified to be ignored" do
|
12
|
-
|
12
|
+
Filter.stub(:units) do
|
13
13
|
[
|
14
14
|
Unit.new('.zshrc'),
|
15
15
|
Unit.new('.bashrc'),
|
@@ -18,7 +18,7 @@ module Dotify
|
|
18
18
|
]
|
19
19
|
end
|
20
20
|
Config.stub(:ignore).with(:dotfiles).and_return %w[.zshrc .vimrc]
|
21
|
-
result =
|
21
|
+
result = Filter.home.map(&:filename)
|
22
22
|
result.should include '.bashrc'
|
23
23
|
result.should include '.gitconfig'
|
24
24
|
result.should_not include '.zshrc'
|
@@ -26,13 +26,13 @@ module Dotify
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
30
|
-
it "should call
|
31
|
-
|
32
|
-
|
29
|
+
describe Filter, "#dotify" do
|
30
|
+
it "should call Filter#units with the correct path" do
|
31
|
+
Filter.should_receive(:units).with("/tmp/home/.dotify/.*").once.and_return([])
|
32
|
+
Filter.dotify
|
33
33
|
end
|
34
34
|
it "should drop files that have been specified to be ignored" do
|
35
|
-
|
35
|
+
Filter.stub(:units) do
|
36
36
|
[
|
37
37
|
Unit.new(".gitconfig"),
|
38
38
|
Unit.new('.vimrc'),
|
@@ -42,7 +42,7 @@ module Dotify
|
|
42
42
|
]
|
43
43
|
end
|
44
44
|
Config.stub(:ignore).with(:dotify).and_return %w[.gitconfig .bashrc]
|
45
|
-
result =
|
45
|
+
result = Filter.filenames(Filter.dotify)
|
46
46
|
result.should include '.vimrc'
|
47
47
|
result.should include '.zshrc'
|
48
48
|
result.should include '.fakefile'
|
@@ -51,17 +51,17 @@ module Dotify
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe
|
54
|
+
describe Filter, "#units" do
|
55
55
|
let(:glob) { '/spec/test/.*' }
|
56
56
|
it "should pull the glob of dotfiles from a directory" do
|
57
57
|
Dir.should_receive(:[]).with(glob).and_return(%w[. .. /spec/test/.vimrc /spec/test/.bashrc /spec/test/.zshrc])
|
58
|
-
|
58
|
+
Filter.units(glob)
|
59
59
|
end
|
60
60
|
describe "return values" do
|
61
61
|
before do
|
62
62
|
Dir.stub(:[]).with(glob).and_return(%w[. .. /spec/test/.vimrc /spec/test/.bashrc /spec/test/.zshrc])
|
63
63
|
end
|
64
|
-
let(:files) {
|
64
|
+
let(:files) { Filter.units(glob) }
|
65
65
|
it "should return the right directories" do
|
66
66
|
f = files.map(&:filename)
|
67
67
|
f.should include '.vimrc'
|
@@ -76,12 +76,12 @@ module Dotify
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
describe
|
79
|
+
describe Filter, "#filenames" do
|
80
80
|
let(:files) { [
|
81
81
|
Unit.new('.vimrc'), Unit.new('.bashrc'), Unit.new('.zshrc')
|
82
82
|
] }
|
83
83
|
it "return only the filenames of the units" do
|
84
|
-
result =
|
84
|
+
result = Filter.filenames(files)
|
85
85
|
result.should include '.vimrc'
|
86
86
|
result.should include '.bashrc'
|
87
87
|
result.should include '.zshrc'
|
data/spec/dotify/unit_spec.rb
CHANGED
@@ -153,5 +153,15 @@ module Dotify
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
+
describe "inspecting unit" do
|
157
|
+
it "should display properly" do
|
158
|
+
Unit.new(".zshrc").inspect.should == "#<Dotify::Unit filename: '.zshrc' linked: false>"
|
159
|
+
bash = Unit.new(".bashrc")
|
160
|
+
bash.stub(:linked?).and_return true
|
161
|
+
bash.inspect.should == "#<Dotify::Unit filename: '.bashrc' linked: true>"
|
162
|
+
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
156
166
|
end
|
157
167
|
end
|
@@ -18,16 +18,14 @@ module Dotify
|
|
18
18
|
end
|
19
19
|
describe VersionChecker, "#current?" do
|
20
20
|
it "should be false if version is not current" do
|
21
|
-
|
21
|
+
stub_const "Dotify::VERSION", '0.2.0'
|
22
22
|
VersionChecker.stub(:version).and_return('0.1.9')
|
23
|
-
|
24
|
-
|
25
|
-
end
|
23
|
+
VersionChecker.current?.should == false
|
24
|
+
end
|
26
25
|
it "should be true if version is current" do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
26
|
+
stub_const "Dotify::VERSION", '0.2.0'
|
27
|
+
VersionChecker.stub(:version).and_return('0.2.0')
|
28
|
+
VersionChecker.current?.should == true
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|
data/spec/dotify_spec.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dotify do
|
4
|
+
it "#installed? should be a shortcut method to Config#installed?" do
|
5
|
+
Dotify::Config.stub(:installed?).and_return true
|
6
|
+
Dotify.installed?.should == true
|
7
|
+
Dotify::Config.stub(:installed?).and_return false
|
8
|
+
Dotify.installed?.should == false
|
9
|
+
end
|
10
|
+
|
11
|
+
it "version is a shortcut method to Dotify::VERSION" do
|
12
|
+
Dotify.version.should == Dotify::VERSION
|
13
|
+
end
|
14
|
+
|
15
|
+
it "version is a shortcut method to Dotify::VERSION" do
|
16
|
+
Dotify.collection.should be_instance_of Dotify::Collection
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,8 +5,11 @@
|
|
5
5
|
#
|
6
6
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
7
|
$:.unshift File.expand_path("../../lib", __FILE__)
|
8
|
-
require '
|
9
|
-
|
8
|
+
require 'thor/util'
|
9
|
+
require 'simplecov'
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter '/spec/support'
|
12
|
+
end
|
10
13
|
|
11
14
|
RSpec.configure do |config|
|
12
15
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
@@ -14,11 +17,9 @@ RSpec.configure do |config|
|
|
14
17
|
config.filter_run :focus
|
15
18
|
|
16
19
|
config.before(:each) do
|
17
|
-
class Thor
|
18
|
-
module Util
|
19
|
-
end
|
20
|
-
end
|
21
20
|
Thor::Util.stub(:user_home) { '/tmp/home' }
|
22
|
-
#Dotify::Config.stub(:home) { '/tmp/home' }
|
23
21
|
end
|
24
22
|
end
|
23
|
+
|
24
|
+
require 'dotify'
|
25
|
+
Dir["./spec/support/**/*.rb"].each { |f| require f }
|
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.
|
4
|
+
version: 0.6.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,120 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
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'
|
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'
|
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'
|
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: '0'
|
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: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: guard-rspec
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '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: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: rspec
|
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: webmock
|
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: vcr
|
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'
|
12
|
+
date: 2012-07-13 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
126
14
|
description: A CLI Tool for managing your dotfiles
|
127
15
|
email:
|
128
16
|
- mbridges.91@gmail.com
|
@@ -141,28 +29,32 @@ files:
|
|
141
29
|
- Rakefile
|
142
30
|
- bin/dotify
|
143
31
|
- dotify.gemspec
|
32
|
+
- features/linking_files.feature
|
33
|
+
- features/setting_up_dotify.feature
|
34
|
+
- features/step_definitions/linking_files.rb
|
35
|
+
- features/step_definitions/setting_up_dotify.rb
|
36
|
+
- features/support/env.rb
|
144
37
|
- lib/dotify.rb
|
145
38
|
- lib/dotify/cli.rb
|
146
39
|
- lib/dotify/collection.rb
|
147
40
|
- lib/dotify/config.rb
|
148
41
|
- lib/dotify/errors.rb
|
149
|
-
- lib/dotify/
|
42
|
+
- lib/dotify/filter.rb
|
150
43
|
- lib/dotify/unit.rb
|
151
44
|
- lib/dotify/version.rb
|
152
45
|
- lib/dotify/version_checker.rb
|
153
46
|
- spec/dotify/cli_spec.rb
|
154
47
|
- spec/dotify/collection_spec.rb
|
155
48
|
- spec/dotify/config_spec.rb
|
156
|
-
- spec/dotify/
|
49
|
+
- spec/dotify/filter_spec.rb
|
157
50
|
- spec/dotify/unit_spec.rb
|
158
51
|
- spec/dotify/version_checker_spec.rb
|
52
|
+
- spec/dotify_spec.rb
|
159
53
|
- spec/fixtures/.dotrc-default
|
160
54
|
- spec/fixtures/vcr/version_check.yml
|
161
55
|
- spec/spec_helper.rb
|
162
56
|
- spec/support/vcr.rb
|
163
|
-
- spec/support/with_constants.rb
|
164
57
|
- templates/.dotrc
|
165
|
-
- templates/.gitkeep
|
166
58
|
homepage: https://github.com/mattdbridges/dotify
|
167
59
|
licenses: []
|
168
60
|
post_install_message:
|
@@ -188,14 +80,19 @@ signing_key:
|
|
188
80
|
specification_version: 3
|
189
81
|
summary: A CLI Tool for managing your dotfiles
|
190
82
|
test_files:
|
83
|
+
- features/linking_files.feature
|
84
|
+
- features/setting_up_dotify.feature
|
85
|
+
- features/step_definitions/linking_files.rb
|
86
|
+
- features/step_definitions/setting_up_dotify.rb
|
87
|
+
- features/support/env.rb
|
191
88
|
- spec/dotify/cli_spec.rb
|
192
89
|
- spec/dotify/collection_spec.rb
|
193
90
|
- spec/dotify/config_spec.rb
|
194
|
-
- spec/dotify/
|
91
|
+
- spec/dotify/filter_spec.rb
|
195
92
|
- spec/dotify/unit_spec.rb
|
196
93
|
- spec/dotify/version_checker_spec.rb
|
94
|
+
- spec/dotify_spec.rb
|
197
95
|
- spec/fixtures/.dotrc-default
|
198
96
|
- spec/fixtures/vcr/version_check.yml
|
199
97
|
- spec/spec_helper.rb
|
200
98
|
- spec/support/vcr.rb
|
201
|
-
- spec/support/with_constants.rb
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Kernel
|
2
|
-
def silence_warnings
|
3
|
-
with_warnings(nil) { yield }
|
4
|
-
end
|
5
|
-
|
6
|
-
def with_warnings(flag)
|
7
|
-
old_verbose, $VERBOSE = $VERBOSE, flag
|
8
|
-
yield
|
9
|
-
ensure
|
10
|
-
$VERBOSE = old_verbose
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def constantize(camel_cased_word)
|
15
|
-
names = camel_cased_word.split('::')
|
16
|
-
names.shift if names.empty? || names.first.empty?
|
17
|
-
|
18
|
-
constant = Object
|
19
|
-
names.each do |name|
|
20
|
-
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
21
|
-
end
|
22
|
-
constant
|
23
|
-
end
|
24
|
-
|
25
|
-
def parse(constant)
|
26
|
-
source, _, constant_name = constant.to_s.rpartition('::')
|
27
|
-
|
28
|
-
[constantize(source), constant_name]
|
29
|
-
end
|
30
|
-
|
31
|
-
def with_constants(constants, &block)
|
32
|
-
saved_constants = {}
|
33
|
-
constants.each do |constant, val|
|
34
|
-
source_object, const_name = parse(constant)
|
35
|
-
|
36
|
-
saved_constants[constant] = source_object.const_get(const_name)
|
37
|
-
Kernel::silence_warnings { source_object.const_set(const_name, val) }
|
38
|
-
end
|
39
|
-
|
40
|
-
begin
|
41
|
-
block.call
|
42
|
-
ensure
|
43
|
-
constants.each do |constant, val|
|
44
|
-
source_object, const_name = parse(constant)
|
45
|
-
|
46
|
-
Kernel::silence_warnings { source_object.const_set(const_name, saved_constants[constant]) }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/templates/.gitkeep
DELETED
File without changes
|