dotman 0.0.3.1 → 0.0.3.2

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: 9ef282bbc9b22112fcaabe4c4c0dc89a08e47356
4
- data.tar.gz: 9bb36932d204047c7bf959e4223b0a74bc191e62
3
+ metadata.gz: ba09c98df605af2940299b8b47265c7654bbbd80
4
+ data.tar.gz: b3f1df8ed7ffc5149b44106aa715e153445a592b
5
5
  SHA512:
6
- metadata.gz: f7e276c0a2f577bf20cbdd72d8746e607911764db53233f7c7a3e563b88a37a64acb5a6949286bbae51f9cbe347d40840edf7e54dc32aed5031202f52c0bd2eb
7
- data.tar.gz: 43922a67d3bf5f21190d965f3b2d5a1c5dcb040f6a56186624681763e13d4e69c238020a38af00710808306ed81e0392a42ae1f3b4925b27921ab4eda5245f11
6
+ metadata.gz: 7737e0f1283d0de789bb5c1b1509dc673615702d9a6faac32f260e316b7f61d88921dd29abccd7410decb1060d5266774f8741c568ab2220472043d78c0db72c
7
+ data.tar.gz: 307dc3144004e4e915c07d4d3636d5c4955b293c5c3933888833df07f8eecd43da4d41956c121283fb3305ad73943c673b8d67de93e8d6f1c0fda0115c4b5c59
data/bin/dot CHANGED
@@ -14,11 +14,19 @@ when 'collect'
14
14
  Dotman::Collect.new.create_dotman
15
15
  when 'list'
16
16
  Dotman::DotfileCollection.show_all_aliases
17
+ when 'alias'
18
+ if ARGV[1] == 'change'
19
+ Dotman::DotfileCollection.change_alias(ARGV[2], ARGV[3])
20
+ elsif ARGV[1] == 'list'
21
+ Dotman::DotfileCollection.show_all_aliases
22
+ end
17
23
  else
18
24
  puts "USAGE:\n
19
- dot clone git_repository alias : clone the dotfiles repo\n
20
- dot use alias : use the dotfiles\n
25
+ dot clone <git_repository> <alias> : clone the dotfiles repo\n
26
+ dot use <alias> : use the dotfiles\n
27
+ dot list : lists all downloaded dotfile aliases\n
21
28
  dot use default : switch to the default dot files\n
22
29
  dot collect : collects all dot files within a directory called dotfiles\n
23
- dot list : lists all downloaded dotfile aliases"
30
+ dot alias change <old alias> <new alias> : changes alias from old to new\n
31
+ dot alias list : same as dot list"
24
32
  end
@@ -36,6 +36,15 @@ DOTFILES_PATH = "#{ENV['HOME']}/.dotman/dotfiles.yml"
36
36
  STDOUT.puts all_aliases.join("\n")
37
37
  end
38
38
 
39
+ def self.change_alias(old_alias, new_alias)
40
+ dotfiles_yaml[new_alias] = dotfiles_yaml[old_alias]
41
+ dotfiles_yaml.delete(old_alias)
42
+ if Dotman::User.current_user_alias == old_alias
43
+ Dotman::User.set_current_user(new_alias)
44
+ end
45
+ save_dotfile_yaml
46
+ end
47
+
39
48
  def all_dotfiles
40
49
  Dir.entries("#{Dotman::Base.dotman_folder}/#{@yaml['folder_name']}").select{|x| x =~ /\.{1}\w+[^git]/ }
41
50
  end
data/lib/dotman/user.rb CHANGED
@@ -57,6 +57,12 @@ module Dotman
57
57
  end
58
58
  end
59
59
 
60
+ def self.set_current_user(alias_name)
61
+ File.open(Dotman::Base.current_dotman, 'w') do |f|
62
+ f.write(alias_name)
63
+ end
64
+ end
65
+
60
66
 
61
67
  def self.current_user_alias
62
68
  File.open(Dotman::Base.current_dotman).read.strip
@@ -1,3 +1,3 @@
1
1
  module Dotman
2
- VERSION = "0.0.3.1"
2
+ VERSION = "0.0.3.2"
3
3
  end
@@ -32,4 +32,38 @@ describe Dotman::DotfileCollection do
32
32
  end
33
33
  end
34
34
  end
35
+
36
+ describe ".change_alias" do
37
+ context "when alias exists" do
38
+ it "adds the alias to the desired new alias name" do
39
+ Dotman::Base.ensure_current_dotman_file_exists
40
+ Dotman::DotfileCollection.change_alias('tim', 'frank')
41
+ YAML::load_file("#{ENV['HOME']}/.dotman/dotfiles.yml").should include('frank')
42
+ end
43
+
44
+ it 'removes the old alias from the yaml file' do
45
+ Dotman::Base.ensure_current_dotman_file_exists
46
+ Dotman::DotfileCollection.change_alias('tim', 'frank')
47
+ YAML::load_file("#{ENV['HOME']}/.dotman/dotfiles.yml").should_not include('tim')
48
+ end
49
+
50
+ context "current user is set to changing alias" do
51
+ it 'sets the current alias to the new name' do
52
+ File.open(Dotman::Base.current_dotman, 'w') { |f| f.write('tim') }
53
+ Dotman::User.current_user_alias.should == 'tim'
54
+ Dotman::DotfileCollection.change_alias('tim', 'frank')
55
+ Dotman::User.current_user_alias.should == 'frank'
56
+ end
57
+ end
58
+
59
+ context "current user is not set to changing alias" do
60
+ it 'does not set the current alias to the new name' do
61
+ File.open(Dotman::Base.current_dotman, 'w') { |f| f.write('default') }
62
+ Dotman::User.current_user_alias.should == 'default'
63
+ Dotman::DotfileCollection.change_alias('tim', 'frank')
64
+ Dotman::User.current_user_alias.should == 'default'
65
+ end
66
+ end
67
+ end
68
+ end
35
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.1
4
+ version: 0.0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim