homesick 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb41a6e1dd7453b91796507fc0a56b6663c73389
4
- data.tar.gz: 7c42989093fd2b303e31e0d0890aaab2f4a73d93
3
+ metadata.gz: 935d44fa24cb4310c884525e49132d31b9e7c4ae
4
+ data.tar.gz: c6ca2fd9083135f116f686495d200dcc197b5edb
5
5
  SHA512:
6
- metadata.gz: 403366559aefb1ff72fb1714f486381ce1be64bf353cb68de64ac8b4acc7f23713aefb5af82ab7a496550f58d398da1876fa4bfd90779e56f4645b0f9c826419
7
- data.tar.gz: 2814e3a366ae0c54e3938e91b98a4910f2f42d8ce710564680d4de6bbe0ce6ae02a66db2c5fe28216b3734665ddf6b4ee2608994f2d7a7f06eddf69427d85016
6
+ metadata.gz: c50908d9d15eb4375a92e377601f2b198a5d2cffb76c58768e7d43cf397a19f10704ef6e83cfa37c974b11de923d111d5ead0a6606dcd1aacab359f4d87dfa33
7
+ data.tar.gz: c1a5a4b9161eb038fa435ba16686a99b0f23dc0a2f05b68c5db9842108d618f08ccc38c8f62025323a09167e27d63a177d30ee0bd411bd19a420b9e49fbe44b2
@@ -1,3 +1,8 @@
1
+ #1.1.2
2
+ * Added '--force' option to the rc command to bypass confirmation checks when running a .homesickrc file
3
+ * Added a check to make sure that a minimum of Git 1.8.0 is installed. This stops Homesick failing silently if Git is not installed.
4
+ * Code refactoring and fixes.
5
+
1
6
  #1.1.0
2
7
  * Added exec and exec_all commands to run commands inside one or all clones castles.
3
8
  * Code refactoring.
data/Gemfile CHANGED
@@ -8,12 +8,11 @@ gem "thor", ">= 0.14.0"
8
8
  # Include everything needed to run rake, tests, features, etc.
9
9
  group :development do
10
10
  gem "rake", ">= 0.8.7"
11
- gem "rspec", "~> 2.10"
11
+ gem "rspec", "~> 3.1.0"
12
12
  gem "guard"
13
13
  gem "guard-rspec"
14
14
  gem "rb-readline", "~> 0.5.0"
15
15
  gem "jeweler", ">= 1.6.2"
16
- #gem "simplecov"
17
16
  gem 'coveralls', require: false
18
17
  gem "test_construct"
19
18
  gem "capture-output", "~> 1.0.0"
@@ -1,11 +1,11 @@
1
1
  # homesick
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/homesick.png)](http://badge.fury.io/rb/homesick)
4
- [![Build Status](https://travis-ci.org/technicalpickles/homesick.png?branch=master)](https://travis-ci.org/technicalpickles/homesick)
5
- [![Dependency Status](https://gemnasium.com/technicalpickles/homesick.png)](https://gemnasium.com/technicalpickles/homesick)
3
+ [![Gem Version](https://badge.fury.io/rb/homesick.svg)](http://badge.fury.io/rb/homesick)
4
+ [![Build Status](https://travis-ci.org/technicalpickles/homesick.svg?branch=master)](https://travis-ci.org/technicalpickles/homesick)
5
+ [![Dependency Status](https://gemnasium.com/technicalpickles/homesick.svg)](https://gemnasium.com/technicalpickles/homesick)
6
6
  [![Coverage Status](https://coveralls.io/repos/technicalpickles/homesick/badge.png)](https://coveralls.io/r/technicalpickles/homesick)
7
- [![Code Climate](https://codeclimate.com/github/technicalpickles/homesick.png)](https://codeclimate.com/github/technicalpickles/homesick)
8
- [![Gitter chat](https://badges.gitter.im/technicalpickles/homesick.png)](https://gitter.im/technicalpickles/homesick)
7
+ [![Code Climate](https://codeclimate.com/github/technicalpickles/homesick.svg)](https://codeclimate.com/github/technicalpickles/homesick)
8
+ [![Gitter chat](https://badges.gitter.im/technicalpickles/homesick.svg)](https://gitter.im/technicalpickles/homesick)
9
9
 
10
10
  Your home directory is your castle. Don't leave your dotfiles behind.
11
11
 
@@ -40,7 +40,7 @@ If you need to add further configuration steps you can add these in a file calle
40
40
 
41
41
  homesick rc CASTLE
42
42
 
43
- The contents of the .homesickrc file must be valid Ruby code as the file will be executed with Ruby's eval construct. The .homesickrc is also passed the current homesick object during its execution and this is available within the .homesickrc file as the 'self' variable.
43
+ The contents of the .homesickrc file must be valid Ruby code as the file will be executed with Ruby's eval construct. The .homesickrc is also passed the current homesick object during its execution and this is available within the .homesickrc file as the 'self' variable. As the rc operation can be destructive the command normally asks for confirmation before proceeding. You can bypass this by passing the '--force' option, for example `homesick rc --force CASTLE`.
44
44
 
45
45
  If you're not sure what castles you have around, you can easily list them:
46
46
 
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: homesick 1.1.1 ruby lib
5
+ # stub: homesick 1.1.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "homesick"
9
- s.version = "1.1.1"
9
+ s.version = "1.1.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Joshua Nichols", "Yusuke Murata"]
14
- s.date = "2014-05-22"
14
+ s.date = "2015-01-02"
15
15
  s.description = "\n Your home directory is your castle. Don't leave your dotfiles behind.\n \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 "
16
16
  s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"]
17
17
  s.executables = ["homesick"]
@@ -37,7 +37,6 @@ Gem::Specification.new do |s|
37
37
  "lib/homesick/actions/file_actions.rb",
38
38
  "lib/homesick/actions/git_actions.rb",
39
39
  "lib/homesick/cli.rb",
40
- "lib/homesick/shell.rb",
41
40
  "lib/homesick/utils.rb",
42
41
  "lib/homesick/version.rb",
43
42
  "spec/homesick_cli_spec.rb",
@@ -55,7 +54,7 @@ Gem::Specification.new do |s|
55
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
55
  s.add_runtime_dependency(%q<thor>, [">= 0.14.0"])
57
56
  s.add_development_dependency(%q<rake>, [">= 0.8.7"])
58
- s.add_development_dependency(%q<rspec>, ["~> 2.10"])
57
+ s.add_development_dependency(%q<rspec>, ["~> 3.1.0"])
59
58
  s.add_development_dependency(%q<guard>, [">= 0"])
60
59
  s.add_development_dependency(%q<guard-rspec>, [">= 0"])
61
60
  s.add_development_dependency(%q<rb-readline>, ["~> 0.5.0"])
@@ -67,7 +66,7 @@ Gem::Specification.new do |s|
67
66
  else
68
67
  s.add_dependency(%q<thor>, [">= 0.14.0"])
69
68
  s.add_dependency(%q<rake>, [">= 0.8.7"])
70
- s.add_dependency(%q<rspec>, ["~> 2.10"])
69
+ s.add_dependency(%q<rspec>, ["~> 3.1.0"])
71
70
  s.add_dependency(%q<guard>, [">= 0"])
72
71
  s.add_dependency(%q<guard-rspec>, [">= 0"])
73
72
  s.add_dependency(%q<rb-readline>, ["~> 0.5.0"])
@@ -80,7 +79,7 @@ Gem::Specification.new do |s|
80
79
  else
81
80
  s.add_dependency(%q<thor>, [">= 0.14.0"])
82
81
  s.add_dependency(%q<rake>, [">= 0.8.7"])
83
- s.add_dependency(%q<rspec>, ["~> 2.10"])
82
+ s.add_dependency(%q<rspec>, ["~> 3.1.0"])
84
83
  s.add_dependency(%q<guard>, [">= 0"])
85
84
  s.add_dependency(%q<guard-rspec>, [">= 0"])
86
85
  s.add_dependency(%q<rb-readline>, ["~> 0.5.0"])
@@ -1,5 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
- require 'homesick/shell'
3
2
  require 'homesick/actions/file_actions'
4
3
  require 'homesick/actions/git_actions'
5
4
  require 'homesick/version'
@@ -3,6 +3,25 @@ module Homesick
3
3
  module Actions
4
4
  # Git-related helper methods for Homesick
5
5
  module GitActions
6
+ # Information on the minimum git version required for Homesick
7
+ MIN_VERSION = {
8
+ major: 1,
9
+ minor: 8,
10
+ patch: 0
11
+ }
12
+ STRING = MIN_VERSION.values.join('.')
13
+
14
+ def git_version_correct?
15
+ info = `git --version`.scan(/(\d+)\.(\d+)\.(\d+)/).flatten.map(&:to_i)
16
+ return false unless info.count == 3
17
+ current_version = Hash[ [:major, :minor, :patch].zip(info) ]
18
+ return true if current_version.eql?(MIN_VERSION)
19
+ return true if current_version[:major] > MIN_VERSION[:major]
20
+ return true if current_version[:major] == MIN_VERSION[:major] && current_version[:minor] > MIN_VERSION[:minor]
21
+ return true if current_version[:major] == MIN_VERSION[:major] && current_version[:minor] == MIN_VERSION[:minor] && current_version[:patch] >= MIN_VERSION[:patch]
22
+ false
23
+ end
24
+
6
25
  # TODO: move this to be more like thor's template, empty_directory, etc
7
26
  def git_clone(repo, config = {})
8
27
  config ||= {}
@@ -19,7 +19,24 @@ module Homesick
19
19
 
20
20
  def initialize(args = [], options = {}, config = {})
21
21
  super
22
- self.shell = Homesick::Shell.new
22
+ # Check if git is installed
23
+ unless git_version_correct?
24
+ say_status :error, "Git version >= #{Homesick::Actions::GitActions::STRING} must be installed to use Homesick", :red
25
+ exit(1)
26
+ end
27
+ # Hack in support for diffing symlinks
28
+ self.shell = Thor::Shell::Color.new
29
+ class << shell
30
+ def show_diff(destination, content)
31
+ destination = Pathname.new(destination)
32
+ if destination.symlink?
33
+ say "- #{destination.readlink}", :red, true
34
+ say "+ #{content.expand_path}", :green, true
35
+ else
36
+ super
37
+ end
38
+ end
39
+ end
23
40
  end
24
41
 
25
42
  desc 'clone URI', 'Clone +uri+ as a castle for homesick'
@@ -49,12 +66,15 @@ module Homesick
49
66
  end
50
67
 
51
68
  desc 'rc CASTLE', 'Run the .homesickrc for the specified castle'
69
+ method_option :force,
70
+ default: false,
71
+ desc: 'Evaluate .homesickrc without prompting.'
52
72
  def rc(name = DEFAULT_CASTLE_NAME)
53
73
  inside repos_dir do
54
74
  destination = Pathname.new(name)
55
75
  homesickrc = destination.join('.homesickrc').expand_path
56
76
  if homesickrc.exist?
57
- proceed = shell.yes?("#{name} has a .homesickrc. Proceed with evaling it? (This could be destructive)")
77
+ proceed = options[:force] || shell.yes?("#{name} has a .homesickrc. Proceed with evaling it? (This could be destructive)")
58
78
  if proceed
59
79
  say_status 'eval', homesickrc
60
80
  inside destination do
@@ -21,7 +21,7 @@ module Homesick
21
21
  protected
22
22
 
23
23
  def home_dir
24
- @home_dir ||= Pathname.new(ENV['HOME'] || '~').expand_path
24
+ @home_dir ||= Pathname.new(ENV['HOME'] || '~').realpath
25
25
  end
26
26
 
27
27
  def repos_dir
@@ -5,7 +5,7 @@ module Homesick
5
5
  module Version
6
6
  MAJOR = 1
7
7
  MINOR = 1
8
- PATCH = 1
8
+ PATCH = 2
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
11
11
  end
@@ -1,6 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require 'spec_helper'
3
3
  require 'capture-output'
4
+ require 'pathname'
4
5
 
5
6
  describe Homesick::CLI do
6
7
  let(:home) { create_construct }
@@ -12,6 +13,49 @@ describe Homesick::CLI do
12
13
 
13
14
  before { allow(homesick).to receive(:repos_dir).and_return(castles) }
14
15
 
16
+ describe 'smoke tests' do
17
+ context 'when running bin/homesick' do
18
+ before do
19
+ bin_path = Pathname.new(__FILE__).parent.parent
20
+ @output = `#{bin_path.expand_path}/bin/homesick`
21
+ end
22
+ it 'should output some text when bin/homesick is called' do
23
+ expect(@output.length).to be > 0
24
+ end
25
+ end
26
+
27
+ context 'when a git version that doesn\'t meet the minimum required is installed' do
28
+ before do
29
+ expect_any_instance_of(Homesick::Actions::GitActions).to receive(:`).and_return("git version 1.7.6")
30
+ end
31
+ it 'should raise an exception' do
32
+ output = Capture.stdout{ expect{Homesick::CLI.new}.to raise_error SystemExit }
33
+ expect(output.chomp).to include(Homesick::Actions::GitActions::STRING)
34
+ end
35
+ end
36
+
37
+ context 'when a git version that is the same as the minimum required is installed' do
38
+ before do
39
+ expect_any_instance_of(Homesick::Actions::GitActions).to receive(:`).at_least(:once).and_return("git version #{Homesick::Actions::GitActions::STRING}")
40
+ end
41
+ it 'should not raise an exception' do
42
+ output = Capture.stdout{ expect{Homesick::CLI.new}.not_to raise_error }
43
+ expect(output.chomp).not_to include(Homesick::Actions::GitActions::STRING)
44
+ end
45
+ end
46
+
47
+ context 'when a git version that is greater than the minimum required is installed' do
48
+ before do
49
+ expect_any_instance_of(Homesick::Actions::GitActions).to receive(:`).at_least(:once).and_return("git version 3.9.8")
50
+ end
51
+ it 'should not raise an exception' do
52
+ output = Capture.stdout{ expect{Homesick::CLI.new}.not_to raise_error }
53
+ expect(output.chomp).not_to include(Homesick::Actions::GitActions::STRING)
54
+ end
55
+
56
+ end
57
+ end
58
+
15
59
  describe 'clone' do
16
60
  context 'has a .homesickrc' do
17
61
  it 'runs the .homesickrc' do
@@ -63,7 +107,7 @@ describe Homesick::CLI do
63
107
  homesick.clone "file://#{bare_repo}"
64
108
  end
65
109
  expect(File.directory?(File.join(home.to_s, '.homesick/repos/dotfiles')))
66
- .to be_true
110
+ .to be_truthy
67
111
  end
68
112
 
69
113
  it 'clones git repo like git://host/path/to.git' do
@@ -136,6 +180,26 @@ describe Homesick::CLI do
136
180
  end
137
181
  end
138
182
 
183
+ context 'when options[:force] == true' do
184
+ let(:homesick) { Homesick::CLI.new [], force: true }
185
+ before do
186
+ expect_any_instance_of(Thor::Shell::Basic).to_not receive(:yes?)
187
+ end
188
+
189
+ it 'executes the .homesickrc' do
190
+ castle.file('.homesickrc') do |file|
191
+ file << "File.open(Dir.pwd + '/testing', 'w') do |f|
192
+ f.print 'testing'
193
+ end"
194
+ end
195
+
196
+ expect(homesick).to receive(:say_status).with('eval', kind_of(Pathname))
197
+ homesick.rc castle
198
+
199
+ expect(castle.join('testing')).to exist
200
+ end
201
+ end
202
+
139
203
  context 'when told not to do so' do
140
204
  before do
141
205
  expect_any_instance_of(Thor::Shell::Basic).to receive(:yes?).with(be_a(String)).and_return(false)
@@ -671,7 +735,7 @@ describe Homesick::CLI do
671
735
  describe 'version' do
672
736
  it 'prints the current version of homesick' do
673
737
  text = Capture.stdout { homesick.version }
674
- expect(text.chomp).to match(/\d+\.\d+\.\d+/)
738
+ expect(text.chomp).to match(/#{Regexp.escape(Homesick::Version::STRING)}/)
675
739
  end
676
740
  end
677
741
 
@@ -5,7 +5,6 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
  require 'homesick'
7
7
  require 'rspec'
8
- require 'rspec/autorun'
9
8
  require 'test_construct'
10
9
  require 'tempfile'
11
10
 
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: 1.1.1
4
+ version: 1.1.2
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: 2014-05-22 00:00:00.000000000 Z
12
+ date: 2015-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '2.10'
48
+ version: 3.1.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '2.10'
55
+ version: 3.1.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: guard
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -196,7 +196,6 @@ files:
196
196
  - lib/homesick/actions/file_actions.rb
197
197
  - lib/homesick/actions/git_actions.rb
198
198
  - lib/homesick/cli.rb
199
- - lib/homesick/shell.rb
200
199
  - lib/homesick/utils.rb
201
200
  - lib/homesick/version.rb
202
201
  - spec/homesick_cli_spec.rb
@@ -1,17 +0,0 @@
1
- require 'thor'
2
-
3
- module Homesick
4
- # Hack in support for diffing symlinks
5
- class Shell < Thor::Shell::Color
6
- def show_diff(destination, content)
7
- destination = Pathname.new(destination)
8
-
9
- if destination.symlink?
10
- say "- #{destination.readlink}", :red, true
11
- say "+ #{content.expand_path}", :green, true
12
- else
13
- super
14
- end
15
- end
16
- end
17
- end