dottor 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
1
  source "http://rubygems.org"
2
- gem "thor"
3
- gem "rspec"
2
+
3
+ group :development do
4
+ gem "thor"
5
+ gem "rspec"
6
+ end
data/README ADDED
@@ -0,0 +1,75 @@
1
+ Dottor
2
+ ======
3
+
4
+ Description
5
+ -----------
6
+ Dottor is an unobtrusive command line tool for easily managing your dotfiles,
7
+ without assumptions on how your dotfiles repository should be organized.
8
+
9
+ Why Dottor?
10
+ -----------
11
+ I designed dottor so that it would be easy to setup and use, reliable and work
12
+ with existing dotfiles repos.
13
+
14
+ With Dottor you can:
15
+
16
+ 1. Get started with yout current dotfils repo, without changing anything.
17
+ 2. Specify different profiles, so that you can use it to symlink files in your
18
+ dev machine as well as in your production boxes.
19
+
20
+ How it works?
21
+ -------------
22
+
23
+ Dottor expect to find in your repo a YAML file named dottor_rules.yml (or you
24
+ can specify a different path) with the following format
25
+
26
+ ```ruby
27
+ profile_name:
28
+ - source: <dotffile or directory>
29
+ target: <where do you want the file to be symlinked to>
30
+ - source: <dotffile or directory>
31
+ target: <where do you want the file to be symlinked to>
32
+ ```
33
+
34
+ All the actions performed by Dottor are based on the dottor_rules.yml file.
35
+ Check my [dotfiles repo][dotfiles_repo] for a working example.
36
+
37
+
38
+ Getting started
39
+ ---------------
40
+
41
+ gem install dottor
42
+
43
+ ### Create a dottor_rules.yml inside your dotfiles repo
44
+
45
+ dottor init
46
+
47
+ ### Create symlinks based on dottor_rules.yml file in current directory
48
+
49
+ dottor symlink <profile_name>
50
+
51
+ ### Specify a dottor_rules.yml file in another directory
52
+
53
+ dottor symlink <profile_name> -f <custom_path>
54
+
55
+ ### Delete all the symlinks
56
+
57
+ dottor symlink -d
58
+
59
+ Submitting a Pull Request
60
+ -------------------------
61
+
62
+ 1. Fork the project.
63
+ 2. Create a topic branch.
64
+ 3. Implement your feature or bug fix.
65
+ 4. Add documentation for your feature or bug fix.
66
+ 6. Add specs for your feature or bug fix.
67
+ 8. Commit and push your changes.
68
+
69
+ License
70
+ -------
71
+ Released under the MIT License. See the [LICENSE][license] file for further
72
+ details.
73
+
74
+ [license]: https://github.com/marcocampana/dottor/blob/master/LICENSE.md
75
+ [dotfiles_repo]: https://github.com/marcocampana/dotfiles
@@ -14,6 +14,12 @@ module Dottor
14
14
  say("Loading rules YAML file")
15
15
  rules = YAML::load(yaml_rules)
16
16
 
17
+ if rules[profile_name].nil?
18
+ $stderr.puts("Error: Profile name not found. Make sure that your dottor_rules yaml file define the profile #{profile_name}")
19
+ # exit(1)
20
+ return
21
+ end
22
+
17
23
  rules[profile_name].each do |mapping|
18
24
  dotfile = Dotfile.new(mapping)
19
25
  if options[:delete]
@@ -31,7 +37,7 @@ module Dottor
31
37
  if options[:force]
32
38
  FileUtils.rm 'dottor_rules.yml'
33
39
  else
34
- say("Abort: dottor_rules.yml already exist. Use the --force to overwrite.")
40
+ say("Error: dottor_rules.yml already exist. Use the --force to overwrite.")
35
41
  exit(1)
36
42
  end
37
43
  end
@@ -9,19 +9,18 @@ module Dottor
9
9
 
10
10
  def create_symlink
11
11
  # If file exists rename it to .old
12
- # TODO check if .old file already exists
13
- if File.exists?(target)
14
- old_file_name = "#{target}.old"
15
- FileUtils.mv target, old_file_name
16
- end
12
+ # if File.exists?(target)
13
+ # old_file_name = "#{target}.old"
14
+ # FileUtils.mv(target, old_file_name) unless File.exists?(old_file_name)
15
+ # end
17
16
 
18
17
  # If symlink exists, remove it
19
- if File.symlink?(target)
18
+ if File.exists?(target) || File.symlink?(target)
20
19
  FileUtils.rm target
21
20
  end
22
21
 
23
22
  $stdout.puts("Create symlink #{File.join(current_path, source)} -> #{target}")
24
- FileUtils.symlink File.join(current_path, source), target
23
+ FileUtils.symlink(File.join(current_path, source), target)
25
24
  end
26
25
 
27
26
  def delete_symlink
@@ -1,3 +1,3 @@
1
1
  module Dottor
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Dottor::App" do
4
- describe "symlink" do
4
+ describe "#symlink" do
5
5
  it "should use the dottor_rules.yml in current directory by default" do
6
6
  stub_dottor_rules_file('dottor_rules.yml')
7
7
  stub_dotfile
@@ -22,5 +22,13 @@ describe "Dottor::App" do
22
22
 
23
23
  Dottor::App.start(['symlink', 'development'])
24
24
  end
25
+
26
+ it "should return an error message if profile_name is not found" do
27
+ stub_dottor_rules_file('dottor_rules.yml')
28
+
29
+ capture(:stderr) {
30
+ Dottor::App.start(['symlink', 'not_defined_profile_name'])
31
+ }.should =~ /Error: Profile name not found/
32
+ end
25
33
  end
26
34
  end
@@ -10,6 +10,19 @@ RSpec.configure do |c|
10
10
  c.mock_with :rspec
11
11
 
12
12
  c.before(:each) do
13
- STDOUT.should_receive(:puts).and_return("")
13
+ # STDOUT.should_receive(:puts).at_least(1).times.and_return("")
14
+ end
15
+
16
+ def capture(stream)
17
+ begin
18
+ stream = stream.to_s
19
+ eval "$#{stream} = StringIO.new"
20
+ yield
21
+ result = eval("$#{stream}").string
22
+ ensure
23
+ eval("$#{stream} = #{stream.upcase}")
24
+ end
25
+
26
+ result
14
27
  end
15
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dottor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-15 00:00:00.000000000 Z
12
+ date: 2012-08-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70257029527160 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70257029527160
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &70257029524660 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70257029524660
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: Unobtrusive command line tool for easily managing your dotfiles, without
37
47
  assumptions on how your dotfiles repository should be organized.
38
48
  email:
@@ -46,6 +56,7 @@ files:
46
56
  - Gemfile
47
57
  - Gemfile.lock
48
58
  - LICENSE.md
59
+ - README
49
60
  - README.md
50
61
  - bin/dottor
51
62
  - dottor.gemspec
@@ -76,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
87
  version: '0'
77
88
  requirements: []
78
89
  rubyforge_project: dottor
79
- rubygems_version: 1.8.15
90
+ rubygems_version: 1.8.24
80
91
  signing_key:
81
92
  specification_version: 3
82
93
  summary: Command line tool to manage dotfiles the easy way
@@ -85,4 +96,3 @@ test_files:
85
96
  - spec/fixtures/dottor_rules.yml
86
97
  - spec/helpers/utils.rb
87
98
  - spec/spec_helper.rb
88
- has_rdoc: