dotman 0.0.3.4 → 0.0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cdba5f26889fa15fafb597bdaa574365e4312b63
4
- data.tar.gz: 7f19a42240c7ad4d216e91e61a19e4a1c2e53bb3
3
+ metadata.gz: 02d61901f1ecaed6d72c8ff3265419cfa6bcd165
4
+ data.tar.gz: 96bf81094aeecf17c9420cd044b35b8bf7df4e76
5
5
  SHA512:
6
- metadata.gz: 2cd7340dd7dfa9bccdbdb9ec818eef671b79b40551aca2b39be326a4edef705b1743f27fe5227085fd0c46c255816e02718da1da80f0773e6da45c55c6d55f3f
7
- data.tar.gz: 2325f45fa7f4b1b8489bbc43dfcfe166534c3b721d56625186fd4857d7c0af94b442145843145f7e0ba6b08b7f91636f00f1fd9a6ec43a572059c66c79febcc7
6
+ metadata.gz: 8ec780a62926699bb739936ef8b07613e1187e1659d988f11b05d029bc67594916ec139930cebfe8403325b13e35b8f144efcf1d6ee0f4631e87ffecb4723e50
7
+ data.tar.gz: 46c94520482a966d98350f1e5e267d802310c1c90c01f535ae4d4edf839fa3e3b70a863868a8111896c7473f2aa8edcf2ece893fdffc46e46e18d23fcffea3b8
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - "1.8.7"
3
4
  - "1.9.2"
4
5
  - "1.9.3"
5
6
  - "2.0.0"
data/README.md CHANGED
@@ -3,7 +3,7 @@ This gem allows you to switch between different dotfiles on the same user accoun
3
3
 
4
4
  ## Requirements
5
5
 
6
- ruby 1.9, 2.0
6
+ ruby 1.8, 1.9, 2.0
7
7
 
8
8
  ## Installation
9
9
 
@@ -26,7 +26,12 @@ DOTFILES_PATH = "#{ENV['HOME']}/.dotman/dotfiles.yml"
26
26
 
27
27
  def self.find_by_alias(alias_name)
28
28
  ensure_default_dotfile_configuration_exists
29
- new(dotfiles_yaml.fetch(alias_name))
29
+ begin
30
+ found = dotfiles_yaml.fetch(alias_name)
31
+ new(dotfiles_yaml.fetch(alias_name))
32
+ rescue KeyError
33
+ Dotman::Notification.dotfile_collection_not_found(alias_name)
34
+ end
30
35
  end
31
36
 
32
37
  def self.new_configuration(folder_name, alias_name = nil)
@@ -10,11 +10,16 @@ module Dotman
10
10
  end
11
11
 
12
12
  def self.folder_name(git_location)
13
- folder_name = git_location.scan(/[^:]+[\/]?dotfile[s?]{1}/).first.gsub('/', '_')
13
+ folder_name = git_location.scan(/[^:]+[\/]{1}[a-zA-Z0-9]+/).first.gsub('/', '_')
14
14
  end
15
15
 
16
16
  def self.clone_repository(git_location, alias_name = nil)
17
- dotfile_location = "#{ENV['HOME']}/.dotman/#{folder_name(git_location)}"
17
+ if git_location && !git_location.strip.empty?
18
+ dotfile_location = "#{ENV['HOME']}/.dotman/#{folder_name(git_location)}"
19
+ else
20
+ return Dotman::Notification.unspecified_git_path
21
+ end
22
+
18
23
  if (File.directory?(dotfile_location))
19
24
  Dotman::Notification.already_cloned
20
25
  else
@@ -1,3 +1,3 @@
1
1
  module Dotman
2
- VERSION = "0.0.3.4"
2
+ VERSION = "0.0.3.6"
3
3
  end
@@ -17,6 +17,13 @@ describe Dotman::DotfileCollection do
17
17
  File.directory?(File.join(Dotman::Base.dotman_folder, 'Timbinous_dotfiles')).should be_true
18
18
  end
19
19
  end
20
+
21
+ context "when dotfile collection is not found" do
22
+ it "shows the message that the dotfile wasn't found" do
23
+ Dotman::Notification.should_receive(:dotfile_collection_not_found).with('zach')
24
+ Dotman::DotfileCollection.find_by_alias('zach')
25
+ end
26
+ end
20
27
  end
21
28
 
22
29
  describe ".delete" do
@@ -55,7 +62,7 @@ describe Dotman::DotfileCollection do
55
62
  describe ".show_all_aliases" do
56
63
  context "when aliases exist in the collection" do
57
64
  it "shows all the aliases" do
58
- STDOUT.should_receive(:puts).with("default\ntim")
65
+ STDOUT.should_receive(:puts).with(Dotman::DotfileCollection.all_aliases.join("\n"))
59
66
  Dotman::Notification.display_all_aliases
