librarian 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.travis.yml +7 -1
  2. data/CHANGELOG.md +19 -1
  3. data/README.md +2 -9
  4. data/Rakefile +0 -11
  5. data/lib/librarian.rb +0 -8
  6. data/lib/librarian/action/base.rb +6 -4
  7. data/lib/librarian/chef/cli.rb +1 -1
  8. data/lib/librarian/chef/integration/knife.rb +4 -0
  9. data/lib/librarian/chef/manifest_reader.rb +14 -2
  10. data/lib/librarian/chef/source/local.rb +2 -0
  11. data/lib/librarian/chef/source/site.rb +49 -41
  12. data/lib/librarian/cli.rb +32 -17
  13. data/lib/librarian/dependency.rb +1 -9
  14. data/lib/librarian/dsl.rb +6 -3
  15. data/lib/librarian/dsl/receiver.rb +10 -12
  16. data/lib/librarian/dsl/target.rb +5 -10
  17. data/lib/librarian/environment.rb +41 -2
  18. data/lib/librarian/lockfile.rb +0 -4
  19. data/lib/librarian/lockfile/compiler.rb +0 -4
  20. data/lib/librarian/lockfile/parser.rb +0 -4
  21. data/lib/librarian/logger.rb +46 -0
  22. data/lib/librarian/manifest.rb +1 -9
  23. data/lib/librarian/resolution.rb +5 -3
  24. data/lib/librarian/resolver.rb +6 -1
  25. data/lib/librarian/resolver/implementation.rb +18 -8
  26. data/lib/librarian/source/git.rb +2 -0
  27. data/lib/librarian/source/git/repository.rb +9 -5
  28. data/lib/librarian/source/local.rb +12 -2
  29. data/lib/librarian/spec.rb +4 -4
  30. data/lib/librarian/spec_change_set.rb +7 -4
  31. data/lib/librarian/specfile.rb +3 -8
  32. data/lib/librarian/version.rb +1 -1
  33. data/librarian.gemspec +3 -9
  34. data/spec/functional/chef/cli_spec.rb +194 -0
  35. data/spec/functional/chef/source/site_spec.rb +11 -10
  36. data/spec/functional/source/git/repository_spec.rb +1 -1
  37. data/spec/support/cli_macro.rb +122 -0
  38. data/spec/support/with_env_macro.rb +20 -0
  39. data/spec/unit/config/database_spec.rb +2 -2
  40. data/spec/unit/dependency_spec.rb +6 -0
  41. data/spec/unit/dsl_spec.rb +16 -37
  42. data/spec/unit/environment_spec.rb +95 -0
  43. data/spec/unit/manifest_spec.rb +6 -0
  44. data/spec/unit/resolver_spec.rb +41 -0
  45. metadata +7 -42
  46. data/config/cucumber.yaml +0 -1
  47. data/features/chef/cli/init.feature +0 -11
  48. data/features/chef/cli/install.feature +0 -64
  49. data/features/chef/cli/show.feature +0 -77
  50. data/features/chef/cli/version.feature +0 -11
  51. data/features/support/env.rb +0 -9
  52. data/lib/librarian/helpers/debug.rb +0 -35
@@ -0,0 +1,20 @@
1
+ module WithEnvMacro
2
+
3
+ module ClassMethods
4
+
5
+ def with_env(new)
6
+ old = Hash[new.map{|k, v| [k, ENV[k]]}]
7
+
8
+ before { ENV.update(new) }
9
+ after { ENV.update(old) }
10
+ end
11
+
12
+ end
13
+
14
+ private
15
+
16
+ def self.included(base)
17
+ base.extend(ClassMethods)
18
+ end
19
+
20
+ end
@@ -10,8 +10,8 @@ describe Librarian::Config::Database do
10
10
  include FakeFS::SpecHelpers
11
11
 
12
12
  def write_yaml!(path, *yamlables)
13
- dir = File.dirname(path)
14
- FileUtils.mkpath(dir) unless File.directory?(dir)
13
+ path = Pathname(path)
14
+ path.dirname.mkpath unless path.dirname.directory?
15
15
  File.open(path, "wb"){|f| yamlables.each{|y| YAML.dump(y, f)}}
16
16
  end
17
17
 
@@ -25,6 +25,12 @@ describe Librarian::Dependency do
25
25
  end
26
26
  end
27
27
 
28
+ context "when the name is a single character" do
29
+ it "passes" do
30
+ described_class.new("R", [], nil)
31
+ end
32
+ end
33
+
28
34
  end
29
35
 
30
36
  end
@@ -19,27 +19,6 @@ module Librarian
19
19
  end
20
20
  end
21
21
 
22
- context "a single dependency but no applicable source" do
23
-
24
- it "should not run without any sources" do
25
- expect do
26
- env.dsl do
27
- dep 'dependency-1'
28
- end
29
- end.to raise_error(Dsl::Error)
30
- end
31
-
32
- it "should not run when a block source is defined but the dependency is outside the block" do
33
- expect do
34
- env.dsl do
35
- src 'source-1' do end
36
- dep 'dependency-1'
37
- end
38
- end.to raise_error(Dsl::Error)
39
- end
40
-
41
- end
42
-
43
22
  context "a simple specfile - a single source, a single dependency, no transitive dependencies" do
44
23
 
45
24
  it "should run with a hash source" do
@@ -50,7 +29,7 @@ module Librarian
50
29
  spec.dependencies.should_not be_empty
51
30
  spec.dependencies.first.name.should == 'dependency-1'
52
31
  spec.dependencies.first.source.name.should == 'source-1'
53
- spec.source.should be_nil
32
+ spec.sources.should be_empty
54
33
  end
55
34
 
56
35
  it "should run with a shortcut source" do
@@ -61,7 +40,7 @@ module Librarian
61
40
  spec.dependencies.should_not be_empty
62
41
  spec.dependencies.first.name.should == 'dependency-1'
63
42
  spec.dependencies.first.source.name.should == 'source-a'
64
- spec.source.should be_nil
43
+ spec.sources.should be_empty
65
44
  end
66
45
 
67
46
  it "should run with a block hash source" do
@@ -73,7 +52,7 @@ module Librarian
73
52
  spec.dependencies.should_not be_empty
74
53
  spec.dependencies.first.name.should == 'dependency-1'
75
54
  spec.dependencies.first.source.name.should == 'source-1'
76
- spec.source.should be_nil
55
+ spec.sources.should be_empty
77
56
  end
78
57
 
79
58
  it "should run with a block named source" do
@@ -85,7 +64,7 @@ module Librarian
85
64
  spec.dependencies.should_not be_empty
86
65
  spec.dependencies.first.name.should == 'dependency-1'
87
66
  spec.dependencies.first.source.name.should == 'source-1'
88
- spec.source.should be_nil
67
+ spec.sources.should be_empty
89
68
  end
90
69
 
91
70
  it "should run with a default hash source" do
@@ -96,8 +75,8 @@ module Librarian
96
75
  spec.dependencies.should_not be_empty
97
76
  spec.dependencies.first.name.should == 'dependency-1'
98
77
  spec.dependencies.first.source.name.should == 'source-1'
99
- spec.source.should_not be_nil
100
- spec.dependencies.first.source.should == spec.source
78
+ spec.sources.should_not be_empty
79
+ spec.dependencies.first.source.should == spec.sources.first
101
80
  end
102
81
 
103
82
  it "should run with a default named source" do
@@ -108,8 +87,8 @@ module Librarian
108
87
  spec.dependencies.should_not be_empty
109
88
  spec.dependencies.first.name.should == 'dependency-1'
110
89
  spec.dependencies.first.source.name.should == 'source-1'
111
- spec.source.should_not be_nil
112
- spec.dependencies.first.source.should == spec.source
90
+ spec.sources.should_not be_empty
91
+ spec.dependencies.first.source.should == spec.sources.first
113
92
  end
114
93
 
115
94
  it "should run with a default shortcut source" do
@@ -120,8 +99,8 @@ module Librarian
120
99
  spec.dependencies.should_not be_empty
121
100
  spec.dependencies.first.name.should == 'dependency-1'
122
101
  spec.dependencies.first.source.name.should == 'source-a'
123
- spec.source.should_not be_nil
124
- spec.dependencies.first.source.should == spec.source
102
+ spec.sources.should_not be_empty
103
+ spec.dependencies.first.source.should == spec.sources.first
125
104
  end
126
105
 
127
106
  it "should run with a shortcut source hash definition" do
@@ -132,7 +111,7 @@ module Librarian
132
111
  spec.dependencies.should_not be_empty
133
112
  spec.dependencies.first.name.should == 'dependency-1'
134
113
  spec.dependencies.first.source.name.should == 'source-b'
135
- spec.source.should be_nil
114
+ spec.sources.should be_empty
136
115
  end
137
116
 
