homesick 0.9.7 → 0.9.8

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4fc4b30a85f7a1001b99eb6c6ad90722d514fb52
4
+ data.tar.gz: 6486c266462f0f2e48b4c559e44184f35f25f3d2
5
+ SHA512:
6
+ metadata.gz: b796a5dfaf02f88523dbfbe9baa0756b3272a079056e67a91613f6ee7457ea3e0cce22bc065b38d02aebd4f9004a0db0a432968c4a8e4f3bdd503e1508375c4c
7
+ data.tar.gz: 2074f30e9d96a67b8b9753c02f5549b7432689f276edfbdc92c1eaf8def60b59ca96d3fd4434cfb3df21407b685d17b09cd2fad70512f2fa0d9dccc3c5b5be9d
data/Gemfile CHANGED
@@ -8,10 +8,14 @@ gem "thor", ">= 0.14.0"
8
8
  group :development do
9
9
  gem "rake", ">= 0.8.7"
10
10
  gem "rspec", "~> 2.10"
11
+ gem "guard"
12
+ gem "guard-rspec"
13
+ gem "rb-readline", "~> 0.5.0"
11
14
  gem "jeweler", ">= 1.6.2"
12
15
  gem "rcov", :platforms => :mri_18
13
16
  gem "simplecov", :platforms => :mri_19
14
17
  gem "test-construct"
18
+ gem "capture-output", "~> 1.0.0"
15
19
  if RUBY_VERSION >= '1.9.2'
16
20
  gem "rubocop"
17
21
  end
