dotman 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +27 -2
- data/bin/dot +2 -0
- data/lib/dotman.rb +3 -1
- data/lib/dotman/base.rb +0 -4
- data/lib/dotman/dotfile_collection.rb +14 -13
- data/lib/dotman/git.rb +4 -0
- data/lib/dotman/version.rb +1 -1
- data/spec/data/{dotfiles/.bashrc → home/.gitkeep} +0 -0
- data/spec/dotman/base_spec.rb +0 -30
- data/spec/dotman/dotfile_collection_spec.rb +30 -0
- data/spec/integration/dotfile_collection_integration_spec.rb +6 -1
- data/spec/integration/git_integration_spec.rb +0 -3
- data/spec/integration/user_integration_spec.rb +13 -17
- data/spec/spec_helper.rb +15 -1
- metadata +4 -10
- data/spec/data/dotfiles/.vimrc +0 -0
- data/spec/data/dotfiles/.zshrc +0 -0
- data/spec/data/dotfiles/some_nondot_file +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3b731737f17c1671451e5b4e769a1004456e586
|
4
|
+
data.tar.gz: 8f7301a47b9dbf857eb18eda8d255aa417d097f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d64c527bb313c8f0d147fd8a1ca5300c7bee05847eb97c0e9af35bee42579fce0ea67aa28f85e6ab679bece1208827b4c7b38ff773fa7f3bb7865cc10c31980e
|
7
|
+
data.tar.gz: 18f2b801b2ebc9e12d496596bef8fbc88ffad4029187601fadb4afe594999c008a264ca15336a637be86a232c2672816960e6724c618e125f61d537fc3cefab2
|
data/README.md
CHANGED
@@ -1,8 +1,33 @@
|
|
1
1
|
# Dotman
|
2
2
|
|
3
|
-
This is a work in progress.
|
3
|
+
This is a work in progress.
|
4
4
|
|
5
|
-
This gem will
|
5
|
+
This gem will allows you to switch between different dotfiles on the same user account.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'dotman'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install dotman
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
To retrieve your dotfiles and store them
|
24
|
+
dot clone your\_dotfiles\_repo alias
|
25
|
+
|
26
|
+
To use cloned dotfiles
|
27
|
+
dot use alias
|
28
|
+
|
29
|
+
To revert dotfiles back to original
|
30
|
+
dot use default
|
6
31
|
|
7
32
|
## Contributing
|
8
33
|
|
data/bin/dot
CHANGED
@@ -10,4 +10,6 @@ when 'clone'
|
|
10
10
|
Dotman::Git.klone(ARGV[1], ARGV[2])
|
11
11
|
when 'use'
|
12
12
|
Dotman::User.set(ARGV[1])
|
13
|
+
else
|
14
|
+
puts "USAGE:\ndot clone git_repository alias : clone the dotfiles repo\ndot use alias : use the dotfiles\ndot use default : switch to the default dot files"
|
13
15
|
end
|
data/lib/dotman.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require "dotman/version"
|
3
3
|
require "dotman/base"
|
4
|
+
Dotman::Base.ensure_dotman_folder_exists
|
5
|
+
Dotman::Base.ensure_default_folder_exists
|
6
|
+
Dotman::Base.ensure_current_dotman_file_exists
|
4
7
|
require "dotman/git"
|
5
8
|
require "dotman/dotfile_collection"
|
6
9
|
require "dotman/user"
|
7
|
-
|
data/lib/dotman/base.rb
CHANGED
@@ -1,46 +1,47 @@
|
|
1
1
|
module Dotman
|
2
2
|
|
3
3
|
DOTFILES_PATH = "#{ENV['HOME']}/.dotman/dotfiles.yml"
|
4
|
-
DOTFILES_YAML = File.exist?(DOTFILES_PATH) ? YAML::load_file(DOTFILES_PATH) : Hash.new
|
5
4
|
|
6
5
|
class DotfileCollection
|
7
6
|
|
7
|
+
def initialize(yaml)
|
8
|
+
@yaml = yaml
|
9
|
+
end
|
10
|
+
|
8
11
|
attr_accessor :yaml
|
9
12
|
|
13
|
+
def self.dotfiles_yaml
|
14
|
+
@dotfiles_yaml ||= File.exist?(DOTFILES_PATH) ? YAML::load_file(DOTFILES_PATH) : Hash.new
|
15
|
+
end
|
16
|
+
|
10
17
|
def self.find_by_alias(alias_name)
|
11
|
-
dotfile_collection = new
|
12
18
|
ensure_default_dotfile_configuration_exists
|
13
|
-
|
14
|
-
dotfile_collection
|
19
|
+
new(dotfiles_yaml.fetch(alias_name))
|
15
20
|
end
|
16
21
|
|
17
22
|
def self.new_configuration(folder_name, alias_name = nil)
|
18
|
-
dotfile_collection = new
|
19
23
|
alias_name = folder_name unless alias_name
|
20
|
-
|
24
|
+
dotfiles_yaml.store(alias_name, {
|
21
25
|
'folder_name' => folder_name
|
22
|
-
}
|
23
|
-
)
|
26
|
+
})
|
24
27
|
save_dotfile_yaml
|
25
|
-
dotfile_collection.yaml = DOTFILES_YAML
|
26
|
-
dotfile_collection
|
27
28
|
end
|
28
29
|
|
29
30
|
|
30
31
|
def all_dotfiles
|
31
|
-
Dir.entries("#{Dotman::Base.dotman_folder}/#{@yaml['folder_name']}").select{|x| x =~ /\.{1}\w
|
32
|
+
Dir.entries("#{Dotman::Base.dotman_folder}/#{@yaml['folder_name']}").select{|x| x =~ /\.{1}\w+[^git]/ }
|
32
33
|
end
|
33
34
|
|
34
35
|
private
|
35
36
|
|
36
37
|
def self.ensure_default_dotfile_configuration_exists
|
37
|
-
unless
|
38
|
+
unless dotfiles_yaml && dotfiles_yaml['default']
|
38
39
|
new_configuration('default')
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
43
|
def self.save_dotfile_yaml
|
43
|
-
File.open(DOTFILES_PATH, 'w') { |f| f.write
|
44
|
+
File.open(DOTFILES_PATH, 'w') { |f| f.write dotfiles_yaml.to_yaml }
|
44
45
|
end
|
45
46
|
|
46
47
|
end
|
data/lib/dotman/git.rb
CHANGED
@@ -2,6 +2,10 @@ module Dotman
|
|
2
2
|
class Git
|
3
3
|
def self.klone(git_location, alias_name = nil)
|
4
4
|
unless git_location.nil?
|
5
|
+
Dotman::Base.ensure_dotman_folder_exists
|
6
|
+
puts "ENSURING DOTMAN FOLDER EXISTS"
|
7
|
+
Dotman::Base.ensure_default_folder_exists
|
8
|
+
Dotman::Base.ensure_current_dotman_file_exists
|
5
9
|
clone_repository(git_location, alias_name)
|
6
10
|
end
|
7
11
|
end
|
data/lib/dotman/version.rb
CHANGED
File without changes
|
data/spec/dotman/base_spec.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
describe Dotman::Base do
|
3
|
-
let (:dotfiles_folder) { File.expand_path('../../data/dotfiles', __FILE__) }
|
4
|
-
let!(:dotfiles) {FileUtils.touch "#{dotfiles_folder}/.vimrc"; FileUtils.touch "#{dotfiles_folder}/.bashrc"; FileUtils.touch "#{dotfiles_folder}/.zshrc" }
|
5
3
|
|
6
4
|
describe ".ensure_dotman_folder_exists" do
|
7
5
|
context "when `$HOME.dotman/` does not exist" do
|
@@ -20,32 +18,4 @@ describe Dotman::Base do
|
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
23
|
-
|
24
|
-
describe ".all_dotfiles" do
|
25
|
-
context "when dotfiles exist for a location" do
|
26
|
-
|
27
|
-
it "returns all the dotfiles" do
|
28
|
-
Dotman::Base.all_dotfiles(dotfiles_folder).should include('.vimrc', '.bashrc', '.zshrc')
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should not contain . or .." do
|
32
|
-
Dotman::Base.all_dotfiles(dotfiles_folder).should_not include('..', '.')
|
33
|
-
end
|
34
|
-
|
35
|
-
it "does not contain non dotfiles" do
|
36
|
-
Dotman::Base.all_dotfiles(dotfiles_folder).should_not include('some_nondot_file')
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe ".move_home_files_to_default" do
|
43
|
-
context "when having dotfiles in project" do
|
44
|
-
it "moves the files" do
|
45
|
-
Dotman::Base.move_home_files_to_default(dotfiles_folder)
|
46
|
-
Dir.entries(Dotman::Base.default_folder).should include('.vimrc', '.bashrc', '.zshrc')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
21
|
end
|
@@ -7,4 +7,34 @@ describe Dotman::DotfileCollection do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
10
|
+
|
11
|
+
describe ".all_dotfiles" do
|
12
|
+
let (:dotfile_collection) { Dotman::DotfileCollection.new(Hash.new) }
|
13
|
+
|
14
|
+
before :each do
|
15
|
+
Dir.stub(:entries).and_return(['some_nondot_file', '.gitignore', '.gitconfig', '.vimrc', '.bashrc', '.zshrc', '..', '.', '.git'])
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when dotfiles exist for a location" do
|
19
|
+
it "returns all the dotfiles" do
|
20
|
+
dotfile_collection.all_dotfiles.should include('.vimrc', '.bashrc', '.zshrc')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should not contain . or .." do
|
24
|
+
dotfile_collection.all_dotfiles.should_not include('..', '.')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "does not contain non dotfiles" do
|
28
|
+
dotfile_collection.all_dotfiles.should_not include('some_nondot_file')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'excludes .git' do
|
32
|
+
dotfile_collection.all_dotfiles.should_not include('.git')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'includes .gitignore' do
|
36
|
+
dotfile_collection.all_dotfiles.should include('.gitignore')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
10
40
|
end
|
@@ -1,16 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
describe Dotman::DotfileCollection do
|
3
|
+
before :all do
|
4
|
+
Dotman::Git.clone_repository('git@github.com:Timbinous/dotfiles.git', 'tim')
|
5
|
+
end
|
6
|
+
|
3
7
|
describe ".find_by_alias" do
|
4
8
|
context "when dotfile collection is found" do
|
5
9
|
let (:alias_name) { 'tim' }
|
6
10
|
let (:dotfile_collection_name) { 'Timbinous_dotfiles' }
|
7
11
|
let! (:dotfile_configuration) { Dotman::DotfileCollection.new_configuration(dotfile_collection_name, alias_name) }
|
8
12
|
it "returns the dotfile collection" do
|
9
|
-
Dotman::DotfileCollection.find_by_alias(alias_name)
|
13
|
+
Dotman::DotfileCollection.find_by_alias(alias_name).should be_an_instance_of(Dotman::DotfileCollection)
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
13
17
|
after :all do
|
14
18
|
FileUtils.rm_r("#{ENV['HOME']}/.dotman/dotfiles.yml")
|
19
|
+
FileUtils.rm_rf("#{ENV['HOME']}/.dotman/Timbinous_dotfiles")
|
15
20
|
end
|
16
21
|
end
|
@@ -1,5 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
describe Dotman::User do
|
3
|
+
let (:tim) { Dotman::User.new('tim') }
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
Dotman::Git.clone_repository("git@github.com:Timbinous/dotfiles.git", 'tim')
|
7
|
+
end
|
8
|
+
|
3
9
|
describe ".current_user_alias" do
|
4
10
|
before :all do
|
5
11
|
File.open(Dotman::Base.current_dotman, 'w') { |f| f.write 'tim' }
|
@@ -11,15 +17,10 @@ describe Dotman::User do
|
|
11
17
|
end
|
12
18
|
|
13
19
|
describe "#set_current_user" do
|
14
|
-
let (:user) { Dotman::User.new('frank') }
|
15
|
-
|
16
|
-
before :all do
|
17
|
-
Dotman::DotfileCollection.new_configuration('frankie_dotfiles', 'frank')
|
18
|
-
end
|
19
20
|
|
20
21
|
it 'writes to the .current file, the alias of the current user' do
|
21
|
-
|
22
|
-
Dotman::User.current_user_alias.should == '
|
22
|
+
tim.set_current_user
|
23
|
+
Dotman::User.current_user_alias.should == 'tim'
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -27,15 +28,17 @@ describe Dotman::User do
|
|
27
28
|
describe ".current" do
|
28
29
|
|
29
30
|
it 'returns the current users information' do
|
30
|
-
|
31
|
+
tim.set_current_user
|
32
|
+
Dotman::User.current.folder_name.should == 'Timbinous_dotfiles'
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
36
|
describe "#set" do
|
35
37
|
|
36
|
-
before :
|
37
|
-
|
38
|
+
before :all do
|
39
|
+
$default_user.set_current_user
|
38
40
|
FileUtils.touch(["#{ENV['HOME']}/.vimrc", "#{ENV['HOME']}/.zshrc", "#{ENV['HOME']}/.bashrc"])
|
41
|
+
FileUtils.mkdir("#{ENV['HOME']}/.dotman/default")
|
39
42
|
Dotman::User.set('tim')
|
40
43
|
end
|
41
44
|
|
@@ -51,12 +54,5 @@ describe Dotman::User do
|
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
54
|
-
after :each do
|
55
|
-
FileUtils.rm_r("#{ENV['HOME']}/.dotman/dotfiles.yml")
|
56
|
-
FileUtils.rm_rf("#{ENV['HOME']}/.dotman/Timbinous_dotfiles")
|
57
|
-
$default_user.collection.all_dotfiles.each do |df|
|
58
|
-
FileUtils.rm("#{ENV['HOME']}/.dotman/default/#{df}")
|
59
|
-
end
|
60
|
-
end
|
61
57
|
end
|
62
58
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,16 @@
|
|
1
1
|
ENV['HOME'] = File.expand_path('../data/home', __FILE__)
|
2
|
-
|
2
|
+
require 'fileutils'
|
3
|
+
require_relative "../lib/dotman"
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
|
7
|
+
config.after(:all) do
|
8
|
+
FileUtils.rm_rf(File.join(ENV['HOME'], '.dotman')) if File.directory? (File.join(ENV['HOME'], '.dotman'))
|
9
|
+
FileUtils.rm(File.join(ENV['HOME'], '.bashrc')) if File.symlink? (File.join(ENV['HOME'], '.bashrc'))
|
10
|
+
FileUtils.rm(File.join(ENV['HOME'], '.gitignore')) if File.symlink? (File.join(ENV['HOME'], '.gitignore'))
|
11
|
+
FileUtils.rm(File.join(ENV['HOME'], '.tmux.conf')) if File.symlink? (File.join(ENV['HOME'], '.tmux.conf'))
|
12
|
+
FileUtils.rm(File.join(ENV['HOME'], '.vim')) if File.symlink? (File.join(ENV['HOME'], '.vim'))
|
13
|
+
FileUtils.rm(File.join(ENV['HOME'], '.vimrc')) if File.symlink? (File.join(ENV['HOME'], '.vimrc'))
|
14
|
+
FileUtils.rm(File.join(ENV['HOME'], '.zshrc')) if File.symlink? (File.join(ENV['HOME'], '.zshrc'))
|
15
|
+
end
|
16
|
+
end
|
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.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05
|
11
|
+
date: 2013-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -88,10 +88,7 @@ files:
|
|
88
88
|
- lib/dotman/git.rb
|
89
89
|
- lib/dotman/user.rb
|
90
90
|
- lib/dotman/version.rb
|
91
|
-
- spec/data/
|
92
|
-
- spec/data/dotfiles/.vimrc
|
93
|
-
- spec/data/dotfiles/.zshrc
|
94
|
-
- spec/data/dotfiles/some_nondot_file
|
91
|
+
- spec/data/home/.gitkeep
|
95
92
|
- spec/dotman/base_spec.rb
|
96
93
|
- spec/dotman/dotfile_collection_spec.rb
|
97
94
|
- spec/dotman_spec.rb
|
@@ -127,10 +124,7 @@ specification_version: 4
|
|
127
124
|
summary: Use this utility to manage your dotfiles and others who may use the same
|
128
125
|
login user as yourself
|
129
126
|
test_files:
|
130
|
-
- spec/data/
|
131
|
-
- spec/data/dotfiles/.vimrc
|
132
|
-
- spec/data/dotfiles/.zshrc
|
133
|
-
- spec/data/dotfiles/some_nondot_file
|
127
|
+
- spec/data/home/.gitkeep
|
134
128
|
- spec/dotman/base_spec.rb
|
135
129
|
- spec/dotman/dotfile_collection_spec.rb
|
136
130
|
- spec/dotman_spec.rb
|
data/spec/data/dotfiles/.vimrc
DELETED
File without changes
|
data/spec/data/dotfiles/.zshrc
DELETED
File without changes
|
File without changes
|