librarian-puppet-lmco 0.9.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/LICENSE +20 -0
  4. data/README.md +187 -0
  5. data/bin/librarian-puppet +9 -0
  6. data/lib/librarian/puppet.rb +22 -0
  7. data/lib/librarian/puppet/cli.rb +85 -0
  8. data/lib/librarian/puppet/dsl.rb +16 -0
  9. data/lib/librarian/puppet/environment.rb +54 -0
  10. data/lib/librarian/puppet/extension.rb +47 -0
  11. data/lib/librarian/puppet/lockfile/parser.rb +53 -0
  12. data/lib/librarian/puppet/source.rb +4 -0
  13. data/lib/librarian/puppet/source/forge.rb +348 -0
  14. data/lib/librarian/puppet/source/git.rb +121 -0
  15. data/lib/librarian/puppet/source/githubtarball.rb +249 -0
  16. data/lib/librarian/puppet/source/local.rb +57 -0
  17. data/lib/librarian/puppet/source/path.rb +12 -0
  18. data/lib/librarian/puppet/templates/Puppetfile +10 -0
  19. data/lib/librarian/puppet/version.rb +5 -0
  20. data/vendor/librarian/CHANGELOG.md +224 -0
  21. data/vendor/librarian/Gemfile +6 -0
  22. data/vendor/librarian/MIT-LICENSE +20 -0
  23. data/vendor/librarian/README.md +401 -0
  24. data/vendor/librarian/Rakefile +34 -0
  25. data/vendor/librarian/bin/librarian-chef +7 -0
  26. data/vendor/librarian/bin/librarian-mock +7 -0
  27. data/vendor/librarian/config/cucumber.yaml +1 -0
  28. data/vendor/librarian/features/chef/cli/init.feature +11 -0
  29. data/vendor/librarian/features/chef/cli/install.feature +64 -0
  30. data/vendor/librarian/features/chef/cli/show.feature +77 -0
  31. data/vendor/librarian/features/chef/cli/version.feature +11 -0
  32. data/vendor/librarian/features/support/env.rb +9 -0
  33. data/vendor/librarian/lib/librarian.rb +11 -0
  34. data/vendor/librarian/lib/librarian/action.rb +5 -0
  35. data/vendor/librarian/lib/librarian/action/base.rb +24 -0
  36. data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
  37. data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
  38. data/vendor/librarian/lib/librarian/action/install.rb +95 -0
  39. data/vendor/librarian/lib/librarian/action/persist_resolution_mixin.rb +51 -0
  40. data/vendor/librarian/lib/librarian/action/resolve.rb +46 -0
  41. data/vendor/librarian/lib/librarian/action/update.rb +44 -0
  42. data/vendor/librarian/lib/librarian/chef.rb +1 -0
  43. data/vendor/librarian/lib/librarian/chef/cli.rb +47 -0
  44. data/vendor/librarian/lib/librarian/chef/dsl.rb +16 -0
  45. data/vendor/librarian/lib/librarian/chef/environment.rb +27 -0
  46. data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
  47. data/vendor/librarian/lib/librarian/chef/integration/knife.rb +46 -0
  48. data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +59 -0
  49. data/vendor/librarian/lib/librarian/chef/source.rb +4 -0
  50. data/vendor/librarian/lib/librarian/chef/source/git.rb +25 -0
  51. data/vendor/librarian/lib/librarian/chef/source/github.rb +27 -0
  52. data/vendor/librarian/lib/librarian/chef/source/local.rb +69 -0
  53. data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
  54. data/vendor/librarian/lib/librarian/chef/source/site.rb +442 -0
  55. data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
  56. data/vendor/librarian/lib/librarian/cli.rb +223 -0
  57. data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +93 -0
  58. data/vendor/librarian/lib/librarian/config.rb +7 -0
  59. data/vendor/librarian/lib/librarian/config/database.rb +205 -0
  60. data/vendor/librarian/lib/librarian/config/file_source.rb +47 -0
  61. data/vendor/librarian/lib/librarian/config/hash_source.rb +33 -0
  62. data/vendor/librarian/lib/librarian/config/source.rb +149 -0
  63. data/vendor/librarian/lib/librarian/dependency.rb +147 -0
  64. data/vendor/librarian/lib/librarian/dsl.rb +108 -0
  65. data/vendor/librarian/lib/librarian/dsl/receiver.rb +46 -0
  66. data/vendor/librarian/lib/librarian/dsl/target.rb +171 -0
  67. data/vendor/librarian/lib/librarian/environment.rb +182 -0
  68. data/vendor/librarian/lib/librarian/error.rb +4 -0
  69. data/vendor/librarian/lib/librarian/helpers.rb +13 -0
  70. data/vendor/librarian/lib/librarian/linter/source_linter.rb +55 -0
  71. data/vendor/librarian/lib/librarian/lockfile.rb +29 -0
  72. data/vendor/librarian/lib/librarian/lockfile/compiler.rb +66 -0
  73. data/vendor/librarian/lib/librarian/lockfile/parser.rb +123 -0
  74. data/vendor/librarian/lib/librarian/logger.rb +46 -0
  75. data/vendor/librarian/lib/librarian/manifest.rb +140 -0
  76. data/vendor/librarian/lib/librarian/manifest_set.rb +151 -0
  77. data/vendor/librarian/lib/librarian/mock.rb +1 -0
  78. data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
  79. data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
  80. data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
  81. data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
  82. data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
  83. data/vendor/librarian/lib/librarian/mock/source/mock.rb +80 -0
  84. data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
  85. data/vendor/librarian/lib/librarian/resolution.rb +46 -0
  86. data/vendor/librarian/lib/librarian/resolver.rb +81 -0
  87. data/vendor/librarian/lib/librarian/resolver/implementation.rb +223 -0
  88. data/vendor/librarian/lib/librarian/source.rb +2 -0
  89. data/vendor/librarian/lib/librarian/source/basic_api.rb +45 -0
  90. data/vendor/librarian/lib/librarian/source/git.rb +134 -0
  91. data/vendor/librarian/lib/librarian/source/git/repository.rb +217 -0
  92. data/vendor/librarian/lib/librarian/source/local.rb +54 -0
  93. data/vendor/librarian/lib/librarian/source/path.rb +56 -0
  94. data/vendor/librarian/lib/librarian/spec.rb +13 -0
  95. data/vendor/librarian/lib/librarian/spec_change_set.rb +173 -0
  96. data/vendor/librarian/lib/librarian/specfile.rb +17 -0
  97. data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
  98. data/vendor/librarian/lib/librarian/ui.rb +64 -0
  99. data/vendor/librarian/lib/librarian/version.rb +3 -0
  100. data/vendor/librarian/librarian.gemspec +35 -0
  101. data/vendor/librarian/spec/functional/chef/cli_spec.rb +194 -0
  102. data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
  103. data/vendor/librarian/spec/functional/chef/source/site_spec.rb +266 -0
  104. data/vendor/librarian/spec/functional/source/git/repository_spec.rb +150 -0
  105. data/vendor/librarian/spec/integration/chef/source/git_spec.rb +441 -0
  106. data/vendor/librarian/spec/integration/chef/source/site_spec.rb +217 -0
  107. data/vendor/librarian/spec/support/cli_macro.rb +114 -0
  108. data/vendor/librarian/spec/support/method_patch_macro.rb +30 -0
  109. data/vendor/librarian/spec/support/with_env_macro.rb +20 -0
  110. data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
  111. data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
  112. data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
  113. data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
  114. data/vendor/librarian/spec/unit/config/database_spec.rb +327 -0
  115. data/vendor/librarian/spec/unit/dependency_spec.rb +212 -0
  116. data/vendor/librarian/spec/unit/dsl_spec.rb +173 -0
  117. data/vendor/librarian/spec/unit/environment_spec.rb +173 -0
  118. data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
  119. data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
  120. data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
  121. data/vendor/librarian/spec/unit/manifest_spec.rb +36 -0
  122. data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
  123. data/vendor/librarian/spec/unit/resolver_spec.rb +233 -0
  124. data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
  125. data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
  126. metadata +220 -0
