librarian-puppet-maestrodev 0.9.7

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.
Files changed (115) hide show
  1. data/.gitignore +3 -0
  2. data/LICENSE +20 -0
  3. data/README.md +187 -0
  4. data/bin/librarian-puppet +9 -0
  5. data/lib/librarian/puppet.rb +13 -0
  6. data/lib/librarian/puppet/cli.rb +85 -0
  7. data/lib/librarian/puppet/dsl.rb +16 -0
  8. data/lib/librarian/puppet/environment.rb +54 -0
  9. data/lib/librarian/puppet/extension.rb +41 -0
  10. data/lib/librarian/puppet/lockfile/parser.rb +53 -0
  11. data/lib/librarian/puppet/source.rb +4 -0
  12. data/lib/librarian/puppet/source/forge.rb +279 -0
  13. data/lib/librarian/puppet/source/git.rb +114 -0
  14. data/lib/librarian/puppet/source/githubtarball.rb +234 -0
  15. data/lib/librarian/puppet/source/local.rb +57 -0
  16. data/lib/librarian/puppet/source/path.rb +12 -0
  17. data/lib/librarian/puppet/templates/Puppetfile +10 -0
  18. data/lib/librarian/puppet/version.rb +5 -0
  19. data/vendor/librarian/CHANGELOG.md +185 -0
  20. data/vendor/librarian/Gemfile +6 -0
  21. data/vendor/librarian/MIT-LICENSE +20 -0
  22. data/vendor/librarian/README.md +403 -0
  23. data/vendor/librarian/Rakefile +34 -0
  24. data/vendor/librarian/bin/librarian-chef +7 -0
  25. data/vendor/librarian/bin/librarian-mock +7 -0
  26. data/vendor/librarian/config/cucumber.yaml +1 -0
  27. data/vendor/librarian/features/chef/cli/init.feature +11 -0
  28. data/vendor/librarian/features/chef/cli/install.feature +64 -0
  29. data/vendor/librarian/features/chef/cli/show.feature +77 -0
  30. data/vendor/librarian/features/chef/cli/version.feature +11 -0
  31. data/vendor/librarian/features/support/env.rb +9 -0
  32. data/vendor/librarian/lib/librarian.rb +19 -0
  33. data/vendor/librarian/lib/librarian/action.rb +5 -0
  34. data/vendor/librarian/lib/librarian/action/base.rb +24 -0
  35. data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
  36. data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
  37. data/vendor/librarian/lib/librarian/action/install.rb +99 -0
  38. data/vendor/librarian/lib/librarian/action/resolve.rb +81 -0
  39. data/vendor/librarian/lib/librarian/action/update.rb +78 -0
  40. data/vendor/librarian/lib/librarian/chef.rb +1 -0
  41. data/vendor/librarian/lib/librarian/chef/cli.rb +48 -0
  42. data/vendor/librarian/lib/librarian/chef/dsl.rb +15 -0
  43. data/vendor/librarian/lib/librarian/chef/environment.rb +27 -0
  44. data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
  45. data/vendor/librarian/lib/librarian/chef/integration/knife.rb +42 -0
  46. data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +59 -0
  47. data/vendor/librarian/lib/librarian/chef/source.rb +3 -0
  48. data/vendor/librarian/lib/librarian/chef/source/git.rb +25 -0
  49. data/vendor/librarian/lib/librarian/chef/source/local.rb +69 -0
  50. data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
  51. data/vendor/librarian/lib/librarian/chef/source/site.rb +446 -0
  52. data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
  53. data/vendor/librarian/lib/librarian/cli.rb +205 -0
  54. data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +79 -0
  55. data/vendor/librarian/lib/librarian/config.rb +7 -0
  56. data/vendor/librarian/lib/librarian/config/database.rb +205 -0
  57. data/vendor/librarian/lib/librarian/config/file_source.rb +47 -0
  58. data/vendor/librarian/lib/librarian/config/hash_source.rb +33 -0
  59. data/vendor/librarian/lib/librarian/config/source.rb +149 -0
  60. data/vendor/librarian/lib/librarian/dependency.rb +91 -0
  61. data/vendor/librarian/lib/librarian/dsl.rb +108 -0
  62. data/vendor/librarian/lib/librarian/dsl/receiver.rb +48 -0
  63. data/vendor/librarian/lib/librarian/dsl/target.rb +172 -0
  64. data/vendor/librarian/lib/librarian/environment.rb +134 -0
  65. data/vendor/librarian/lib/librarian/error.rb +4 -0
  66. data/vendor/librarian/lib/librarian/helpers.rb +13 -0
  67. data/vendor/librarian/lib/librarian/lockfile.rb +29 -0
  68. data/vendor/librarian/lib/librarian/lockfile/compiler.rb +66 -0
  69. data/vendor/librarian/lib/librarian/lockfile/parser.rb +100 -0
  70. data/vendor/librarian/lib/librarian/logger.rb +46 -0
  71. data/vendor/librarian/lib/librarian/manifest.rb +132 -0
  72. data/vendor/librarian/lib/librarian/manifest_set.rb +153 -0
  73. data/vendor/librarian/lib/librarian/mock.rb +1 -0
  74. data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
  75. data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
  76. data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
  77. data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
  78. data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
  79. data/vendor/librarian/lib/librarian/mock/source/mock.rb +97 -0
  80. data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
  81. data/vendor/librarian/lib/librarian/resolution.rb +44 -0
  82. data/vendor/librarian/lib/librarian/resolver.rb +78 -0
  83. data/vendor/librarian/lib/librarian/resolver/implementation.rb +118 -0
  84. data/vendor/librarian/lib/librarian/source.rb +2 -0
  85. data/vendor/librarian/lib/librarian/source/git.rb +150 -0
  86. data/vendor/librarian/lib/librarian/source/git/repository.rb +217 -0
  87. data/vendor/librarian/lib/librarian/source/local.rb +61 -0
  88. data/vendor/librarian/lib/librarian/source/path.rb +74 -0
  89. data/vendor/librarian/lib/librarian/spec.rb +13 -0
  90. data/vendor/librarian/lib/librarian/spec_change_set.rb +173 -0
  91. data/vendor/librarian/lib/librarian/specfile.rb +18 -0
  92. data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
  93. data/vendor/librarian/lib/librarian/ui.rb +64 -0
  94. data/vendor/librarian/lib/librarian/version.rb +3 -0
  95. data/vendor/librarian/librarian.gemspec +34 -0
  96. data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
  97. data/vendor/librarian/spec/functional/chef/source/site_spec.rb +215 -0
  98. data/vendor/librarian/spec/functional/source/git/repository_spec.rb +149 -0
  99. data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
  100. data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
  101. data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
  102. data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
  103. data/vendor/librarian/spec/unit/config/database_spec.rb +319 -0
  104. data/vendor/librarian/spec/unit/dependency_spec.rb +36 -0
  105. data/vendor/librarian/spec/unit/dsl_spec.rb +194 -0
  106. data/vendor/librarian/spec/unit/environment_spec.rb +9 -0
  107. data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
  108. data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
  109. data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
  110. data/vendor/librarian/spec/unit/manifest_spec.rb +36 -0
  111. data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
  112. data/vendor/librarian/spec/unit/resolver_spec.rb +192 -0
  113. data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
  114. data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
  115. metadata +227 -0
@@ -0,0 +1,215 @@
1
+ require 'pathname'
2
+ require 'json'
3
+ require 'webmock'
4
+
5
+ require 'librarian'
6
+ require 'librarian/helpers'
7
+ require 'librarian/action/resolve'
8
+ require 'librarian/action/install'
9
+ require 'librarian/chef'
10
+
11
+ module Librarian
12
+ module Chef
13
+ module Source
14
+ describe Site do
15
+
16
+ include WebMock::API
17
+
18
+ let(:project_path) do
19
+ project_path = Pathname.new(__FILE__).expand_path
20
+ project_path = project_path.dirname until project_path.join("Rakefile").exist?
21
+ project_path
22
+ end
23
+ let(:tmp_path) { project_path.join("tmp/spec/chef/site-source") }
24
+ let(:sample_path) { tmp_path.join("sample") }
25
+ let(:sample_metadata) do
26
+ Helpers.strip_heredoc(<<-METADATA)
27
+ version "0.6.5"
28
+ METADATA
29
+ end
30
+
31
+ let(:api_url) { "http://site.cookbooks.com" }
32
+
33
+ let(:sample_index_data) do
34
+ {
35
+ "name" => "sample",
36
+ "versions" => [
37
+ "#{api_url}/cookbooks/sample/versions/0_6_5"
38
+ ]
39
+ }
40
+ end
41
+ let(:sample_0_6_5_data) do
42
+ {
43
+ "version" => "0.6.5",
44
+ "file" => "#{api_url}/cookbooks/sample/versions/0_6_5/file.tar.gz"
45
+ }
46
+ end
47
+
48
+ # depends on repo_path being defined in each context
49
+ let(:env) { Environment.new(:project_path => repo_path) }
50
+
51
+ before :all do
52
+ sample_path.rmtree if sample_path.exist?
53
+ sample_path.mkpath
54
+ sample_path.join("metadata.rb").open("wb") { |f| f.write(sample_metadata) }
55
+ Dir.chdir(sample_path.dirname) do
56
+ system "tar --create --gzip --file sample.tar.gz #{sample_path.basename}"
57
+ end
58
+ end
59
+
60
+ before do
61
+ stub_request(:get, "#{api_url}/cookbooks/sample").
62
+ to_return(:body => JSON.dump(sample_index_data))
63
+
64
+ stub_request(:get, "#{api_url}/cookbooks/sample/versions/0_6_5").
65
+ to_return(:body => JSON.dump(sample_0_6_5_data))
66
+
67
+ stub_request(:get, "#{api_url}/cookbooks/sample/versions/0_6_5/file.tar.gz").
68
+ to_return(:body => sample_path.dirname.join("sample.tar.gz").read)
69
+ end
70
+
71
+ after do
72
+ WebMock.reset!
73
+ end
74
+
75
+ context "a single dependency with a site source" do
76
+
77
+ context "resolving" do
78
+ let(:repo_path) { tmp_path.join("repo/resolve") }
79
+ before do
80
+ repo_path.rmtree if repo_path.exist?
81
+ repo_path.mkpath
82
+ repo_path.join("cookbooks").mkpath
83
+ cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
84
+ #!/usr/bin/env ruby
85
+ cookbook "sample", :site => #{api_url.inspect}
86
+ CHEFFILE
87
+ repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
88
+ end
89
+
90
+ context "the resolve" do
91
+ it "should not raise an exception" do
92
+ expect { Action::Resolve.new(env).run }.to_not raise_error
93
+ end
94
+ end
95
+
96
+ context "the results" do
97
+ before { Action::Resolve.new(env).run }
98
+
99
+ it "should create the lockfile" do
100
+ repo_path.join("Cheffile.lock").should exist
101
+ end
102
+
103
+ it "should not attempt to install the cookbok" do
104
+ repo_path.join("cookbooks/sample").should_not exist
105
+ end
106
+ end
107
+ end
108
+
109
+ context "intalling" do
110
+ let(:repo_path) { tmp_path.join("repo/install") }
111
+ before do
112
+ repo_path.rmtree if repo_path.exist?
113
+ repo_path.mkpath
114
+ repo_path.join("cookbooks").mkpath
115
+ cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
116
+ #!/usr/bin/env ruby
117
+ cookbook "sample", :site => #{api_url.inspect}
118
+ CHEFFILE
119
+ repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
120
+
121
+ Action::Resolve.new(env).run
122
+ end
123
+
124
+ context "the install" do
125
+ it "should not raise an exception" do
126
+ expect { Action::Install.new(env).run }.to_not raise_error
127
+ end
128
+ end
129
+
130
+ context "the results" do
131
+ before { Action::Install.new(env).run }
132
+
133
+ it "should create the lockfile" do
134
+ repo_path.join("Cheffile.lock").should exist
135
+ end
136
+
137
+ it "should create a directory for the cookbook" do
138
+ repo_path.join("cookbooks/sample").should exist
139
+ end
140
+
141
+ it "should copy the cookbook files into the cookbook directory" do
142
+ repo_path.join("cookbooks/sample/metadata.rb").should exist
143
+ end
144
+ end
145
+ end
146
+
147
+ context "resolving and separately installing" do
148
+ let(:repo_path) { tmp_path.join("repo/resolve-install") }
149
+ before do
150
+ repo_path.rmtree if repo_path.exist?
151
+ repo_path.mkpath
152
+ repo_path.join("cookbooks").mkpath
153
+ cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
154
+ #!/usr/bin/env ruby
155
+ cookbook "sample", :site => #{api_url.inspect}
156
+ CHEFFILE
157
+ repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
158
+
159
+ Action::Resolve.new(env).run
160
+ repo_path.join("tmp").rmtree if repo_path.join("tmp").exist?
161
+ end
162
+
163
+ context "the install" do
164
+ it "should not raise an exception" do
165
+ expect { Action::Install.new(env).run }.to_not raise_error
166
+ end
167
+ end
168
+
169
+ context "the results" do
170
+ before { Action::Install.new(env).run }
171
+
172
+ it "should create a directory for the cookbook" do
173
+ repo_path.join("cookbooks/sample").should exist
174
+ end
175
+
176
+ it "should copy the cookbook files into the cookbook directory" do
177
+ repo_path.join("cookbooks/sample/metadata.rb").should exist
178
+ end
179
+ end
180
+ end
181
+
182
+ end
183
+
184
+ context "when the repo path has a space" do
185
+
186
+ let(:repo_path) { tmp_path.join("repo/with extra spaces/resolve") }
187
+
188
+ before do
189
+ repo_path.rmtree if repo_path.exist?
190
+ repo_path.mkpath
191
+ repo_path.join("cookbooks").mkpath
192
+
193
+ cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
194
+ #!/usr/bin/env ruby
195
+ cookbook "sample", :site => #{api_url.inspect}
196
+ CHEFFILE
197
+ repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
198
+ end
199
+
200
+ after do
201
+ repo_path.rmtree
202
+ end
203
+
204
+ context "the resolution" do
205
+ it "should not raise an exception" do
206
+ expect { Action::Resolve.new(env).run }.to_not raise_error
207
+ end
208
+ end
209
+
210
+ end
211
+
212
+ end
213
+ end
214
+ end
215
+ end
@@ -0,0 +1,149 @@
1
+ require "fileutils"
2
+ require "pathname"
3
+ require "securerandom"
4
+
5
+ require "librarian/source/git/repository"
6
+
7
+ describe Librarian::Source::Git::Repository do
8
+
9
+ let(:env) do
10
+ double(:ui => nil, :logger => double(:debug => nil, :info => nil))
11
+ end
12
+
13
+ let(:project_path) do
14
+ project_path = Pathname.new(__FILE__).expand_path
15
+ project_path = project_path.dirname until project_path.join("Rakefile").exist?
16
+ project_path
17
+ end
18
+ let(:tmp_path) { project_path + "tmp/spec/unit/source/git/repository-spec" }
19
+ let(:git_source_path) { tmp_path + SecureRandom.hex(16) }
20
+ let(:branch) { "the-branch" }
21
+ let(:tag) { "the-tag" }
22
+ let(:atag) { "the-atag" }
23
+
24
+ before do
25
+ git_source_path.mkpath
26
+ Dir.chdir(git_source_path) do
27
+ `git init`
28
+
29
+ # master
30
+ `touch butter.txt`
31
+ `git add butter.txt`
32
+ `git commit -m "Initial Commit"`
33
+
34
+ # branch
35
+ `git checkout -b #{branch} --quiet`
36
+ `touch jam.txt`
37
+ `git add jam.txt`
38
+ `git commit -m "Branch Commit"`
39
+ `git checkout master --quiet`
40
+
41
+ # tag
42
+ `git checkout -b deletable --quiet`
43
+ `touch jelly.txt`
44
+ `git add jelly.txt`
45
+ `git commit -m "Tag Commit"`
46
+ `git tag #{tag}`
47
+ `git checkout master --quiet`
48
+ `git branch -D deletable`
49
+
50
+ # annotated tag
51
+ `git checkout -b deletable --quiet`
52
+ `touch jelly.txt`
53
+ `git add jelly.txt`
54
+ `git commit -m "Tag Commit"`
55
+ `git tag -am "Annotated Tag Commit" #{atag}`
56
+ `git checkout master --quiet`
57
+ `git branch -D deletable`
58
+ end
59
+ end
60
+
61
+ context "the original" do
62
+ subject { described_class.new(env, git_source_path) }
63
+
64
+ it "should recognize it" do
65
+ subject.should be_git
66
+ end
67
+
68
+ it "should not list any remotes for it" do
69
+ subject.remote_names.should be_empty
70
+ end
71
+
72
+ it "should not list any remote branches for it" do
73
+ subject.remote_branch_names.should be_empty
74
+ end
75
+ end
76
+
77
+ context "a clone" do
78
+ let(:git_clone_path) { tmp_path + SecureRandom.hex(16) }
79
+ subject { described_class.clone!(env, git_clone_path, git_source_path) }
80
+
81
+ let(:master_sha) { subject.hash_from("origin", "master") }
82
+ let(:branch_sha) { subject.hash_from("origin", branch) }
83
+ let(:tag_sha) { subject.hash_from("origin", tag) }
84
+ let(:atag_sha) { subject.hash_from("origin", atag) }
85
+
86
+ it "should recognize it" do
87
+ subject.should be_git
88
+ end
89
+
90
+ it "should have a single remote for it" do
91
+ subject.should have(1).remote_names
92
+ end
93
+
94
+ it "should have a remote with the expected name" do
95
+ subject.remote_names.first.should == "origin"
96
+ end
97
+
98
+ it "should have the remote branch" do
99
+ subject.remote_branch_names["origin"].should include branch
100
+ end
101
+
102
+ it "should be checked out on the master" do
103
+ subject.should be_checked_out(master_sha)
104
+ end
105
+
106
+ context "checking out the branch" do
107
+ before do
108
+ subject.checkout! branch
109
+ end
110
+
111
+ it "should be checked out on the branch" do
112
+ subject.should be_checked_out(branch_sha)
113
+ end
114
+
115
+ it "should not be checked out on the master" do
116
+ subject.should_not be_checked_out(master_sha)
117
+ end
118
+ end
119
+
120
+ context "checking out the tag" do
121
+ before do
122
+ subject.checkout! tag
123
+ end
124
+
125
+ it "should be checked out on the tag" do
126
+ subject.should be_checked_out(tag_sha)
127
+ end
128
+
129
+ it "should not be checked out on the master" do
130
+ subject.should_not be_checked_out(master_sha)
131
+ end
132
+ end
133
+
134
+ context "checking out the annotated tag" do
135
+ before do
136
+ subject.checkout! atag
137
+ end
138
+
139
+ it "should be checked out on the annotated tag" do
140
+ subject.should be_checked_out(atag_sha)
141
+ end
142
+
143
+ it "should not be checked out on the master" do
144
+ subject.should_not be_checked_out(master_sha)
145
+ end
146
+ end
147
+ end
148
+
149
+ end
@@ -0,0 +1,18 @@
1
+ require "librarian/action/base"
2
+
3
+ module Librarian
4
+ describe Action::Base do
5
+
6
+ let(:env) { mock }
7
+ let(:action) { described_class.new(env) }
8
+
9
+ subject { action }
10
+
11
+ it { should respond_to :environment }
12
+
13
+ it "should have the environment that was assigned to it" do
14
+ action.environment.should be env
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,102 @@
1
+ require "librarian/action/clean"
2
+
3
+ module Librarian
4
+ describe Action::Clean do
5
+
6
+ let(:env) { mock }
7
+ let(:action) { described_class.new(env) }
8
+
9
+ before do
10
+ action.stub(:debug)
11
+ end
12
+
13
+ describe "#run" do
14
+
15
+ describe "behavior" do
16
+
17
+ after do
18
+ action.run
19
+ end
20
+
21
+ describe "clearing the cache path" do
22
+
23
+ before do
24
+ action.stub(:clean_install_path)
25
+ end
26
+
27
+ context "when the cache path is missing" do
28
+ before do
29
+ env.stub_chain(:cache_path, :exist?) { false }
30
+ end
31
+
32
+ it "should not try to clear the cache path" do
33
+ env.cache_path.should_receive(:rmtree).never
34
+ end
35
+ end
36
+
37
+ context "when the cache path is present" do
38
+ before do
39
+ env.stub_chain(:cache_path, :exist?) { true }
40
+ end
41
+
42
+ it "should try to clear the cache path" do
43
+ env.cache_path.should_receive(:rmtree).exactly(:once)
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ describe "clearing the install path" do
50
+
51
+ before do
52
+ action.stub(:clean_cache_path)
53
+ end
54
+
55
+ context "when the install path is missing" do
56
+ before do
57
+ env.stub_chain(:install_path, :exist?) { false }
58
+ end
59
+
60
+ it "should not try to clear the install path" do
61
+ env.install_path.should_receive(:children).never
62
+ end
63
+ end
64
+
65
+ context "when the install path is present" do
66
+ before do
67
+ env.stub_chain(:install_path, :exist?) { true }
68
+ end
69
+
70
+ it "should try to clear the install path" do
71
+ children = [mock, mock, mock]
72
+ children.each do |child|
73
+ child.stub(:file?) { false }
74
+ end
75
+ env.stub_chain(:install_path, :children) { children }
76
+
77
+ children.each do |child|
78
+ child.should_receive(:rmtree).exactly(:once)
79
+ end
80
+ end
81
+
82
+ it "should only try to clear out directories from the install path, not files" do
83
+ children = [mock(:file? => false), mock(:file? => true), mock(:file? => true)]
84
+ env.stub_chain(:install_path, :children) { children }
85
+
86
+ children.select(&:file?).each do |child|
87
+ child.should_receive(:rmtree).never
88
+ end
89
+ children.reject(&:file?).each do |child|
90
+ child.should_receive(:rmtree).exactly(:once)
91
+ end
92
+ end
93
+ end
94
+
95
+ end
96
+
97
+ end
98
+
99
+ end
100
+
101
+ end
102
+ end