138
117
  it "should run with a shortcut source block definition" do
@@ -143,7 +122,7 @@ module Librarian
143
122
  spec.dependencies.should_not be_empty
144
123
  spec.dependencies.first.name.should == 'dependency-1'
145
124
  spec.dependencies.first.source.name.should == 'source-b'
146
- spec.source.should be_nil
125
+ spec.sources.should be_empty
147
126
  end
148
127
 
149
128
  it "should run with a default shortcut source hash definition" do
@@ -155,8 +134,8 @@ module Librarian
155
134
  spec.dependencies.should_not be_empty
156
135
  spec.dependencies.first.name.should == 'dependency-1'
157
136
  spec.dependencies.first.source.name.should == 'source-b'
158
- spec.source.should_not be_nil
159
- spec.source.name.should == 'source-b'
137
+ spec.sources.should_not be_empty
138
+ spec.sources.first.name.should == 'source-b'
160
139
  end
161
140
 
162
141
  it "should run with a default shortcut source block definition" do
@@ -168,8 +147,8 @@ module Librarian
168
147
  spec.dependencies.should_not be_empty
169
148
  spec.dependencies.first.name.should == 'dependency-1'
170
149
  spec.dependencies.first.source.name.should == 'source-b'
171
- spec.source.should_not be_nil
172
- spec.source.name.should == 'source-b'
150
+ spec.sources.should_not be_empty
151
+ spec.sources.first.name.should == 'source-b'
173
152
  end
174
153
 
175
154
  end
@@ -1,9 +1,104 @@
1
1
  require "librarian/environment"
2
2
 
3
+ require "support/with_env_macro"
4
+
3
5
  module Librarian
4
6
  describe Environment do
7
+ include WithEnvMacro
5
8
 
6
9
  let(:env) { described_class.new }
7
10
 
11
+ describe "#http_proxy_uri" do
12
+
13
+ context "sanity" do
14
+ with_env "http_proxy" => nil
15
+
16
+ it "should have a nil http proxy uri" do
17
+ env.http_proxy_uri.should be_nil
18
+ end
19
+ end
20
+
21
+ context "with a complex proxy" do
22
+ with_env "http_proxy" => "admin:secret@example.com"
23
+
24
+ it "should have the expcted http proxy uri" do
25
+ env.http_proxy_uri.should == URI("http://admin:secret@example.com")
26
+ end
27
+
28
+ it "should have the expected host" do
29
+ env.http_proxy_uri.host.should == "example.com"
30
+ end
31
+
32
+ it "should have the expected user" do
33
+ env.http_proxy_uri.user.should == "admin"
34
+ end
35
+
36
+ it "should have the expected password" do
37
+ env.http_proxy_uri.password.should == "secret"
38
+ end
39
+ end
40
+
41
+ context "with a split proxy" do
42
+ with_env "http_proxy" => "example.com",
43
+ "http_proxy_user" => "admin",
44
+ "http_proxy_pass" => "secret"
45
+
46
+ it "should have the expcted http proxy uri" do
47
+ env.http_proxy_uri.should == URI("http://admin:secret@example.com")
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ describe "#net_http_class" do
54
+
55
+ context "sanity" do
56
+ with_env "http_proxy" => nil
57
+
58
+ it "should have the normal class" do
59
+ env.net_http_class.should be Net::HTTP
60
+ end
61
+
62
+ it "should not be marked as a proxy class" do
63
+ env.net_http_class.should_not be_proxy_class
64
+ end
65
+ end
66
+
67
+ context "with a complex proxy" do
68
+ with_env "http_proxy" => "admin:secret@example.com"
69
+
70
+ it "should not have the normal class" do
71
+ env.net_http_class.should_not be Net::HTTP
72
+ end
73
+
74
+ it "should have a subclass the normal class" do
75
+ env.net_http_class.should < Net::HTTP
76
+ end
77
+
78
+ it "should be marked as a proxy class" do
79
+ env.net_http_class.should be_proxy_class
80
+ end
81
+
82
+ it "should have the expected proxy attributes" do
83
+ http = env.net_http_class.new("www.kernel.org")
84
+ expected_attributes = {
85
+ "host" => env.http_proxy_uri.host,
86
+ "port" => env.http_proxy_uri.port,
87
+ "user" => env.http_proxy_uri.user,
88
+ "pass" => env.http_proxy_uri.password
89
+ }
90
+ actual_attributes = {
91
+ "host" => http.proxy_address,
92
+ "port" => http.proxy_port,
93
+ "user" => http.proxy_user,
94
+ "pass" => http.proxy_pass,
95
+ }
96
+
97
+ actual_attributes.should == expected_attributes
98
+ end
99
+ end
100
+
101
+ end
102
+
8
103
  end