data/README.markdown CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/technicalpickles/homesick.png?branch=master)](https://travis-ci.org/technicalpickles/homesick)
4
4
 
5
- A man's home (directory) is his castle, so don't leave home with out it.
5
+ Your home directory is your castle. Don't leave your dotfiles behind.
6
6
 
7
7
  Homesick is sorta like [rip](http://github.com/defunkt/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.
8
8
 
data/Rakefile CHANGED
@@ -12,9 +12,10 @@ require 'rake'
12
12
  require 'jeweler'
13
13
  Jeweler::Tasks.new do |gem|
14
14
  gem.name = "homesick"
15
- gem.summary = %Q{A man's home is his castle. Never leave your dotfiles behind.}
15
+ gem.summary = %Q{Your home directory is your castle. Don't leave your dotfiles behind.}
16
16
  gem.description = %Q{
17
- A man's home (directory) is his castle, so don't leave home with out it.
17
+ Your home directory is your castle. Don't leave your dotfiles behind.
18
+
18
19
 
19
20
  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.
20
21
 
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.7"
8
+ s.version = "0.9.8"
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-11-02"
12
+ s.date = "2013-12-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
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'thor'
2
3
 
3
4
  class Homesick < Thor
@@ -89,9 +90,9 @@ class Homesick < Thor
89
90
 
90
91
  end
91
92
 
92
- desc 'commit CASTLE', "Commit the specified castle's changes"
93
- def commit(name = DEFAULT_CASTLE_NAME)
94
- commit_castle name
93
+ desc 'commit CASTLE MESSAGE', "Commit the specified castle's changes"
94
+ def commit(name = DEFAULT_CASTLE_NAME, message = nil)
95
+ commit_castle name, message
95
96
 
96
97
  end
97
98
 
@@ -227,6 +228,41 @@ class Homesick < Thor
227
228
  end
228
229
  end
229
230
 
231
+ desc "destroy CASTLE", "Delete all symlinks and remove the cloned repository"
232
+ def destroy(name)
233
+ check_castle_existance name, "destroy"
234
+
235
+ if shell.yes?("This will destroy your castle irreversible! Are you sure?")
236
+ unlink(name)
237
+ rm_rf repos_dir.join(name)
238
+ end
239
+
240
+ end
241
+
242
+ desc "cd CASTLE", "Open a new shell in the root of the given castle"
243
+ def cd(castle = DEFAULT_CASTLE_NAME)
244
+ check_castle_existance castle, "cd"
245
+ castle_dir = repos_dir.join(castle)
246
+ say_status "cd #{castle_dir.realpath}", "Opening a new shell in castle '#{castle}'. To return to the original one exit from the new shell.", :green
247
+ inside castle_dir do
248
+ system(ENV['SHELL'])
249
+ end
250
+ end
251
+
252
+ desc "open CASTLE", "Open your default editor in the root of the given castle"
253
+ def open(castle = DEFAULT_CASTLE_NAME)
254
+ if ! ENV['EDITOR']
255
+ say_status :error,"The $EDITOR environment variable must be set to use this command", :red
256
+
257
+ exit(1)
258
+ end
259
+ check_castle_existance castle, "open"
260
+ castle_dir = repos_dir.join(castle)
261
+ say_status "#{ENV['EDITOR']} #{castle_dir.realpath}", "Opening the root directory of castle '#{castle}' in editor '#{ENV['EDITOR']}'.", :green
262
+ inside castle_dir do
263
+ system(ENV['EDITOR'])
264
+ end
265
+ end
230
266
 
231
267
  protected
232
268
 
@@ -278,10 +314,10 @@ class Homesick < Thor
278
314
  end
279
315
  end
280
316
 
281
- def commit_castle(castle)
317
+ def commit_castle(castle, message)
282
318
  check_castle_existance(castle, 'commit')
283
319
  inside repos_dir.join(castle) do
284
- git_commit_all
320
+ git_commit_all :message => message
285
321
  end
286
322
  end
287
323
 
@@ -386,7 +422,7 @@ class Homesick < Thor
386
422
  home_path = home_dir.join(relative_dir).join(path)
387
423
 
388
424
  yield(absolute_path, home_path)
389
- end
425
+ end
390
426
  end
391
427
  end
392
428
 
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  class Homesick
2
3
  module Actions
3
4
  # TODO move this to be more like thor's template, empty_directory, etc
@@ -63,7 +64,11 @@ class Homesick
63
64
 
64
65
  def git_commit_all(config = {})
65
66
  say_status 'git commit all', '', :green unless options[:quiet]
66
- system 'git commit -v -a' unless options[:pretend]
67
+ if config[:message]
68
+ system "git commit -a -m '#{config[:message]}'" unless options[:pretend]
69
+ else
70
+ system 'git commit -v -a' unless options[:pretend]
71
+ end
67
72
  end
68
73
 
69
74
  def git_add(file, config = {})
@@ -108,6 +113,37 @@ class Homesick
108
113
  end
109
114
  end
110
115
 
116
+ def rm(file)
117
+ say_status "rm #{file}", '', :green unless options[:quiet]
118
+ system "rm #{file}" if File.exists?(file)
119
+ end
120
+
121
+ def rm_rf(dir)
122
+ say_status "rm -rf #{dir}", '', :green unless options[:quiet]
123
+ system "rm -rf #{dir}"
124
+ end
125
+
126
+ def rm_link(target)
127
+ target = Pathname.new(target)
128
+
129
+ if target.symlink?
130
+ say_status :unlink, "#{target.expand_path}", :green unless options[:quiet]
131
+ FileUtils.rm_rf target
132
+ else
133
+ say_status :conflict, "#{target} is not a symlink", :red unless options[:quiet]
134
+ end
135
+ end
136
+
137
+ def rm(file)
138
+ say_status "rm #{file}", '', :green unless options[:quiet]
139
+ system "rm #{file}"
140
+ end
141
+
142
+ def rm_r(dir)
143
+ say_status "rm -r #{dir}", '', :green unless options[:quiet]
144
+ system "rm -r #{dir}"
145
+ end
146
+
111
147
  def ln_s(source, destination, config = {})
112
148
  source = Pathname.new(source)
113
149
  destination = Pathname.new(destination)
@@ -1,4 +1,6 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'spec_helper'
3
+ require 'capture-output'
2
4
 
3
5
  describe 'homesick' do
4
6
  let(:home) { create_construct }
@@ -340,9 +342,19 @@ describe 'homesick' do
340
342
  end
341
343
 
342
344
  describe 'status' do
345
+ it 'should say "nothing to commit" when there are no changes' do
346
+ given_castle('castle_repo')
347
+ text = Capture.stdout { homesick.status('castle_repo') }
348
+ text.should =~ /nothing to commit \(create\/copy files and use "git add" to track\)$/
349
+ end
343
350
 
344
- xit 'needs testing'
345
-
351
+ it 'should say "Changes to be committed" when there are changes' do
352
+ given_castle('castle_repo')
353
+ some_rc_file = home.file '.some_rc_file'
354
+ homesick.track(some_rc_file.to_s, 'castle_repo')
355
+ text = Capture.stdout { homesick.status('castle_repo') }
356
+ text.should =~ /Changes to be committed:.*new file:\s*home\/.some_rc_file/m
357
+ end
346
358
  end
347
359
 
348
360
  describe 'diff' do
@@ -371,12 +383,6 @@ describe 'homesick' do
371
383
 
372
384
  end
373
385
 
374
- describe 'commit' do
375
-
376
- xit 'needs testing'
377
-
378
- end
379
-
380
386
  describe 'push' do
381
387
 
382
388
  xit 'needs testing'
@@ -447,6 +453,16 @@ describe 'homesick' do
447
453
  end
448
454
  end
449
455
 
456
+ describe 'commit' do
457
+ it 'should have a commit message when the commit succeeds' do
458
+ given_castle('castle_repo')
459
+ some_rc_file = home.file '.a_random_rc_file'
460
+ homesick.track(some_rc_file.to_s, 'castle_repo')
461
+ text = Capture.stdout { homesick.commit('castle_repo', 'Test message') }
462
+ text.should =~ /^\[master \(root-commit\) \w+\] Test message/
463
+ end
464
+ end
465
+
450
466
  describe 'subdir_file' do
451
467
 
452
468
  it 'should add the nested files parent to the subdir_file' do
@@ -490,4 +506,63 @@ describe 'homesick' do
490
506
  end
491
507
  end
492
508
  end
509
+
510
+ describe "destroy" do
511
+ it "removes the symlink files" do
512
+ expect_any_instance_of(Thor::Shell::Basic).to receive(:yes?).and_return('y')
513
+ given_castle("stronghold")
514
+ some_rc_file = home.file '.some_rc_file'
515
+ homesick.track(some_rc_file.to_s, "stronghold")
516
+ homesick.destroy('stronghold')
517
+
518
+ some_rc_file.should_not be_exist
519
+ end
520
+
521
+ it "deletes the cloned repository" do
522
+ expect_any_instance_of(Thor::Shell::Basic).to receive(:yes?).and_return('y')
523
+ castle = given_castle("stronghold")
524
+ some_rc_file = home.file '.some_rc_file'
525
+ homesick.track(some_rc_file.to_s, "stronghold")
526
+ homesick.destroy('stronghold')
527
+
528
+ castle.should_not be_exist
529
+ end
530
+ end
531
+
532
+ describe "cd" do
533
+ it "cd's to the root directory of the given castle" do
534
+ given_castle('castle_repo')
535
+ homesick.should_receive("inside").once.with(kind_of(Pathname)).and_yield
536
+ homesick.should_receive("system").once.with(ENV["SHELL"])
537
+ Capture.stdout { homesick.cd 'castle_repo' }
538
+ end
539
+
540
+ it "returns an error message when the given castle does not exist" do
541
+ homesick.should_receive("say_status").once.with(:error, /Could not cd castle_repo, expected \/tmp\/construct_container.* exist and contain dotfiles/, :red)
542
+ expect { homesick.cd "castle_repo" }.to raise_error(SystemExit)
543
+ end
544
+ end
545
+
546
+ describe "open" do
547
+ it "opens the system default editor in the root of the given castle" do
548
+ ENV.stub(:[]).and_call_original # Make sure calls to ENV use default values for most things...
549
+ ENV.stub(:[]).with('EDITOR').and_return('vim') # Set a default value for 'EDITOR' just in case none is set
550
+ given_castle 'castle_repo'
551
+ homesick.should_receive("inside").once.with(kind_of(Pathname)).and_yield
552
+ homesick.should_receive("system").once.with('vim')
553
+ Capture.stdout { homesick.open 'castle_repo' }
554
+ end
555
+
556
+ it "returns an error message when the $EDITOR environment variable is not set" do
557
+ ENV.stub(:[]).with('EDITOR').and_return(nil) # Set the default editor to make sure it fails.
558
+ homesick.should_receive("say_status").once.with(:error,"The $EDITOR environment variable must be set to use this command", :red)
559
+ expect { homesick.open "castle_repo" }.to raise_error(SystemExit)
560
+ end
561
+
562
+ it "returns an error message when the given castle does not exist" do
563
+ ENV.stub(:[]).with('EDITOR').and_return('vim') # Set a default just in case none is set
564
+ homesick.should_receive("say_status").once.with(:error, /Could not open castle_repo, expected \/tmp\/construct_container.* exist and contain dotfiles/, :red)
565
+ expect { homesick.open "castle_repo" }.to raise_error(SystemExit)
566
+ end
567
+ end
493
568
  end
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ require 'homesick'
4
4
  require 'rspec'
5
5
  require 'rspec/autorun'
6
6
  require 'construct'
7
+ require 'tempfile'
7
8
 
8
9
  RSpec.configure do |config|
9
10
  config.include Construct::Helpers
@@ -21,6 +22,8 @@ RSpec.configure do |config|
21
22
  castles.directory(path) do |castle|
22
23
  Dir.chdir(castle) do
23
24
  system 'git init >/dev/null 2>&1'
25
+ system 'git config user.email "test@test.com"'
26
+ system 'git config user.name "Test Name"'
24
27
  system "git remote add origin git://github.com/technicalpickles/#{name}.git >/dev/null 2>&1"
25
28
  if subdirs
26
29
  subdir_file = castle.join(Homesick::SUBDIR_FILENAME)
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: homesick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
5
- prerelease:
4
+ version: 0.9.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Joshua Nichols
@@ -10,139 +9,123 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-11-02 00:00:00.000000000 Z
12
+ date: 2013-12-31 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: thor
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - ">="
21
19
  - !ruby/object:Gem::Version
22
20
  version: 0.14.0
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - ">="
29
26
  - !ruby/object:Gem::Version
30
27
  version: 0.14.0
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - ">="
37
33
  - !ruby/object:Gem::Version
38
34
  version: 0.8.7
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - ">="
45
40
  - !ruby/object:Gem::Version
46
41
  version: 0.8.7
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rspec
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ~>
46
+ - - "~>"
53
47
  - !ruby/object:Gem::Version
54
48
  version: '2.10'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ~>
53
+ - - "~>"
61
54
  - !ruby/object:Gem::Version
62
55
  version: '2.10'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: jeweler
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - ">="
69
61
  - !ruby/object:Gem::Version
70
62
  version: 1.6.2
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - ">="
77
68
  - !ruby/object:Gem::Version
78
69
  version: 1.6.2
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: rcov
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
- - - ! '>='
74
+ - - ">="
85
75
  - !ruby/object:Gem::Version
86
76
  version: '0'
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
- - - ! '>='
81
+ - - ">="
93
82
  - !ruby/object:Gem::Version
94
83
  version: '0'
95
84
  - !ruby/object:Gem::Dependency
96
85
  name: simplecov
97
86
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
87
  requirements:
100
- - - ! '>='
88
+ - - ">="
101
89
  - !ruby/object:Gem::Version
102
90
  version: '0'
103
91
  type: :development
104
92
  prerelease: false
105
93
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
94
  requirements:
108
- - - ! '>='
95
+ - - ">="
109
96
  - !ruby/object:Gem::Version
110
97
  version: '0'
111
98
  - !ruby/object:Gem::Dependency
112
99
  name: test-construct
113
100
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
101
  requirements:
116
- - - ! '>='
102
+ - - ">="
117
103
  - !ruby/object:Gem::Version
118
104
  version: '0'
119
105
  type: :development
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
108
  requirements:
124
- - - ! '>='
109
+ - - ">="
125
110
  - !ruby/object:Gem::Version
126
111
  version: '0'
127
112
  - !ruby/object:Gem::Dependency
128
113
  name: rubocop
129
114
  requirement: !ruby/object:Gem::Requirement
130
- none: false
131
115
  requirements:
132
- - - ! '>='
116
+ - - ">="
133
117
  - !ruby/object:Gem::Version
134
118
  version: '0'
135
119
  type: :development
136
120
  prerelease: false
137
121
  version_requirements: !ruby/object:Gem::Requirement
138
- none: false
139
122
  requirements:
140
- - - ! '>='
123
+ - - ">="
141
124
  - !ruby/object:Gem::Version
142
125
  version: '0'
143
- description: ! "\n A man's home (directory) is his castle, so don't leave home
144
- with out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to
145
- clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows
126
+ description: "\n A man's home (directory) is his castle, so don't leave home with
127
+ out it.\n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone
128
+ a repository containing dotfiles, and saves them in ~/.homesick. It then allows
146
129
  you to symlink all the dotfiles into place with a single command. \n\n "
147
130
  email:
148
131
  - josh@technicalpickles.com
@@ -155,9 +138,9 @@ extra_rdoc_files:
155
138
  - LICENSE
156
139
  - README.markdown
157
140
  files:
158
- - .document
159
- - .rspec
160
- - .travis.yml
141
+ - ".document"
142
+ - ".rspec"
143
+ - ".travis.yml"
161
144
  - ChangeLog.markdown
162
145
  - Gemfile
163
146
  - LICENSE
@@ -174,28 +157,24 @@ files:
174
157
  homepage: http://github.com/technicalpickles/homesick
175
158
  licenses:
176
159
  - MIT
160
+ metadata: {}
177
161
  post_install_message:
178
162
  rdoc_options: []
179
163
  require_paths:
180
164
  - lib
181
165
  required_ruby_version: !ruby/object:Gem::Requirement
182
- none: false
183
166
  requirements:
184
- - - ! '>='
167
+ - - ">="
185
168
  - !ruby/object:Gem::Version
186
169
  version: '0'
187
- segments:
188
- - 0
189
- hash: 2793752192583116957
190
170
  required_rubygems_version: !ruby/object:Gem::Requirement
191
- none: false
192
171
  requirements:
193
- - - ! '>='
172
+ - - ">="
194
173
  - !ruby/object:Gem::Version
195
174
  version: '0'
196
175
  requirements: []
197
176
  rubyforge_project:
198
- rubygems_version: 1.8.23
177
+ rubygems_version: 2.1.11
199
178
  signing_key:
200
179
  specification_version: 3
201
180
  summary: A man's home is his castle. Never leave your dotfiles behind.