@@ -0,0 +1,37 @@
1
+ require "tmpdir"
2
+
3
+ require "librarian/error"
4
+ require "librarian/action/ensure"
5
+
6
+ module Librarian
7
+ describe Action::Ensure do
8
+
9
+ let(:env) { mock }
10
+ let(:action) { described_class.new(env) }
11
+
12
+ before do
13
+ env.stub(:specfile_name) { "Specfile" }
14
+ end
15
+
16
+ describe "#run" do
17
+
18
+ context "when the environment does not know its project path" do
19
+ before { env.stub(:project_path) { nil } }
20
+
21
+ it "should raise an error describing that the specfile is mising" do
22
+ expect { action.run }.to raise_error(Error, "Cannot find Specfile!")
23
+ end
24
+ end
25
+
26
+ context "when the environment knows its project path" do
27
+ before { env.stub(:project_path) { Dir.tmpdir } }
28
+
29
+ it "should not raise an error" do
30
+ expect { action.run }.to_not raise_error
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,111 @@
1
+ require "librarian/error"
2
+ require "librarian/action/install"
3
+
4
+ module Librarian
5
+ describe Action::Install do
6
+
7
+ let(:env) { mock(:specfile_name => "Specfile", :lockfile_name => "Specfile.lock") }
8
+ let(:action) { described_class.new(env) }
9
+
10
+ describe "#run" do
11
+
12
+ describe "behavior" do
13
+
14
+ describe "checking preconditions" do
15
+
16
+ context "when the specfile is missing" do
17
+ before do
18
+ env.stub_chain(:specfile_path, :exist?) { false }
19
+ end
20
+
21
+ it "should raise an error explaining that the specfile is missing" do
22
+ expect { action.run }.to raise_error(Error, "Specfile missing!")
23
+ end
24
+ end
25
+
26
+ context "when the specfile is present but the lockfile is missing" do
27
+ before do
28
+ env.stub_chain(:specfile_path, :exist?) { true }
29
+ env.stub_chain(:lockfile_path, :exist?) { false }
30
+ end
31
+
32
+ it "should raise an error explaining that the lockfile is missing" do
33
+ expect { action.run }.to raise_error(Error, "Specfile.lock missing!")
34
+ end
35
+ end
36
+
37
+ context "when the specfile and lockfile are present but inconsistent" do
38
+ before do
39
+ env.stub_chain(:specfile_path, :exist?) { true }
40
+ env.stub_chain(:lockfile_path, :exist?) { true }
41
+ action.stub(:spec_consistent_with_lock?) { false }
42
+ end
43
+
44
+ it "should raise an error explaining the inconsistenty" do
45
+ expect { action.run }.to raise_error(Error, "Specfile and Specfile.lock are out of sync!")
46
+ end
47
+ end
48
+
49
+ context "when the specfile and lockfile are present and consistent" do
50
+ before do
51
+ env.stub_chain(:specfile_path, :exist?) { true }
52
+ env.stub_chain(:lockfile_path, :exist?) { true }
53
+ action.stub(:spec_consistent_with_lock?) { true }
54
+ action.stub(:perform_installation)
55
+ end
56
+
57
+ it "should not raise an error" do
58
+ expect { action.run }.to_not raise_error
59
+ end
60
+ end
61
+
62
+ end
63
+
64
+ describe "performing the install" do
65
+
66
+ def mock_manifest(i)
67
+ double(:name => "manifest-#{i}")
68
+ end
69
+
70
+ let(:manifests) { 3.times.map{|i| mock_manifest(i)} }
71
+ let(:sorted_manifests) { 4.times.map{|i| mock_manifest(i + 3)} }
72
+ let(:install_path) { mock }
73
+
74
+ before do
75
+ env.stub(:install_path) { install_path }
76
+ action.stub(:check_preconditions)
77
+ action.stub_chain(:lock, :manifests) { manifests }
78
+ end
79
+
80
+ after do
81
+ action.run
82
+ end
83
+
84
+ it "should sort and install the manifests" do
85
+ ManifestSet.should_receive(:sort).with(manifests).exactly(:once).ordered { sorted_manifests }
86
+
87
+ install_path.stub(:exist?) { false }
88
+ install_path.should_receive(:mkpath).exactly(:once).ordered
89
+
90
+ sorted_manifests.each do |manifest|
91
+ manifest.should_receive(:install!).exactly(:once).ordered
92
+ end
93
+ end
94
+
95
+ it "should recreate the install path if it already exists" do
96
+ action.stub(:sorted_manifests) { sorted_manifests }
97
+ action.stub(:install_manifests)
98
+
99
+ install_path.stub(:exist?) { true }
100
+ install_path.should_receive(:rmtree)
101
+ install_path.should_receive(:mkpath)
102
+ end
103
+
104
+ end
105
+
106
+ end
107
+
108
+ end
109
+
110
+ end
111
+ end
@@ -0,0 +1,327 @@
1
+ require "fileutils"
2
+ require "pathname"
3
+ require "yaml"
4
+
5
+ require "fakefs/spec_helpers"
6
+
7
+ require "support/method_patch_macro"
8
+
9
+ require "librarian/config/database"
10
+
11
+ describe Librarian::Config::Database do
12
+ include FakeFS::SpecHelpers
13
+ include MethodPatchMacro
14
+
15
+ # FakeFS seems to need this because Kernel#Pathname was changed in 1.9.3-p286.
16
+ # It used to indicate the Pathname class by name, but now it references the
17
+ # Pathname class directly by object. FakeFS relies on the old behavior.
18
+ with_module_method(Kernel, :Pathname){|s| Pathname.new(s)}
19
+
20
+ def write_yaml!(path, *yamlables)
21
+ path = Pathname(path)
22
+ path.dirname.mkpath unless path.dirname.directory?
23
+ File.open(path, "wb"){|f| yamlables.each{|y| YAML.dump(y, f)}}
24
+ end
25
+
26
+ let(:adapter_name) { "gem" }
27
+
28
+ let(:env) { { } }
29
+ let(:pwd) { Pathname("/tmp") }
30
+ let(:home) { Pathname("~").expand_path }
31
+ let(:project_path) { nil }
32
+ let(:specfile_name) { nil }
33
+ let(:global) { home.join(".librarian/gem/config") }
34
+ let(:local) { pwd.join(".librarian/gem/config") }
35
+ let(:specfile) { pwd.join("Gemfile") }
36
+
37
+ before do
38
+ FileUtils.mkpath(pwd)
39
+ FileUtils.touch(specfile)
40
+ end
41
+
42
+ let(:database) do
43
+ described_class.new(adapter_name,
44
+ :env => env,
45
+ :pwd => pwd.to_s,
46
+ :home => home.to_s,
47
+ :project_path => project_path,
48
+ :specfile_name => specfile_name
49
+ )
50
+ end
51
+
52
+ context "when a key is given globally" do
53
+ let(:key) { "jam" }
54
+ let(:value) { "jelly" }
55
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
56
+
57
+ before do
58
+ write_yaml! global, raw_key => value
59
+ end
60
+
61
+ it "should have the key globally" do
62
+ database.global[key].should == value
63
+ end
64
+
65
+ it "should not have the key in the env" do
66
+ database.env[key].should be_nil
67
+ end
68
+
69
+ it "should not have the key locally" do
70
+ database.local[key].should be_nil
71
+ end
72
+
73
+ it "should have the key generally" do
74
+ database[key].should == value
75
+ end
76
+ end
77
+
78
+ context "when a key is set globally" do
79
+ let(:key) { "jam" }
80
+ let(:value) { "jelly" }
81
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
82
+
83
+ before do
84
+ database.global[key] = value
85
+ end
86
+
87
+ it "should have the key globally" do
88
+ database.global[key].should == value
89
+ end
90
+
91
+ it "should not have the key in the env" do
92
+ database.env[key].should be_nil
93
+ end
94
+
95
+ it "should not have the key locally" do
96
+ database.local[key].should be_nil
97
+ end
98
+
99
+ it "should have the key generally" do
100
+ database[key].should == value
101
+ end
102
+
103
+ it "should persist the key" do
104
+ data = YAML.load_file(global)
105
+
106
+ data.should == {raw_key => value}
107
+ end
108
+ end
109
+
110
+ context "when the key is set and unset globally" do
111
+ let(:key) { "jam" }
112
+ let(:value) { "jelly" }
113
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
114
+
115
+ before do
116
+ database.global[key] = value
117
+ database.global[key] = nil
118
+ end
119
+
120
+ it "should not have the key globally" do
121
+ database.global[key].should be_nil
122
+ end
123
+
124
+ it "should not have the key in the env" do
125
+ database.env[key].should be_nil
126
+ end
127
+
128
+ it "should not have the key locally" do
129
+ database.local[key].should be_nil
130
+ end
131
+
132
+ it "should not have the key generally" do
133
+ database[key].should be_nil
134
+ end
135
+
136
+ it "should unpersist the key" do
137
+ File.should_not exist global
138
+ end
139
+ end
140
+
141
+ context "when a key is given in the env" do
142
+ let(:key) { "jam" }
143
+ let(:value) { "jelly" }
144
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
145
+
146
+ #override
147
+ let(:env) { {raw_key => value} }
148
+
149
+ it "should not have the key globally" do
150
+ database.global[key].should be_nil
151
+ end
152
+
153
+ it "should have the key in the env" do
154
+ database.env[key].should == value
155
+ end
156
+
157
+ it "should not have the key locally" do
158
+ database.local[key].should be_nil
159
+ end
160
+
161
+ it "should have the key generally" do
162
+ database[key].should == value
163
+ end
164
+ end
165
+
166
+ context "when a key is given locally" do
167
+ let(:key) { "jam" }
168
+ let(:value) { "jelly" }
169
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
170
+
171
+ before do
172
+ write_yaml! local, raw_key => value
173
+ end
174
+
175
+ it "should not have the key globally" do
176
+ database.global[key].should be_nil
177
+ end
178
+
179
+ it "should not have the key in the env" do
180
+ database.env[key].should be_nil
181
+ end
182
+
183
+ it "should have the key locally" do
184
+ database.local[key].should == value
185
+ end
186
+
187
+ it "should have the key generally" do
188
+ database[key].should == value
189
+ end
190
+ end
191
+
192
+ context "when a key is set locally" do
193
+ let(:key) { "jam" }
194
+ let(:value) { "jelly" }
195
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
196
+
197
+ before do
198
+ database.local[key] = value
199
+ end
200
+
201
+ it "should not have the key globally" do
202
+ database.global[key].should be_nil
203
+ end
204
+
205
+ it "should not have the key in the env" do
206
+ database.env[key].should be_nil
207
+ end
208
+
209
+ it "should have the key locally" do
210
+ database.local[key].should == value
211
+ end
212
+
213
+ it "should have the key generally" do
214
+ database[key].should == value
215
+ end
216
+
217
+ it "should persist the key" do
218
+ data = YAML.load_file(local)
219
+
220
+ data.should == {raw_key => value}
221
+ end
222
+ end
223
+
224
+ context "when the key is set and unset locally" do
225
+ let(:key) { "jam" }
226
+ let(:value) { "jelly" }
227
+ let(:raw_key) { "LIBRARIAN_GEM_JAM" }
228
+
229
+ before do
230
+ database.local[key] = value
231
+ database.local[key] = nil
232
+ end
233
+
234
+ it "should not have the key globally" do
235
+ database.global[key].should be_nil
236
+ end
237
+
238
+ it "should not have the key in the env" do
239
+ database.env[key].should be_nil
240
+ end
241
+
242
+ it "should not have the key locally" do
243
+ database.local[key].should be_nil
244
+ end
245
+
246
+ it "should not have the key generally" do
247
+ database[key].should be_nil
248
+ end
249
+
250
+ it "should unpersist the key" do
251
+ File.should_not exist local
252
+ end
253
+ end
254
+
255
+ context "setting malformatted keys" do
256
+ it "should ban caps" do
257
+ expect { database.global["JAM"] = "jelly" }.
258
+ to raise_error Librarian::Error, %[key not permitted: "JAM"]
259
+ end
260
+
261
+ it "should ban double dots" do
262
+ expect { database.global["jam..jam"] = "jelly" }.
263
+ to raise_error Librarian::Error, %[key not permitted: "jam..jam"]
264
+ end
265
+ end
266
+
267
+ context "setting banned keys" do
268
+ it "should ban the specfile key" do
269
+ expect { database.global["gemfile"] = "jelly" }.
270
+ to raise_error Librarian::Error, %[key not permitted: "gemfile"]
271
+ end
272
+
273
+ it "should ban the global-config key" do
274
+ expect { database.global["config"] = "jelly" }.
275
+ to raise_error Librarian::Error, %[key not permitted: "config"]
276
+ end
277
+ end
278
+
279
+ context "project_path" do
280
+ context "by default" do
281
+ it "should give the default project path" do
282
+ database.project_path.should == Pathname("/tmp")
283
+ end
284
+ end
285
+
286
+ context "when the specfile is set in the env" do
287
+ let(:env) { {"LIBRARIAN_GEM_GEMFILE" => "/non/sense/path/to/Sillyfile"} }
288
+
289
+ it "should give the project path from the env-set specfile" do
290
+ database.project_path.should == Pathname("/non/sense/path/to")
291
+ end
292
+ end
293
+ end
294
+
295
+ context "specfile_path" do
296
+ context "by default" do
297
+ it "should give the default specfile path" do
298
+ database.specfile_path.should == specfile
299
+ end
300
+ end
301
+
302
+ context "when set in the env" do
303
+ let(:env) { {"LIBRARIAN_GEM_GEMFILE" => "/non/sense/path/to/Sillyfile"} }
304
+
305
+ it "should give the given specfile path" do
306
+ database.specfile_path.should == Pathname("/non/sense/path/to/Sillyfile")
307
+ end
308
+ end
309
+
310
+ context "when the project_path is assigned" do
311
+ let(:project_path) { "/non/sense/path/to" }
312
+
313
+ it "should give the assigned specfile path" do
314
+ database.specfile_path.should == Pathname("/non/sense/path/to/Gemfile")
315
+ end
316
+ end
317
+
318
+ context "when the specfile_name is assigned" do
319
+ let(:specfile_name) { "Sillyfile" }
320
+
321
+ it "should give the assigned specfile path" do
322
+ database.specfile_path.should == Pathname("/tmp/Sillyfile")
323
+ end
324
+ end
325
+ end
326
+
327
+ end