60
67
  end
61
68
  end
@@ -11,39 +11,70 @@ describe Dotman::Git do
11
11
  Dotman::Base.ensure_current_dotman_file_exists
12
12
  end
13
13
 
14
- context "cloning a new repo" do
15
-
14
+ describe ".clone_repository" do
16
15
  let (:git_dotfile_repo_path) { "git@github.com:Timbinous/dotfiles.git" }
17
16
  let (:git_folder_name) { Dotman::Git.folder_name(git_dotfile_repo_path) }
18
17
 
19
- context "when no alias passed" do
18
+ context "when the git location is specified" do
19
+ context "when the git repository has not been cloned yet" do
20
+ context "when alias was passed" do
20
21
 
21
- it "clones to the $HOME/.dotman folder" do
22
- expect {
23
- Dotman::Git.clone_repository(git_dotfile_repo_path) }.
24
- to change { File.directory?("#{ENV['HOME']}/.dotman/Timbinous_dotfiles") }.to true
25
- end
22
+ it "clones to the $HOME/.dotman folder" do
23
+ expect {
24
+ Dotman::Git.clone_repository(git_dotfile_repo_path, 'tim') }.
25
+ to change { File.directory?("#{ENV['HOME']}/.dotman/Timbinous_dotfiles") }.to true
26
+ end
26
27
 
27
- it "sets the yaml configuration" do
28
- Dotman::DotfileCollection.find_by_alias(git_folder_name).should_not be_false
29
- end
28
+ it "sets the yaml configuration relating to the alias" do
29
+ Dotman::DotfileCollection.find_by_alias('tim').should_not be_false
30
+ end
31
+ end
30
32
 
31
- end
33
+ context "when no alias passed" do
32
34
 
33
- context "when alias was passed" do
35
+ it "clones to the $HOME/.dotman folder" do
36
+ expect {
37
+ Dotman::Git.clone_repository(git_dotfile_repo_path) }.
38
+ to change { File.directory?("#{ENV['HOME']}/.dotman/Timbinous_dotfiles") }.to true
39
+ end
34
40
 
35
- it "clones to the $HOME/.dotman folder" do
36
- expect {
37
- Dotman::Git.clone_repository(git_dotfile_repo_path, 'tim') }.
38
- to change { File.directory?("#{ENV['HOME']}/.dotman/Timbinous_dotfiles") }.to true
41
+ it "sets the yaml configuration relating to the \"git user name\"_\"repo name\"" do
42
+ Dotman::DotfileCollection.find_by_alias(git_folder_name).should_not be_false
43
+ end
44
+ end
39
45
  end
40
46
 
41
- it "sets the yaml configuration" do
42
- Dotman::DotfileCollection.find_by_alias('tim').should_not be_false
43
- end
47
+ context "when the git repository has already been cloned" do
48
+ before :each do
49
+ Dotman::Git.clone_repository(git_dotfile_repo_path, 'tim')
50
+ end
44
51
 
52
+ it "sends a notification that this repository has already been cloned"do
53
+ Dotman::Notification.should_receive(:already_cloned)
54
+ Dotman::Git.clone_repository(git_dotfile_repo_path, 'tim')
55
+ end
56
+ end
57
+ end
58
+
59
+ context "when the git location was not specified" do
60
+ it "sends an error notification to the user" do
61
+ Dotman::Notification.should_receive(:unspecified_git_path)
62
+ Dotman::Git.clone_repository(nil)
63
+ end
45
64
  end
46
65
  end
47
-
48
66
 
67
+ describe ".folder_name" do
68
+ context "when containing a dotfiles repository name in github" do
69
+ it "returns the username_dotfiles as the folder name" do
70
+ Dotman::Git.folder_name('git@github.com:Timbinous/dotfiles.git').should == "Timbinous_dotfiles"
71
+ end
72
+ end
73
+
74
+ context "when containing a random repository name in github" do
75
+ it "returns the username_randomrepository as the folder name" do
76
+ Dotman::Git.folder_name('git@github.com:Timbinous/random.git').should == "Timbinous_random"
77
+ end
78
+ end
79
+ end
49
80
  end
@@ -1,6 +1,6 @@
1
1
  ENV['HOME'] = File.expand_path('../data/home', __FILE__)
2
2
  require 'fakefs/spec_helpers'
3
- require_relative "../lib/dotman"
3
+ require File.expand_path("../../lib/dotman", __FILE__)
4
4
 
5
5
  def create_home_directory
6
6
  FileUtils.mkdir_p(ENV['HOME']) unless File.directory?(ENV['HOME'])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.4
4
+ version: 0.0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-13 00:00:00.000000000 Z
11
+ date: 2013-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler