puppet_forge 2.3.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby-rspec.yml +2 -2
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/puppet_forge/connection.rb +2 -4
- data/lib/puppet_forge/version.rb +1 -1
- data/puppet_forge.gemspec +6 -6
- data/spec/spec_helper.rb +1 -2
- data/spec/unit/forge/connection_spec.rb +3 -3
- data/spec/unit/forge/v3/metadata_spec.rb +0 -40
- metadata +12 -34
- data/lib/puppet_forge/middleware/symbolify_json.rb +0 -72
- data/spec/unit/forge/middleware/symbolify_json_spec.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 04e64600a52c57a9fef2dce82516632a77e196b1778b2082c925def0ecdbf734
|
4
|
+
data.tar.gz: 660cb79c76d923bbe6f101f68f01d913800625688ba59f61152d697054f967bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2199cd27949a3de2c7869bcffea4b489b03aee703b5a1fdb9cac4b9447a90160ecf731cd549b1c8edcfeeb560a6352c0df3836daf2e22d2fdf5290f95f6f9f0b
|
7
|
+
data.tar.gz: 2a0053e71e9bccd6cb9cb2168618344426ca9e829f1328f5ff97b1d7d644a164e2a3077f483f2bc0ce2a41078e7daeefaf2d3016730ded51fd24a6cca9b82750
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@
|
|
3
3
|
Starting with v2.0.0, all notable changes to this project will be documented in this file.
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## v3.0.0 - 2021-01-28
|
7
|
+
|
8
|
+
* Breaking: The `puppet_forge` gem now requires at least Ruby 2.4.0.
|
9
|
+
* Update `faraday` and `faraday_middleware` gem dependencies to 1.x series.
|
10
|
+
* Update optional `typhoeus` dependency to `>= 1.4` to maintain compatibility with `faraday`.
|
11
|
+
|
6
12
|
## v2.3.4 - 2020-03-31
|
7
13
|
|
8
14
|
* Update the forge API url to `forgeapi.puppet.com` (instead of using the older puppetlabs.com domain).
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@ require 'puppet_forge/connection/connection_failure'
|
|
2
2
|
|
3
3
|
require 'faraday'
|
4
4
|
require 'faraday_middleware'
|
5
|
-
require 'puppet_forge/middleware/symbolify_json'
|
6
5
|
|
7
6
|
module PuppetForge
|
8
7
|
# Provide a common mixin for adding a HTTP connection to classes.
|
@@ -81,7 +80,7 @@ module PuppetForge
|
|
81
80
|
|
82
81
|
begin
|
83
82
|
# Use Typhoeus if available.
|
84
|
-
Gem::Specification.find_by_name('typhoeus', '~> 1.
|
83
|
+
Gem::Specification.find_by_name('typhoeus', '~> 1.4')
|
85
84
|
require 'typhoeus/adapters/faraday'
|
86
85
|
adapter = :typhoeus
|
87
86
|
rescue Gem::LoadError
|
@@ -114,8 +113,7 @@ module PuppetForge
|
|
114
113
|
end
|
115
114
|
|
116
115
|
Faraday.new(url, options) do |builder|
|
117
|
-
builder.
|
118
|
-
builder.response(:json, :content_type => /\bjson$/)
|
116
|
+
builder.response(:json, :content_type => /\bjson$/, :parser_options => { :symbolize_names => true })
|
119
117
|
builder.response(:raise_error)
|
120
118
|
builder.use(:connection_failure)
|
121
119
|
|
data/lib/puppet_forge/version.rb
CHANGED
data/puppet_forge.gemspec
CHANGED
@@ -18,13 +18,13 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.required_ruby_version = '>=
|
21
|
+
spec.required_ruby_version = '>= 2.4.0'
|
22
22
|
|
23
|
-
spec.add_runtime_dependency "faraday",
|
24
|
-
spec.add_runtime_dependency "faraday_middleware",
|
25
|
-
spec.add_dependency
|
26
|
-
spec.add_dependency
|
27
|
-
spec.add_dependency
|
23
|
+
spec.add_runtime_dependency "faraday", "~> 1.3"
|
24
|
+
spec.add_runtime_dependency "faraday_middleware", "~> 1.0"
|
25
|
+
spec.add_dependency "semantic_puppet", "~> 1.0"
|
26
|
+
spec.add_dependency "minitar"
|
27
|
+
spec.add_dependency "gettext-setup", "~> 0.11"
|
28
28
|
|
29
29
|
spec.add_development_dependency "rake"
|
30
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
data/spec/spec_helper.rb
CHANGED
@@ -15,8 +15,7 @@ module StubbingFaraday
|
|
15
15
|
def stub_api_for(klass, base_url = "http://api.example.com")
|
16
16
|
allow(klass).to receive(:conn) do
|
17
17
|
Faraday.new :url => base_url do |builder|
|
18
|
-
builder.
|
19
|
-
builder.response(:json, :content_type => /\bjson$/)
|
18
|
+
builder.response(:json, :content_type => /\bjson$/, :parser_options => { :symbolize_names => true })
|
20
19
|
builder.response(:raise_error)
|
21
20
|
builder.use(:connection_failure)
|
22
21
|
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe PuppetForge::Connection do
|
4
4
|
before(:each) do
|
5
|
-
PuppetForge.host = "https://forgeapi.
|
5
|
+
PuppetForge.host = "https://forgeapi.puppet.com"
|
6
6
|
end
|
7
7
|
|
8
8
|
let(:test_conn) do
|
@@ -88,7 +88,7 @@ describe PuppetForge::Connection do
|
|
88
88
|
|
89
89
|
expect {
|
90
90
|
subject.get('/error')
|
91
|
-
}.to raise_error(Faraday::
|
91
|
+
}.to raise_error(Faraday::ServerError, "the server responded with status 503")
|
92
92
|
end
|
93
93
|
|
94
94
|
context 'when an authorization value is provided' do
|
@@ -115,7 +115,7 @@ describe PuppetForge::Connection do
|
|
115
115
|
describe 'creating a default connection' do
|
116
116
|
it 'creates a connection with the PuppetForge host' do
|
117
117
|
conn = test_conn.default_connection
|
118
|
-
expect(conn.url_prefix.to_s).to eq 'https://forgeapi.
|
118
|
+
expect(conn.url_prefix.to_s).to eq 'https://forgeapi.puppet.com/'
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -168,14 +168,6 @@ describe PuppetForge::Metadata do
|
|
168
168
|
|
169
169
|
end
|
170
170
|
|
171
|
-
context "with a valid dependency", :pending => "dependency resolution is not yet in scope" do
|
172
|
-
let(:data) { {'dependencies' => [{'name' => 'puppetlabs-goodmodule'}] }}
|
173
|
-
|
174
|
-
it "adds the dependency" do
|
175
|
-
expect(subject.dependencies.size).to eq(1)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
171
|
context "with a invalid dependency name" do
|
180
172
|
let(:data) { {'dependencies' => [{'name' => 'puppetlabsbadmodule'}] }}
|
181
173
|
|
@@ -184,14 +176,6 @@ describe PuppetForge::Metadata do
|
|
184
176
|
end
|
185
177
|
end
|
186
178
|
|
187
|
-
context "with a valid dependency version range", :pending => "dependency resolution is not yet in scope" do
|
188
|
-
let(:data) { {'dependencies' => [{'name' => 'puppetlabs-badmodule', 'version_requirement' => '>= 2.0.0'}] }}
|
189
|
-
|
190
|
-
it "adds the dependency" do
|
191
|
-
expect(subject.dependencies.size).to eq(1)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
179
|
context "with a invalid version range" do
|
196
180
|
let(:data) { {'dependencies' => [{'name' => 'puppetlabsbadmodule', 'version_requirement' => '>= banana'}] }}
|
197
181
|
|
@@ -199,30 +183,6 @@ describe PuppetForge::Metadata do
|
|
199
183
|
expect { subject }.to raise_error(ArgumentError)
|
200
184
|
end
|
201
185
|
end
|
202
|
-
|
203
|
-
context "with duplicate dependencies", :pending => "dependency resolution is not yet in scope" do
|
204
|
-
let(:data) { {'dependencies' => [{'name' => 'puppetlabs-dupmodule', 'version_requirement' => '1.0.0'},
|
205
|
-
{'name' => 'puppetlabs-dupmodule', 'version_requirement' => '0.0.1'}] }
|
206
|
-
}
|
207
|
-
|
208
|
-
it "raises an exception" do
|
209
|
-
expect { subject }.to raise_error(ArgumentError)
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
context "adding a duplicate dependency", :pending => "dependency resolution is not yet in scope" do
|
214
|
-
let(:data) { {'dependencies' => [{'name' => 'puppetlabs-origmodule', 'version_requirement' => '1.0.0'}] }}
|
215
|
-
|
216
|
-
it "with a different version raises an exception" do
|
217
|
-
metadata.add_dependency('puppetlabs-origmodule', '>= 0.0.1')
|
218
|
-
expect { subject }.to raise_error(ArgumentError)
|
219
|
-
end
|
220
|
-
|
221
|
-
it "with the same version does not add another dependency" do
|
222
|
-
metadata.add_dependency('puppetlabs-origmodule', '1.0.0')
|
223
|
-
expect(subject.dependencies.size).to eq(1)
|
224
|
-
end
|
225
|
-
end
|
226
186
|
end
|
227
187
|
|
228
188
|
describe '#dashed_name' do
|
metadata
CHANGED
@@ -1,61 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet_forge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.9.0
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 0.18.0
|
23
|
-
- - "!="
|
17
|
+
- - "~>"
|
24
18
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
19
|
+
version: '1.3'
|
26
20
|
type: :runtime
|
27
21
|
prerelease: false
|
28
22
|
version_requirements: !ruby/object:Gem::Requirement
|
29
23
|
requirements:
|
30
|
-
- - "
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 0.9.0
|
33
|
-
- - "<"
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 0.18.0
|
36
|
-
- - "!="
|
24
|
+
- - "~>"
|
37
25
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
26
|
+
version: '1.3'
|
39
27
|
- !ruby/object:Gem::Dependency
|
40
28
|
name: faraday_middleware
|
41
29
|
requirement: !ruby/object:Gem::Requirement
|
42
30
|
requirements:
|
43
|
-
- - "
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 0.9.0
|
46
|
-
- - "<"
|
31
|
+
- - "~>"
|
47
32
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
33
|
+
version: '1.0'
|
49
34
|
type: :runtime
|
50
35
|
prerelease: false
|
51
36
|
version_requirements: !ruby/object:Gem::Requirement
|
52
37
|
requirements:
|
53
|
-
- - "
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 0.9.0
|
56
|
-
- - "<"
|
38
|
+
- - "~>"
|
57
39
|
- !ruby/object:Gem::Version
|
58
|
-
version:
|
40
|
+
version: '1.0'
|
59
41
|
- !ruby/object:Gem::Dependency
|
60
42
|
name: semantic_puppet
|
61
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -218,7 +200,6 @@ files:
|
|
218
200
|
- lib/puppet_forge/error.rb
|
219
201
|
- lib/puppet_forge/lazy_accessors.rb
|
220
202
|
- lib/puppet_forge/lazy_relations.rb
|
221
|
-
- lib/puppet_forge/middleware/symbolify_json.rb
|
222
203
|
- lib/puppet_forge/tar.rb
|
223
204
|
- lib/puppet_forge/tar/mini.rb
|
224
205
|
- lib/puppet_forge/unpacker.rb
|
@@ -269,7 +250,6 @@ files:
|
|
269
250
|
- spec/unit/forge/connection_spec.rb
|
270
251
|
- spec/unit/forge/lazy_accessors_spec.rb
|
271
252
|
- spec/unit/forge/lazy_relations_spec.rb
|
272
|
-
- spec/unit/forge/middleware/symbolify_json_spec.rb
|
273
253
|
- spec/unit/forge/tar/mini_spec.rb
|
274
254
|
- spec/unit/forge/tar_spec.rb
|
275
255
|
- spec/unit/forge/unpacker_spec.rb
|
@@ -293,15 +273,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
293
273
|
requirements:
|
294
274
|
- - ">="
|
295
275
|
- !ruby/object:Gem::Version
|
296
|
-
version:
|
276
|
+
version: 2.4.0
|
297
277
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
298
278
|
requirements:
|
299
279
|
- - ">="
|
300
280
|
- !ruby/object:Gem::Version
|
301
281
|
version: '0'
|
302
282
|
requirements: []
|
303
|
-
|
304
|
-
rubygems_version: 2.6.14
|
283
|
+
rubygems_version: 3.0.8
|
305
284
|
signing_key:
|
306
285
|
specification_version: 4
|
307
286
|
summary: Access the Puppet Forge API from Ruby for resource information and to download
|
@@ -343,7 +322,6 @@ test_files:
|
|
343
322
|
- spec/unit/forge/connection_spec.rb
|
344
323
|
- spec/unit/forge/lazy_accessors_spec.rb
|
345
324
|
- spec/unit/forge/lazy_relations_spec.rb
|
346
|
-
- spec/unit/forge/middleware/symbolify_json_spec.rb
|
347
325
|
- spec/unit/forge/tar/mini_spec.rb
|
348
326
|
- spec/unit/forge/tar_spec.rb
|
349
327
|
- spec/unit/forge/unpacker_spec.rb
|
@@ -1,72 +0,0 @@
|
|
1
|
-
module PuppetForge
|
2
|
-
module Middleware
|
3
|
-
|
4
|
-
# SymbolifyJson is a Faraday Middleware that will process any response formatted as a hash
|
5
|
-
# and change all the keys into symbols (as long as they respond to the method #to_sym.
|
6
|
-
#
|
7
|
-
# This middleware makes no changes to the values of the hash.
|
8
|
-
# If the response is not a hash, no changes will be made.
|
9
|
-
class SymbolifyJson < Faraday::Middleware
|
10
|
-
|
11
|
-
# Processes an array
|
12
|
-
#
|
13
|
-
# @return an array with any hash's keys turned into symbols if possible
|
14
|
-
def process_array(array)
|
15
|
-
array.map do |arg|
|
16
|
-
# Search any arrays and hashes for hash keys
|
17
|
-
if arg.is_a? Hash
|
18
|
-
process_hash(arg)
|
19
|
-
elsif arg.is_a? Array
|
20
|
-
process_array(arg)
|
21
|
-
else
|
22
|
-
arg
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Processes a hash
|
28
|
-
#
|
29
|
-
# @return a hash with all keys turned into symbols if possible
|
30
|
-
def process_hash(hash)
|
31
|
-
|
32
|
-
# hash.map returns an array in the format
|
33
|
-
# [ [key, value], [key2, value2], ... ]
|
34
|
-
# Hash[] converts that into a hash in the format
|
35
|
-
# { key => value, key2 => value2, ... }
|
36
|
-
Hash[hash.map do |key, val|
|
37
|
-
# Convert to a symbol if possible
|
38
|
-
if key.respond_to? :to_sym
|
39
|
-
new_key = key.to_sym
|
40
|
-
else
|
41
|
-
new_key = key
|
42
|
-
end
|
43
|
-
|
44
|
-
# If value is a hash or array look for more hash keys inside.
|
45
|
-
if val.is_a?(Hash)
|
46
|
-
[new_key, process_hash(val)]
|
47
|
-
elsif val.is_a?(Array)
|
48
|
-
[new_key, process_array(val)]
|
49
|
-
else
|
50
|
-
[new_key, val]
|
51
|
-
end
|
52
|
-
end]
|
53
|
-
end
|
54
|
-
|
55
|
-
def process_response(env)
|
56
|
-
if !env["body"].nil? && env["body"].is_a?(Hash)
|
57
|
-
process_hash(env.body)
|
58
|
-
else
|
59
|
-
env.body
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def call(environment)
|
64
|
-
@app.call(environment).on_complete do |env|
|
65
|
-
env.body = process_response(env)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PuppetForge::Middleware::SymbolifyJson do
|
4
|
-
let(:basic_array) { [1, "two", 3] }
|
5
|
-
let(:basic_hash) { { "id" => 1, "data" => "x" } }
|
6
|
-
let(:symbolified_hash) { { :id => 1, :data => "x" } }
|
7
|
-
let(:internal_hash) { { :id => 2, :data => basic_hash } }
|
8
|
-
|
9
|
-
let(:hash_with_array) { { "id" => 3, "data" => basic_array } }
|
10
|
-
let(:array_with_hash) { [1, "two", basic_hash] }
|
11
|
-
|
12
|
-
let(:complex_array) { [array_with_hash, hash_with_array] }
|
13
|
-
let(:complex_hash) { { "id" => 4, "data" => [complex_array, basic_array], "more_data" => hash_with_array } }
|
14
|
-
let(:complex_request) { { "id" => 5, "data" => complex_hash } }
|
15
|
-
|
16
|
-
let(:middleware) { described_class.new() }
|
17
|
-
|
18
|
-
context "#process_array" do
|
19
|
-
it "doesn't change an array with no array or hash inside" do
|
20
|
-
processed_array = middleware.process_array(basic_array)
|
21
|
-
expect(processed_array).to eql( [1, "two", 3] )
|
22
|
-
end
|
23
|
-
|
24
|
-
it "changes all keys of a hash inside the array" do
|
25
|
-
processed_array = middleware.process_array(array_with_hash)
|
26
|
-
expect(processed_array).to eql( [ 1, "two", { :id => 1, :data => "x" } ] )
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "#process_hash" do
|
31
|
-
it "changes all keys that respond to :to_sym into Symbols and doesn't change values." do
|
32
|
-
processed_hash = middleware.process_hash(basic_hash)
|
33
|
-
expect(processed_hash).to eql( { :id => 1, :data => "x" } )
|
34
|
-
end
|
35
|
-
|
36
|
-
it "doesn't change keys that don't respond to :to_sym" do
|
37
|
-
processed_hash = middleware.process_hash(basic_hash.merge({ 1 => 2 }))
|
38
|
-
expect(processed_hash).to eql( { :id => 1, :data => "x", 1 => 2 } )
|
39
|
-
end
|
40
|
-
|
41
|
-
it "can process a hash that is already symbolified" do
|
42
|
-
processed_hash = middleware.process_hash(symbolified_hash)
|
43
|
-
expect(processed_hash).to eql( { :id => 1, :data => "x" })
|
44
|
-
end
|
45
|
-
|
46
|
-
it "can process a hash with a hash inside of it" do
|
47
|
-
processed_hash = middleware.process_hash(internal_hash)
|
48
|
-
expect(processed_hash).to eql( {:id => 2, :data => { :id => 1, :data => "x" } })
|
49
|
-
end
|
50
|
-
|
51
|
-
it "can process a hash with an array inside of it" do
|
52
|
-
processed_hash = middleware.process_hash(hash_with_array)
|
53
|
-
expect(processed_hash).to eql( { :id => 3, :data => [1, "two", 3] } )
|
54
|
-
end
|
55
|
-
|
56
|
-
it "can handle extensively nested arrays and hashes" do
|
57
|
-
processed_hash = middleware.process_hash(complex_request)
|
58
|
-
expect(processed_hash).to eql( { :id => 5, :data => { :id => 4 , :data=>[ [ [1, "two", { :id => 1, :data => "x" } ], { :id=>3, :data => [1, "two", 3] } ], [1, "two", 3] ], :more_data => { :id => 3, :data => [1, "two", 3] } } } )
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|