homesick 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.markdown +6 -0
- data/README.markdown +4 -0
- data/Rakefile +1 -1
- data/homesick.gemspec +2 -2
- data/lib/homesick.rb +42 -5
- data/lib/homesick/actions.rb +11 -0
- data/spec/homesick_spec.rb +141 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b018e996f0ee25166f43663c5e761e53f12f0f72
|
4
|
+
data.tar.gz: 8664e007c7b5b45e3dc298b7b1c16b9142b42c1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fae9ca5dea450348afde9f237eb1c357f74144b35bf1bce5695f46a8336bad5758fb73dab39341fb845a54f1f0100c994e04a7cfd4991a54e9c2251cfae5961
|
7
|
+
data.tar.gz: 82c49cbe96f65516c73cec976b9ae04e42cc8da176167b20174b3bbf3111fd96b3886e2d0d6b45758f4b4c8b403dd5a72855e81511b4ed74e42df14bbc17d9fa
|
data/ChangeLog.markdown
CHANGED
data/README.markdown
CHANGED
@@ -31,6 +31,10 @@ If you use the shorthand syntax for GitHub repositories in your clone, please no
|
|
31
31
|
|
32
32
|
homesick symlink technicalpickles/pickled-vim
|
33
33
|
|
34
|
+
You can remove symlinks anytime when you don't need them anymore
|
35
|
+
|
36
|
+
homesick unlink pickled-vim
|
37
|
+
|
34
38
|
If you're not sure what castles you have around, you can easily list them:
|
35
39
|
|
36
40
|
homesick list
|
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem|
|
|
22
22
|
gem.email = ["josh@technicalpickles.com", "info@muratayusuke.com"]
|
23
23
|
gem.homepage = "http://github.com/technicalpickles/homesick"
|
24
24
|
gem.authors = ["Joshua Nichols", "Yusuke Murata"]
|
25
|
-
gem.version = "0.9.
|
25
|
+
gem.version = "0.9.4"
|
26
26
|
gem.license = "MIT"
|
27
27
|
# Have dependencies? Add them to Gemfile
|
28
28
|
|
data/homesick.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "homesick"
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joshua Nichols", "Yusuke Murata"]
|
12
|
-
s.date = "2013-07-
|
12
|
+
s.date = "2013-07-31"
|
13
13
|
s.description = "\n A man's home (directory) is his castle, so don't leave home with out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. \n\n "
|
14
14
|
s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"]
|
15
15
|
s.executables = ["homesick"]
|
data/lib/homesick.rb
CHANGED
@@ -34,7 +34,7 @@ class Homesick < Thor
|
|
34
34
|
ln_s uri, destination
|
35
35
|
elsif uri =~ GITHUB_NAME_REPO_PATTERN
|
36
36
|
destination = Pathname.new($1)
|
37
|
-
git_clone "
|
37
|
+
git_clone "https://github.com/#{$1}.git", :destination => destination
|
38
38
|
elsif uri =~ /%r([^%r]*?)(\.git)?\Z/
|
39
39
|
destination = Pathname.new($1)
|
40
40
|
git_clone uri
|
@@ -52,13 +52,21 @@ class Homesick < Thor
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
rc(destination)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'rc CASTLE', 'Run the .homesickrc for the specified castle'
|
60
|
+
def rc(name = DEFAULT_CASTLE_NAME)
|
61
|
+
inside repos_dir do
|
62
|
+
destination = Pathname.new(name)
|
55
63
|
homesickrc = destination.join('.homesickrc').expand_path
|
56
64
|
if homesickrc.exist?
|
57
|
-
proceed = shell.yes?("#{
|
65
|
+
proceed = shell.yes?("#{name} has a .homesickrc. Proceed with evaling it? (This could be destructive)")
|
58
66
|
if proceed
|
59
67
|
shell.say_status 'eval', homesickrc
|
60
68
|
inside destination do
|
61
|
-
eval homesickrc.read, binding, homesickrc.expand_path
|
69
|
+
eval homesickrc.read, binding, homesickrc.expand_path.to_s
|
62
70
|
end
|
63
71
|
else
|
64
72
|
shell.say_status 'eval skip', "not evaling #{homesickrc}, #{destination} may need manual configuration", :blue
|
@@ -90,7 +98,23 @@ class Homesick < Thor
|
|
90
98
|
desc 'push CASTLE', 'Push the specified castle'
|
91
99
|
def push(name = DEFAULT_CASTLE_NAME)
|
92
100
|
push_castle name
|
101
|
+
end
|
102
|
+
|
103
|
+
desc 'unlink CASTLE', 'Unsymlinks all dotfiles from the specified castle'
|
104
|
+
def unlink(name = DEFAULT_CASTLE_NAME)
|
105
|
+
check_castle_existance(name, 'symlink')
|
106
|
+
|
107
|
+
inside castle_dir(name) do
|
108
|
+
subdirs = subdirs(name)
|
109
|
+
|
110
|
+
# unlink files
|
111
|
+
unsymlink_each(name, castle_dir(name), subdirs)
|
93
112
|
|
113
|
+
# unlink files in subdirs
|
114
|
+
subdirs.each do |subdir|
|
115
|
+
unsymlink_each(name, subdir, subdirs)
|
116
|
+
end
|
117
|
+
end
|
94
118
|
end
|
95
119
|
|
96
120
|
desc 'symlink CASTLE', 'Symlinks all dotfiles from the specified castle'
|
@@ -331,7 +355,7 @@ class Homesick < Thor
|
|
331
355
|
first_p.mtime > second_p.mtime && !first_p.symlink?
|
332
356
|
end
|
333
357
|
|
334
|
-
def
|
358
|
+
def each_file(castle, basedir, subdirs)
|
335
359
|
absolute_basedir = Pathname.new(basedir).expand_path
|
336
360
|
inside basedir do
|
337
361
|
files = Pathname.glob('{.*,*}').reject{ |a| ['.', '..'].include?(a.to_s) }
|
@@ -360,8 +384,21 @@ class Homesick < Thor
|
|
360
384
|
|
361
385
|
relative_dir = absolute_basedir.relative_path_from(castle_home)
|
362
386
|
home_path = home_dir.join(relative_dir).join(path)
|
363
|
-
|
387
|
+
|
388
|
+
yield(absolute_path, home_path)
|
364
389
|
end
|
365
390
|
end
|
366
391
|
end
|
392
|
+
|
393
|
+
def unsymlink_each(castle, basedir, subdirs)
|
394
|
+
each_file(castle, basedir, subdirs) do |absolute_path, home_path|
|
395
|
+
rm_link home_path
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
def symlink_each(castle, basedir, subdirs)
|
400
|
+
each_file(castle, basedir, subdirs) do |absolute_path, home_path|
|
401
|
+
ln_s absolute_path, home_path
|
402
|
+
end
|
403
|
+
end
|
367
404
|
end
|
data/lib/homesick/actions.rb
CHANGED
@@ -97,6 +97,17 @@ class Homesick
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
+
def rm_link(target)
|
101
|
+
target = Pathname.new(target)
|
102
|
+
|
103
|
+
if target.symlink?
|
104
|
+
say_status :unlink, "#{target.expand_path}", :green unless options[:quiet]
|
105
|
+
FileUtils.rm_rf target
|
106
|
+
else
|
107
|
+
say_status :conflict, "#{target} is not a symlink", :red unless options[:quiet]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
100
111
|
def ln_s(source, destination, config = {})
|
101
112
|
source = Pathname.new(source)
|
102
113
|
destination = Pathname.new(destination)
|
data/spec/homesick_spec.rb
CHANGED
@@ -8,9 +8,25 @@ describe 'homesick' do
|
|
8
8
|
|
9
9
|
let(:homesick) { Homesick.new }
|
10
10
|
|
11
|
-
before { homesick.stub
|
11
|
+
before { homesick.stub(:repos_dir).and_return(castles) }
|
12
12
|
|
13
13
|
describe 'clone' do
|
14
|
+
context 'has a .homesickrc' do
|
15
|
+
it 'should run the .homesickrc' do
|
16
|
+
somewhere = create_construct
|
17
|
+
local_repo = somewhere.directory('some_repo')
|
18
|
+
local_repo.file('.homesickrc') do |file|
|
19
|
+
file << "File.open(Dir.pwd + '/testing', 'w') { |f| f.print 'testing' }"
|
20
|
+
end
|
21
|
+
|
22
|
+
expect($stdout).to receive(:print)
|
23
|
+
expect($stdin).to receive(:gets).and_return('y')
|
24
|
+
homesick.clone local_repo
|
25
|
+
|
26
|
+
castles.join('some_repo').join('testing').should exist
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
14
30
|
context 'of a file' do
|
15
31
|
it 'should symlink existing directories' do
|
16
32
|
somewhere = create_construct
|
@@ -78,12 +94,50 @@ describe 'homesick' do
|
|
78
94
|
end
|
79
95
|
|
80
96
|
it 'should clone a github repo' do
|
81
|
-
homesick.should_receive(:git_clone).with('
|
97
|
+
homesick.should_receive(:git_clone).with('https://github.com/wfarr/dotfiles.git', :destination => Pathname.new('wfarr/dotfiles'))
|
82
98
|
|
83
99
|
homesick.clone 'wfarr/dotfiles'
|
84
100
|
end
|
85
101
|
end
|
86
102
|
|
103
|
+
describe 'rc' do
|
104
|
+
let(:castle) { given_castle('glencairn') }
|
105
|
+
|
106
|
+
context 'when told to do so' do
|
107
|
+
before do
|
108
|
+
expect($stdout).to receive(:print)
|
109
|
+
expect($stdin).to receive(:gets).and_return('y')
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'executes the .homesickrc' do
|
113
|
+
castle.file('.homesickrc') do |file|
|
114
|
+
file << "File.open(Dir.pwd + '/testing', 'w') { |f| f.print 'testing' }"
|
115
|
+
end
|
116
|
+
|
117
|
+
homesick.rc castle
|
118
|
+
|
119
|
+
castle.join('testing').should exist
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'when told not to do so' do
|
124
|
+
before do
|
125
|
+
expect($stdout).to receive(:print)
|
126
|
+
expect($stdin).to receive(:gets).and_return('n')
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'does not execute the .homesickrc' do
|
130
|
+
castle.file('.homesickrc') do |file|
|
131
|
+
file << "File.open(Dir.pwd + '/testing', 'w') { |f| f.print 'testing' }"
|
132
|
+
end
|
133
|
+
|
134
|
+
homesick.rc castle
|
135
|
+
|
136
|
+
castle.join('testing').should_not exist
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
87
141
|
describe 'symlink' do
|
88
142
|
let(:castle) { given_castle('glencairn') }
|
89
143
|
|
@@ -188,6 +242,91 @@ describe 'homesick' do
|
|
188
242
|
end
|
189
243
|
end
|
190
244
|
|
245
|
+
describe 'unlink' do
|
246
|
+
let(:castle) { given_castle('glencairn') }
|
247
|
+
|
248
|
+
it 'unlinks dotfiles in the home folder' do
|
249
|
+
castle.file('.some_dotfile')
|
250
|
+
|
251
|
+
homesick.symlink('glencairn')
|
252
|
+
homesick.unlink('glencairn')
|
253
|
+
|
254
|
+
home.join('.some_dotfile').should_not exist
|
255
|
+
end
|
256
|
+
|
257
|
+
it 'unlinks non-dotfiles from the home folder' do
|
258
|
+
castle.file('bin')
|
259
|
+
|
260
|
+
homesick.symlink('glencairn')
|
261
|
+
homesick.unlink('glencairn')
|
262
|
+
|
263
|
+
home.join('bin').should_not exist
|
264
|
+
end
|
265
|
+
|
266
|
+
context "with '.config' in .homesick_subdir" do
|
267
|
+
let(:castle) { given_castle('glencairn', ['.config']) }
|
268
|
+
|
269
|
+
it 'can unlink sub directories' do
|
270
|
+
castle.directory('.config').file('.some_dotfile')
|
271
|
+
|
272
|
+
homesick.symlink('glencairn')
|
273
|
+
homesick.unlink('glencairn')
|
274
|
+
|
275
|
+
home_dotdir = home.join('.config')
|
276
|
+
home_dotdir.should exist
|
277
|
+
home_dotdir.join('.some_dotfile').should_not exist
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
context "with '.config/appA' in .homesick_subdir" do
|
282
|
+
let(:castle) { given_castle('glencairn', ['.config/appA']) }
|
283
|
+
|
284
|
+
it 'can unsymlink in nested sub directory' do
|
285
|
+
castle.directory('.config').directory('appA').file('.some_dotfile')
|
286
|
+
|
287
|
+
homesick.symlink('glencairn')
|
288
|
+
homesick.unlink('glencairn')
|
289
|
+
|
290
|
+
home_dotdir = home.join('.config').join('appA')
|
291
|
+
home_dotdir.should exist
|
292
|
+
home_dotdir.join('.some_dotfile').should_not exist
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
context "with '.config' and '.config/someapp' in .homesick_subdir" do
|
297
|
+
let(:castle) { given_castle('glencairn', ['.config', '.config/someapp']) }
|
298
|
+
|
299
|
+
it 'can unsymlink under both of .config and .config/someapp' do
|
300
|
+
config_dir = castle.directory('.config')
|
301
|
+
config_dir.file('.some_dotfile')
|
302
|
+
config_dir.directory('someapp').file('.some_appfile')
|
303
|
+
|
304
|
+
homesick.symlink('glencairn')
|
305
|
+
homesick.unlink('glencairn')
|
306
|
+
|
307
|
+
home_config_dir = home.join('.config')
|
308
|
+
home_someapp_dir = home_config_dir.join('someapp')
|
309
|
+
home_config_dir.should exist
|
310
|
+
home_config_dir.join('.some_dotfile').should_not exist
|
311
|
+
home_someapp_dir.should exist
|
312
|
+
home_someapp_dir.join('.some_appfile').should_not exist
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
context "when call with no castle name" do
|
317
|
+
let(:castle) { given_castle('dotfiles') }
|
318
|
+
|
319
|
+
it 'using default castle name: "dotfiles"' do
|
320
|
+
castle.file('.some_dotfile')
|
321
|
+
|
322
|
+
homesick.symlink
|
323
|
+
homesick.unlink
|
324
|
+
|
325
|
+
home.join('.some_dotfile').should_not exist
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
191
330
|
describe 'list' do
|
192
331
|
it 'should say each castle in the castle directory' do
|
193
332
|
given_castle('zomg')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: homesick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Nichols
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|