berkshelf-shims 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -2
- data/lib/berkshelf-shims.rb +4 -1
- data/lib/berkshelf-shims/version.rb +1 -1
- data/spec/berkshelf_shims_spec.rb +25 -10
- metadata +2 -8
data/README.md
CHANGED
@@ -30,10 +30,9 @@ Put the following into spec/spec_helper.rb.
|
|
30
30
|
```ruby
|
31
31
|
require 'berkshelf-shims'
|
32
32
|
|
33
|
-
root_dir = File.join(File.dirname(__FILE__), '..')
|
34
33
|
RSpec.configure do |config|
|
35
34
|
config.before(:suite) do
|
36
|
-
BerkshelfShims::create_shims(
|
35
|
+
BerkshelfShims::create_shims(File.join(File.dirname(__FILE__), '..'))
|
37
36
|
end
|
38
37
|
end
|
39
38
|
```
|
data/lib/berkshelf-shims.rb
CHANGED
@@ -37,6 +37,9 @@ module BerkshelfShims
|
|
37
37
|
|
38
38
|
def create_links(cookbook_dir, berkshelf_path)
|
39
39
|
FileUtils.mkdir_p(cookbook_dir)
|
40
|
+
Dir["#{cookbook_dir}/*"].each do |f|
|
41
|
+
File.delete(f)
|
42
|
+
end
|
40
43
|
cookbooks.each do |name, options|
|
41
44
|
if options[:path]
|
42
45
|
target = options[:path]
|
@@ -46,7 +49,7 @@ module BerkshelfShims
|
|
46
49
|
target = "#{berkshelf_path}/cookbooks/#{name}-#{options[:ref]}"
|
47
50
|
end
|
48
51
|
if target
|
49
|
-
FileUtils.ln_s(target, "#{cookbook_dir}/#{name}"
|
52
|
+
FileUtils.ln_s(target, "#{cookbook_dir}/#{name}")
|
50
53
|
else
|
51
54
|
raise UnknownCookbookReferenceError.new(name, options)
|
52
55
|
end
|
@@ -22,7 +22,7 @@ describe BerkshelfShims do
|
|
22
22
|
let(:test_dir) {'tmp'}
|
23
23
|
let(:lock_file) {"#{test_dir}/Berksfile.lock"}
|
24
24
|
let(:cookbooks_dir) {"#{test_dir}/cookbooks"}
|
25
|
-
let(:relative_target_dir) {
|
25
|
+
let(:relative_target_dir) {File.expand_path("#{test_dir}/relative")}
|
26
26
|
|
27
27
|
before do
|
28
28
|
FileUtils.rm_rf(test_dir)
|
@@ -35,22 +35,37 @@ describe BerkshelfShims do
|
|
35
35
|
end
|
36
36
|
context 'with a normal input' do
|
37
37
|
let(:cookbook_entries) {[
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
"cookbook 'relative', :path => '#{relative_target_dir}'",
|
39
|
+
"cookbook 'versioned', :locked_version => '0.0.1'",
|
40
|
+
"cookbook 'somegitrepo', :git => 'http://github.com/someuser/somegitrepo.git', :ref => '6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a'"
|
41
|
+
]}
|
42
42
|
|
43
43
|
context 'with the default berkshelf path' do
|
44
44
|
before do
|
45
|
+
Dir.mkdir(relative_target_dir)
|
45
46
|
BerkshelfShims::create_shims('tmp')
|
46
47
|
end
|
47
48
|
it 'creates the links' do
|
48
49
|
Dir.exists?(cookbooks_dir).should == true
|
49
50
|
Dir["#{cookbooks_dir}/*"].sort.should == ["#{cookbooks_dir}/relative", "#{cookbooks_dir}/somegitrepo", "#{cookbooks_dir}/versioned"]
|
50
|
-
File.readlink("#{cookbooks_dir}/relative").should ==
|
51
|
+
File.readlink("#{cookbooks_dir}/relative").should == relative_target_dir
|
51
52
|
File.readlink("#{cookbooks_dir}/versioned").should == "#{BerkshelfShims.berkshelf_path}/cookbooks/versioned-0.0.1"
|
52
53
|
File.readlink("#{cookbooks_dir}/somegitrepo").should == "#{BerkshelfShims.berkshelf_path}/cookbooks/somegitrepo-6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a"
|
54
|
+
Dir["#{relative_target_dir}/*"].should == []
|
53
55
|
end
|
56
|
+
context 'run a second time' do
|
57
|
+
before do
|
58
|
+
BerkshelfShims::create_shims('tmp')
|
59
|
+
end
|
60
|
+
it 'creates the links' do
|
61
|
+
Dir.exists?(cookbooks_dir).should == true
|
62
|
+
Dir["#{cookbooks_dir}/*"].sort.should == ["#{cookbooks_dir}/relative", "#{cookbooks_dir}/somegitrepo", "#{cookbooks_dir}/versioned"]
|
63
|
+
File.readlink("#{cookbooks_dir}/relative").should == relative_target_dir
|
64
|
+
File.readlink("#{cookbooks_dir}/versioned").should == "#{BerkshelfShims.berkshelf_path}/cookbooks/versioned-0.0.1"
|
65
|
+
File.readlink("#{cookbooks_dir}/somegitrepo").should == "#{BerkshelfShims.berkshelf_path}/cookbooks/somegitrepo-6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a"
|
66
|
+
Dir["#{relative_target_dir}/*"].should == []
|
67
|
+
end
|
68
|
+
end
|
54
69
|
end
|
55
70
|
|
56
71
|
context 'with an explicit berkshelf path' do
|
@@ -60,7 +75,7 @@ describe BerkshelfShims do
|
|
60
75
|
it 'creates the links' do
|
61
76
|
Dir.exists?(cookbooks_dir).should == true
|
62
77
|
Dir["#{cookbooks_dir}/*"].sort.should == ["#{cookbooks_dir}/relative", "#{cookbooks_dir}/somegitrepo", "#{cookbooks_dir}/versioned"]
|
63
|
-
File.readlink("#{cookbooks_dir}/relative").should ==
|
78
|
+
File.readlink("#{cookbooks_dir}/relative").should == relative_target_dir
|
64
79
|
File.readlink("#{cookbooks_dir}/versioned").should == "berkshelf/cookbooks/versioned-0.0.1"
|
65
80
|
File.readlink("#{cookbooks_dir}/somegitrepo").should == "berkshelf/cookbooks/somegitrepo-6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a"
|
66
81
|
end
|
@@ -74,7 +89,7 @@ describe BerkshelfShims do
|
|
74
89
|
it 'creates the links' do
|
75
90
|
Dir.exists?(cookbooks_dir).should == true
|
76
91
|
Dir["#{cookbooks_dir}/*"].sort.should == ["#{cookbooks_dir}/relative", "#{cookbooks_dir}/somegitrepo", "#{cookbooks_dir}/versioned"]
|
77
|
-
File.readlink("#{cookbooks_dir}/relative").should ==
|
92
|
+
File.readlink("#{cookbooks_dir}/relative").should == relative_target_dir
|
78
93
|
File.readlink("#{cookbooks_dir}/versioned").should == "/berkshelf_env/cookbooks/versioned-0.0.1"
|
79
94
|
File.readlink("#{cookbooks_dir}/somegitrepo").should == "/berkshelf_env/cookbooks/somegitrepo-6ffb9cf5ddee65b8c208dec5c7b1ca9a4259b86a"
|
80
95
|
end
|
@@ -83,8 +98,8 @@ describe BerkshelfShims do
|
|
83
98
|
|
84
99
|
context 'with an unknown cookbook reference' do
|
85
100
|
let(:cookbook_entries) {[
|
86
|
-
|
87
|
-
|
101
|
+
"cookbook 'relative'"
|
102
|
+
]}
|
88
103
|
it 'throws an error' do
|
89
104
|
expect {BerkshelfShims::create_shims('tmp')}.to raise_error BerkshelfShims::UnknownCookbookReferenceError
|
90
105
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berkshelf-shims
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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: 2013-
|
12
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Shim functionality for Berkshelf
|
15
15
|
email:
|
@@ -43,18 +43,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
hash: 4057482081012609309
|
49
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
47
|
none: false
|
51
48
|
requirements:
|
52
49
|
- - ! '>='
|
53
50
|
- !ruby/object:Gem::Version
|
54
51
|
version: '0'
|
55
|
-
segments:
|
56
|
-
- 0
|
57
|
-
hash: 4057482081012609309
|
58
52
|
requirements: []
|
59
53
|
rubyforge_project:
|
60
54
|
rubygems_version: 1.8.23
|