9
104
  end
@@ -25,6 +25,12 @@ describe Librarian::Manifest do
25
25
  end
26
26
  end
27
27
 
28
+ context "when the name is a single character" do
29
+ it "passes" do
30
+ described_class.new(nil, "R")
31
+ end
32
+ end
33
+
28
34
  end
29
35
 
30
36
  end
@@ -61,6 +61,47 @@ module Librarian
61
61
 
62
62
  end
63
63
 
64
+ context "a specfile with a dep in multiple sources" do
65
+
66
+ before do
67
+ env.registry :clear => true do
68
+ source 'source-1' do
69
+ spec 'butter', '1.0'
70
+ spec 'butter', '1.1'
71
+ end
72
+ source 'source-2' do
73
+ spec 'butter', '1.0'
74
+ spec 'butter', '1.1'
75
+ end
76
+ source 'source-3' do
77
+ spec 'butter', '1.0'
78
+ end
79
+ end
80
+ end
81
+
82
+ let(:spec) do
83
+ env.dsl do
84
+ src 'source-1'
85
+ src 'source-2'
86
+ dep 'butter', '>= 1.1'
87
+ end
88
+ end
89
+
90
+ it "should have the expected number of sources" do
91
+ spec.should have(2).sources
92
+ end
93
+
94
+ let(:resolution) { resolver.resolve(spec) }
95
+
96
+ specify { resolution.should be_correct }
97
+
98
+ it "should have the manifest from the final source with a matching manifest" do
99
+ manifest = resolution.manifests.find{|m| m.name == "butter"}
100
+ manifest.source.name.should == "source-2"
101
+ end
102
+
103
+ end
104
+
64
105
  context "a specfile with a dep depending on a nonexistent dep" do
65
106
 
66
107
  before do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librarian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.25
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-06-23 00:00:00.000000000 Z
12
+ date: 2012-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -59,38 +59,6 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: cucumber
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: aruba
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
62
  - !ruby/object:Gem::Dependency
95
63
  name: webmock
96
64
  requirement: !ruby/object:Gem::Requirement
@@ -190,12 +158,6 @@ files:
190
158
  - Rakefile
191
159
  - bin/librarian-chef
192
160
  - bin/librarian-mock
193
- - config/cucumber.yaml
194
- - features/chef/cli/init.feature
195
- - features/chef/cli/install.feature
196
- - features/chef/cli/show.feature
197
- - features/chef/cli/version.feature
198
- - features/support/env.rb
199
161
  - lib/librarian.rb
200
162
  - lib/librarian/action.rb
201
163
  - lib/librarian/action/base.rb
@@ -231,10 +193,10 @@ files:
231
193
  - lib/librarian/environment.rb
232
194
  - lib/librarian/error.rb
233
195
  - lib/librarian/helpers.rb
234
- - lib/librarian/helpers/debug.rb
235
196
  - lib/librarian/lockfile.rb
236
197
  - lib/librarian/lockfile/compiler.rb
237
198
  - lib/librarian/lockfile/parser.rb
199
+ - lib/librarian/logger.rb
238
200
  - lib/librarian/manifest.rb
239
201
  - lib/librarian/manifest_set.rb
240
202
  - lib/librarian/mock.rb
@@ -260,9 +222,12 @@ files:
260
222
  - lib/librarian/ui.rb
261
223
  - lib/librarian/version.rb
262
224
  - librarian.gemspec
225
+ - spec/functional/chef/cli_spec.rb
263
226
  - spec/functional/chef/source/git_spec.rb
264
227
  - spec/functional/chef/source/site_spec.rb
265
228
  - spec/functional/source/git/repository_spec.rb
229
+ - spec/support/cli_macro.rb
230
+ - spec/support/with_env_macro.rb
266
231
  - spec/unit/action/base_spec.rb
267
232
  - spec/unit/action/clean_spec.rb
268
233
  - spec/unit/action/ensure_spec.rb
@@ -293,7 +258,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
258
  version: '0'
294
259
  segments:
295
260
  - 0
296
- hash: 1740169763066753251
261
+ hash: 3137632899221484598
297
262
  required_rubygems_version: !ruby/object:Gem::Requirement
298
263
  none: false
299
264
  requirements: