librarian-puppet-maestrodev 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
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,36 @@
1
+ require "librarian/dependency"
2
+
3
+ describe Librarian::Dependency do
4
+
5
+ describe "validations" do
6
+
7
+ context "when the name is blank" do
8
+ it "raises" do
9
+ expect { described_class.new("", [], nil) }.
10
+ to raise_error(ArgumentError, %{name ("") must be sensible})
11
+ end
12
+ end
13
+
14
+ context "when the name has leading whitespace" do
15
+ it "raises" do
16
+ expect { described_class.new(" the-name", [], nil) }.
17
+ to raise_error(ArgumentError, %{name (" the-name") must be sensible})
18
+ end
19
+ end
20
+
21
+ context "when the name has trailing whitespace" do
22
+ it "raises" do
23
+ expect { described_class.new("the-name ", [], nil) }.
24
+ to raise_error(ArgumentError, %{name ("the-name ") must be sensible})
25
+ end
26
+ end
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
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,194 @@
1
+ require 'librarian'
2
+ require 'librarian/mock'
3
+
4
+ module Librarian
5
+ module Mock
6
+
7
+ describe Dsl do
8
+
9
+ let(:env) { Environment.new }
10
+
11
+ context "a single source and a single dependency with a blank name" do
12
+ it "should not not run with a blank name" do
13
+ expect do
14
+ env.dsl do
15
+ src 'source-1'
16
+ dep ''
17
+ end
18
+ end.to raise_error(ArgumentError, %{name ("") must be sensible})
19
+ end
20
+ end
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
+ context "a simple specfile - a single source, a single dependency, no transitive dependencies" do
44
+
45
+ it "should run with a hash source" do
46
+ spec = env.dsl do
47
+ dep 'dependency-1',
48
+ :src => 'source-1'
49
+ end
50
+ spec.dependencies.should_not be_empty
51
+ spec.dependencies.first.name.should == 'dependency-1'
52
+ spec.dependencies.first.source.name.should == 'source-1'
53
+ spec.source.should be_nil
54
+ end
55
+
56
+ it "should run with a shortcut source" do
57
+ spec = env.dsl do
58
+ dep 'dependency-1',
59
+ :source => :a
60
+ end
61
+ spec.dependencies.should_not be_empty
62
+ spec.dependencies.first.name.should == 'dependency-1'
63
+ spec.dependencies.first.source.name.should == 'source-a'
64
+ spec.source.should be_nil
65
+ end
66
+
67
+ it "should run with a block hash source" do
68
+ spec = env.dsl do
69
+ source :src => 'source-1' do
70
+ dep 'dependency-1'
71
+ end
72
+ end
73
+ spec.dependencies.should_not be_empty
74
+ spec.dependencies.first.name.should == 'dependency-1'
75
+ spec.dependencies.first.source.name.should == 'source-1'
76
+ spec.source.should be_nil
77
+ end
78
+
79
+ it "should run with a block named source" do
80
+ spec = env.dsl do
81
+ src 'source-1' do
82
+ dep 'dependency-1'
83
+ end
84
+ end
85
+ spec.dependencies.should_not be_empty
86
+ spec.dependencies.first.name.should == 'dependency-1'
87
+ spec.dependencies.first.source.name.should == 'source-1'
88
+ spec.source.should be_nil
89
+ end
90
+
91
+ it "should run with a default hash source" do
92
+ spec = env.dsl do
93
+ source :src => 'source-1'
94
+ dep 'dependency-1'
95
+ end
96
+ spec.dependencies.should_not be_empty
97
+ spec.dependencies.first.name.should == 'dependency-1'
98
+ spec.dependencies.first.source.name.should == 'source-1'
99
+ spec.source.should_not be_nil
100
+ spec.dependencies.first.source.should == spec.source
101
+ end
102
+
103
+ it "should run with a default named source" do
104
+ spec = env.dsl do
105
+ src 'source-1'
106
+ dep 'dependency-1'
107
+ end
108
+ spec.dependencies.should_not be_empty
109
+ spec.dependencies.first.name.should == 'dependency-1'
110
+ spec.dependencies.first.source.name.should == 'source-1'
111
+ spec.source.should_not be_nil
112
+ spec.dependencies.first.source.should == spec.source
113
+ end
114
+
115
+ it "should run with a default shortcut source" do
116
+ spec = env.dsl do
117
+ source :a
118
+ dep 'dependency-1'
119
+ end
120
+ spec.dependencies.should_not be_empty
121
+ spec.dependencies.first.name.should == 'dependency-1'
122
+ spec.dependencies.first.source.name.should == 'source-a'
123
+ spec.source.should_not be_nil
124
+ spec.dependencies.first.source.should == spec.source
125
+ end
126
+
127
+ it "should run with a shortcut source hash definition" do
128
+ spec = env.dsl do
129
+ source :b, :src => 'source-b'
130
+ dep 'dependency-1', :source => :b
131
+ end
132
+ spec.dependencies.should_not be_empty
133
+ spec.dependencies.first.name.should == 'dependency-1'
134
+ spec.dependencies.first.source.name.should == 'source-b'
135
+ spec.source.should be_nil
136
+ end
137
+
138
+ it "should run with a shortcut source block definition" do
139
+ spec = env.dsl do
140
+ source :b, proc { src 'source-b' }
141
+ dep 'dependency-1', :source => :b
142
+ end
143
+ spec.dependencies.should_not be_empty
144
+ spec.dependencies.first.name.should == 'dependency-1'
145
+ spec.dependencies.first.source.name.should == 'source-b'
146
+ spec.source.should be_nil
147
+ end
148
+
149
+ it "should run with a default shortcut source hash definition" do
150
+ spec = env.dsl do
151
+ source :b, :src => 'source-b'
152
+ source :b
153
+ dep 'dependency-1'
154
+ end
155
+ spec.dependencies.should_not be_empty
156
+ spec.dependencies.first.name.should == 'dependency-1'
157
+ spec.dependencies.first.source.name.should == 'source-b'
158
+ spec.source.should_not be_nil
159
+ spec.source.name.should == 'source-b'
160
+ end
161
+
162
+ it "should run with a default shortcut source block definition" do
163
+ spec = env.dsl do
164
+ source :b, proc { src 'source-b' }
165
+ source :b
166
+ dep 'dependency-1'
167
+ end
168
+ spec.dependencies.should_not be_empty
169
+ spec.dependencies.first.name.should == 'dependency-1'
170
+ spec.dependencies.first.source.name.should == 'source-b'
171
+ spec.source.should_not be_nil
172
+ spec.source.name.should == 'source-b'
173
+ end
174
+
175
+ end
176
+
177
+ context "validating source options" do
178
+
179
+ it "should raise when given unrecognized optiosn options" do
180
+ expect do
181
+ env.dsl do
182
+ dep 'dependency-1',
183
+ :src => 'source-1',
184
+ :huh => 'yikes'
185
+ end
186
+ end.to raise_error(Error, %{unrecognized options: huh})
187
+ end
188
+
189
+ end
190
+
191
+ end
192
+
193
+ end
194
+ end
@@ -0,0 +1,9 @@
1
+ require "librarian/environment"
2
+
3
+ module Librarian
4
+ describe Environment do
5
+
6
+ let(:env) { described_class.new }
7
+
8
+ end
9
+ end
@@ -0,0 +1,162 @@
1
+ require "librarian/helpers"
2
+ require "librarian/lockfile/parser"
3
+ require "librarian/mock"
4
+
5
+ module Librarian
6
+ describe Lockfile::Parser do
7
+
8
+ let(:env) { Mock::Environment.new }
9
+ let(:parser) { described_class.new(env) }
10
+ let(:resolution) { parser.parse(lockfile) }
11
+
12
+ context "a mock lockfile with one source and no dependencies" do
13
+ let(:lockfile) do
14
+ Helpers.strip_heredoc <<-LOCKFILE
15
+ MOCK
16
+ remote: source-a
17
+ specs:
18
+
19
+ DEPENDENCIES
20
+
21
+ LOCKFILE
22
+ end
23
+
24
+ it "should give an empty list of dependencies" do
25
+ resolution.dependencies.should be_empty
26
+ end
27
+
28
+ it "should give an empty list of manifests" do
29
+ resolution.manifests.should be_empty
30
+ end
31
+ end
32
+
33
+ context "a mock lockfile with one source and one dependency" do
34
+ let(:lockfile) do
35
+ Helpers.strip_heredoc <<-LOCKFILE
36
+ MOCK
37
+ remote: source-a
38
+ specs:
39
+ jelly (1.3.5)
40
+
41
+ DEPENDENCIES
42
+ jelly (!= 1.2.6, ~> 1.1)
43
+
44
+ LOCKFILE
45
+ end
46
+
47
+ it "should give a list of one dependency" do
48
+ resolution.should have(1).dependencies
49
+ end
50
+
51
+ it "should give a dependency with the expected name" do
52
+ dependency = resolution.dependencies.first
53
+
54
+ dependency.name.should == "jelly"
55
+ end
56
+
57
+ it "should give a dependency with the expected requirement" do
58
+ dependency = resolution.dependencies.first
59
+
60
+ # Note: it must be this order because this order is lexicographically sorted.
61
+ dependency.requirement.to_s.should == "!= 1.2.6, ~> 1.1"
62
+ end
63
+
64
+ it "should give a dependency wth the expected source" do
65
+ dependency = resolution.dependencies.first
66
+ source = dependency.source
67
+
68
+ source.name.should == "source-a"
69
+ end
70
+
71
+ it "should give a list of one manifest" do
72
+ resolution.should have(1).manifests
73
+ end
74
+
75
+ it "should give a manifest with the expected name" do
76
+ manifest = resolution.manifests.first
77
+
78
+ manifest.name.should == "jelly"
79
+ end
80
+
81
+ it "should give a manifest with the expected version" do
82
+ manifest = resolution.manifests.first
83
+
84
+ manifest.version.to_s.should == "1.3.5"
85
+ end
86
+
87
+ it "should give a manifest with no dependencies" do
88
+ manifest = resolution.manifests.first
89
+
90
+ manifest.dependencies.should be_empty
91
+ end
92
+
93
+ it "should give a manifest with the expected source" do
94
+ manifest = resolution.manifests.first
95
+ source = manifest.source
96
+
97
+ source.name.should == "source-a"
98
+ end
99
+
100
+ it "should give the dependency and the manifest the same source instance" do
101
+ dependency = resolution.dependencies.first
102
+ manifest = resolution.manifests.first
103
+
104
+ dependency_source = dependency.source
105
+ manifest_source = manifest.source
106
+
107
+ manifest_source.should be dependency_source
108
+ end
109
+ end
110
+
111
+ context "a mock lockfile with one source and a complex dependency" do
112
+ let(:lockfile) do
113
+ Helpers.strip_heredoc <<-LOCKFILE
114
+ MOCK
115
+ remote: source-a
116
+ specs:
117
+ butter (2.5.3)
118
+ jelly (1.3.5)
119
+ butter (< 3, >= 1.1)
120
+
121
+ DEPENDENCIES
122
+ jelly (!= 1.2.6, ~> 1.1)
123
+
124
+ LOCKFILE
125
+ end
126
+
127
+ it "should give a list of one dependency" do
128
+ resolution.should have(1).dependencies
129
+ end
130
+
131
+ it "should have the expected dependency" do
132
+ dependency = resolution.dependencies.first
133
+
134
+ dependency.name.should == "jelly"
135
+ end
136
+
137
+ it "should give a list of all the manifests" do
138
+ resolution.should have(2).manifests
139
+ end
140
+
141
+ it "should include all the expected manifests" do
142
+ manifests = ManifestSet.new(resolution.manifests)
143
+
144
+ manifests.to_hash.keys.should =~ %w(butter jelly)
145
+ end
146
+
147
+ it "should have an internally consistent set of manifests" do
148
+ manifests = ManifestSet.new(resolution.manifests)
149
+
150
+ manifests.should be_consistent
151
+ end
152
+
153
+ it "should have an externally consistent set of manifests" do
154
+ dependencies = resolution.dependencies
155
+ manifests = ManifestSet.new(resolution.manifests)
156
+
157
+ manifests.should be_in_compliance_with dependencies
158
+ end
159
+ end
160
+
161
+ end
162
+ end
@@ -0,0 +1,65 @@
1
+ require 'librarian'
2
+ require 'librarian/mock'
3
+
4
+ module Librarian
5
+ describe Lockfile do
6
+
7
+ let(:env) { Mock::Environment.new }
8
+
9
+ before do
10
+ env.registry :clear => true do
11
+ source 'source-1' do
12
+ spec 'alpha', '1.1'
13
+ end
14
+ end
15
+ end
16
+
17
+ let(:spec) do
18
+ env.dsl do
19
+ src 'source-1'
20
+ dep 'alpha', '1.1'
21
+ end
22
+ end
23
+
24
+ let(:resolver) { env.resolver }
25
+ let(:resolution) { resolver.resolve(spec) }
26
+
27
+ context "sanity" do
28
+ context "the resolution" do
29
+ subject { resolution }
30
+
31
+ it { should be_correct }
32
+ it { should have(1).manifests }
33
+ end
34
+ end
35
+
36
+ describe "#save" do
37
+ let(:lockfile) { env.ephemeral_lockfile }
38
+ let(:lockfile_text) { lockfile.save(resolution) }
39
+
40
+ context "just saving" do
41
+ it "should return the lockfile text" do
42
+ lockfile_text.should_not be_nil
43
+ end
44
+ end
45
+
46
+ context "saving and reloading" do
47
+ let(:reloaded_resolution) { lockfile.load(lockfile_text) }
48
+
49
+ it "should have the expected manifests" do
50
+ reloaded_resolution.manifests.count.should == resolution.manifests.count
51
+ end
52
+ end
53
+
54
+ context "bouncing" do
55
+ let(:bounced_resolution) { lockfile.load(lockfile_text) }
56
+ let(:bounced_lockfile_text) { lockfile.save(bounced_resolution) }
57
+
58
+ it "should return the same lockfile text after bouncing as before bouncing" do
59
+ bounced_lockfile_text.should == lockfile_text
60
+ end
61
+ end
62
+ end
63
+
64
+ end
65
+ end