dottor 0.2.0 → 0.3.0

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.
data/README CHANGED
@@ -32,6 +32,7 @@ can specify a different path) with the following format
32
32
  ```
33
33
 
34
34
  All the actions performed by Dottor are based on the dottor_rules.yml file.
35
+ For some examples, see the [dottor_rules.sample.yml](https://github.com/marcocampana/dottor/blob/master/dottor_rules.sample.yml) file.
35
36
  Check my [dotfiles repo][dotfiles_repo] for a working example.
36
37
 
37
38
 
@@ -0,0 +1,16 @@
1
+ ---
2
+ default:
3
+ - source: vimrc
4
+ target: ~/.vimrc
5
+
6
+ # Targets can resolve to the home directory of the executing user:
7
+ - source: gitconfig
8
+ target: ~/.gitconfig
9
+
10
+ # .. or to a specifc user:
11
+ - source: gitconfig
12
+ target: ~ada/.gitconfig
13
+
14
+ # .. or can be absolute directory references:
15
+ - source: client.rb
16
+ target: /etc/chef/client.rb
@@ -7,6 +7,20 @@ module Dottor
7
7
  @target = hash["target"]
8
8
  end
9
9
 
10
+ # Public: Translate a relative target path to an absolute one
11
+ #
12
+ # Examples
13
+ #
14
+ # dotfile = Dottor::Dotfile.new "source" => "blah", "target" => ".gitconfig"
15
+ # dotfile.target
16
+ # # => '/Users/stevejobs/.gitconfig'
17
+ #
18
+ # Returns the absolute path for the given relative string. If the
19
+ # string is already absolute, return unmodified.
20
+ def target
21
+ @expanded_target ||= File.expand_path(@target, ENV['HOME'])
22
+ end
23
+
10
24
  def create_symlink
11
25
  # If file exists rename it to .old
12
26
  # if File.exists?(target)
@@ -1,3 +1,3 @@
1
1
  module Dottor
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,22 @@
1
+ describe Dottor::Dotfile do
2
+ before(:each) do
3
+ ENV['HOME'] = "/home/stevejobs"
4
+ end
5
+
6
+ describe "#target" do
7
+ it "should leave an absolute filepath as is" do
8
+ dotfile = Dottor::Dotfile.new("source" => "/woot/gitconfig", "target" => "/home/woot/gitconfig")
9
+ dotfile.target.should eq("/home/woot/gitconfig")
10
+ end
11
+
12
+ it "should return a path relative to the user's home directory" do
13
+ dotfile = Dottor::Dotfile.new("source" => "/woot/gitconig", "target" => ".gitconfig")
14
+ dotfile.target.should eq("/home/stevejobs/.gitconfig")
15
+ end
16
+
17
+ it "should substitute the user's home directory for the tilde character, '~'" do
18
+ dotfile = Dottor::Dotfile.new("source" => "/woot/gitconig", "target" => "~/.gitconfig")
19
+ dotfile.target.should eq("/home/stevejobs/.gitconfig")
20
+ end
21
+ end
22
+ 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.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-11 00:00:00.000000000 Z
12
+ date: 2012-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -60,10 +60,12 @@ files:
60
60
  - README.md
61
61
  - bin/dottor
62
62
  - dottor.gemspec
63
+ - dottor_rules.sample.yml
63
64
  - lib/dottor.rb
64
65
  - lib/dottor/dotfile.rb
65
66
  - lib/dottor/version.rb
66
67
  - spec/app_spec.rb
68
+ - spec/dotfile_spec.rb
67
69
  - spec/fixtures/dottor_rules.yml
68
70
  - spec/helpers/utils.rb
69
71
  - spec/spec_helper.rb
@@ -93,6 +95,7 @@ specification_version: 3
93
95
  summary: Command line tool to manage dotfiles the easy way
94
96
  test_files:
95
97
  - spec/app_spec.rb
98
+ - spec/dotfile_spec.rb
96
99
  - spec/fixtures/dottor_rules.yml
97
100
  - spec/helpers/utils.rb
98
101
  - spec/spec_helper.rb