puppet_forge 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f48d6266af226aa37df713b0e1e3f72d44dc574e
4
+ data.tar.gz: 70d063373704bfed1c60455cc305a67daa61bb23
5
+ SHA512:
6
+ metadata.gz: a23339d6b315cd7415c5b7421a16df9aaee54c4dc3940f5b803cc8a6896356bf984a8c01ce4cda19bd25ad94d08683569f50420837cb052478cbd0afd22b20ae
7
+ data.tar.gz: f13dc0acd460860e8d9f94d99206c93305abce3a87bebaaf60845a423d4a173018da8a813e39aa0f40bbfbf728fbe4d08ab7c0a04f77dcb4e9378afe62b7fb30
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
+ ## v2.1.4 - 2016-04-01
7
+
8
+ ### Changed
9
+
10
+ * Bug in usage of minitar filenames led to ignored tar files with tar file length of >100 chars.
11
+
6
12
  ## v2.1.3 - 2016-01-25
7
13
 
8
14
  ### Changed
@@ -34,13 +34,20 @@ module PuppetForge
34
34
  @authorization
35
35
  end
36
36
 
37
+ # @param reset_connection [Boolean] flag to create a new connection every time this is called
38
+ # @param opts [Hash] Hash of connection options for Faraday
37
39
  # @return [Faraday::Connection] An existing Faraday connection if one was
38
40
  # already set, otherwise a new Faraday connection.
39
- def conn
40
- @conn ||= default_connection
41
+ def conn(reset_connection = nil, opts = {})
42
+ if reset_connection
43
+ default_connection(opts)
44
+ else
45
+ @conn ||= default_connection(opts)
46
+ end
41
47
  end
42
48
 
43
- def default_connection
49
+ # @param opts [Hash] Hash of connection options for Faraday
50
+ def default_connection(opts = {})
44
51
 
45
52
  begin
46
53
  # Use Typhoeus if available.
@@ -51,13 +58,14 @@ module PuppetForge
51
58
  adapter = Faraday.default_adapter
52
59
  end
53
60
 
54
- make_connection(PuppetForge.host, [adapter])
61
+ make_connection(PuppetForge.host, [adapter], opts)
55
62
  end
56
63
  module_function :default_connection
57
64
 
58
65
  # Generate a new Faraday connection for the given URL.
59
66
  #
60
67
  # @param url [String] the base URL for this connection
68
+ # @param opts [Hash] Hash of connection options for Faraday
61
69
  # @return [Faraday::Connection]
62
70
  def make_connection(url, adapter_args = nil, opts = {})
63
71
  adapter_args ||= [Faraday.default_adapter]
@@ -53,11 +53,11 @@ module PuppetForge
53
53
  Archive::Tar::Minitar.open(tarfile).each do |entry|
54
54
  flag = entry.typeflag
55
55
  if flag.nil? || flag =~ /[[:digit:]]/ && SYMLINK_FLAGS.include?(flag.to_i)
56
- file_lists[:symlinks] << entry.name
56
+ file_lists[:symlinks] << entry.full_name
57
57
  elsif flag.nil? || flag =~ /[[:digit:]]/ && VALID_TAR_FLAGS.include?(flag.to_i)
58
- file_lists[:valid] << entry.name
58
+ file_lists[:valid] << entry.full_name
59
59
  else
60
- file_lists[:invalid] << entry.name
60
+ file_lists[:invalid] << entry.full_name
61
61
  end
62
62
  end
63
63
  file_lists
@@ -54,12 +54,12 @@ module PuppetForge
54
54
  end
55
55
 
56
56
  # @private
57
- def request(resource, item = nil, params = {})
57
+ def request(resource, item = nil, params = {}, reset_connection = false, conn_opts = {})
58
+ conn(reset_connection, conn_opts) if reset_connection
58
59
  unless conn.url_prefix =~ /^#{PuppetForge.host}/
59
60
  conn.url_prefix = "#{PuppetForge.host}"
60
61
  end
61
62
 
62
-
63
63
  if item.nil?
64
64
  uri_path = "/v3/#{resource}"
65
65
  else
@@ -69,32 +69,64 @@ module PuppetForge
69
69
  PuppetForge::V3::Base.conn.get uri_path, params
70
70
  end
71
71
 
72
- def find(slug)
72
+ # @private
73
+ def find_request(slug, reset_connection = false, conn_opts = {})
73
74
  return nil if slug.nil?
74
75
 
75
- resp = request("#{self.name.split("::").last.downcase}s", slug)
76
+ resp = request("#{self.name.split("::").last.downcase}s", slug, {}, reset_connection, conn_opts)
76
77
 
77
78
  self.new(resp.body)
78
79
  end
79
80
 
80
- def where(params)
81
- resp = request("#{self.name.split("::").last.downcase}s", nil, params)
81
+ def find(slug)
82
+ find_request(slug)
83
+ end
84
+
85
+ def find_stateless(slug, conn_opts = {})
86
+ find_request(slug, true, conn_opts)
87
+ end
88
+
89
+ # @private
90
+ def where_request(params, reset_connection = false, conn_opts = {})
91
+ resp = request("#{self.name.split("::").last.downcase}s", nil, params, reset_connection, conn_opts)
82
92
 
83
93
  new_collection(resp)
84
94
  end
85
95
 
96
+ def where(params)
97
+ where_request(params)
98
+ end
99
+
100
+ def where_stateless(params, conn_opts = {})
101
+ where_request(params, true, conn_opts)
102
+ end
103
+
86
104
  # Return a paginated collection of all modules
87
105
  def all(params = {})
88
106
  where(params)
89
107
  end
90
108
 
91
- def get_collection(uri_path)
109
+ # Return a paginated collection of all modules
110
+ def all_stateless(params = {}, conn_opts = {})
111
+ where_stateless(params, conn_opts)
112
+ end
113
+
114
+ # @private
115
+ def get_collection_request(uri_path, reset_connection = false, conn_opts = {})
92
116
  resource, params = split_uri_path uri_path
93
- resp = request(resource, nil, params)
117
+ resp = request(resource, nil, params, reset_connection, conn_opts)
94
118
 
95
119
  new_collection(resp)
96
120
  end
97
121
 
122
+ def get_collection(uri_path)
123
+ get_collection_request(uri_path)
124
+ end
125
+
126
+ def get_collection_stateless(uri_path, conn_opts)
127
+ get_collection_request(uri_path, true, conn_opts)
128
+ end
129
+
98
130
  # Faraday's Util#escape method will replace a '+' with '%2B' to prevent it being
99
131
  # interpreted as a space. For compatibility with the Forge API, we would like a '+'
100
132
  # to be interpreted as a space so they are changed to spaces here.
@@ -1,3 +1,3 @@
1
1
  module PuppetForge
2
- VERSION = '2.1.3' # Library version
2
+ VERSION = '2.1.4' # Library version
3
3
  end
@@ -10,11 +10,16 @@ describe PuppetForge::V3::Module do
10
10
  context "::find" do
11
11
  context "gets information on an existing module and" do
12
12
  let (:mod) { PuppetForge::V3::Module.find('puppetforgegemtesting-thorin') }
13
+ let (:mod_stateless) { PuppetForge::V3::Module.find_stateless('puppetforgegemtesting-thorin') }
13
14
 
14
15
  it "returns a PuppetForge::V3::Module." do
15
16
  expect(mod).to be_a(PuppetForge::V3::Module)
16
17
  end
17
18
 
19
+ it "returns a PuppetForge::V3::Module from a stateless call." do
20
+ expect(mod_stateless).to be_a(PuppetForge::V3::Module)
21
+ end
22
+
18
23
  it "exposes the API information." do
19
24
  expect(mod).to respond_to(:uri)
20
25
  expect(mod).to respond_to(:owner)
@@ -75,5 +80,41 @@ describe PuppetForge::V3::Module do
75
80
  end
76
81
  end
77
82
  end
83
+
84
+ context "::where_stateless" do
85
+ context "finds matching resources" do
86
+
87
+ it "only returns modules that match the query" do
88
+ modules = PuppetForge::V3::Module.where_stateless(:owner => 'puppetforgegemtesting')
89
+
90
+ expect(modules).to be_a(PuppetForge::V3::Base::PaginatedCollection)
91
+ modules.each do |mod|
92
+ expect(mod.owner.username).to eq('puppetforgegemtesting')
93
+ end
94
+
95
+ end
96
+
97
+ it "returns a paginated response" do
98
+ modules = PuppetForge::V3::Module.where_stateless(:owner => 'puppetforgegemtesting', :limit => 1)
99
+
100
+ expect(modules.limit).to eq(1)
101
+ expect(modules.total).to eq(2)
102
+
103
+ expect(modules.next).not_to be_nil
104
+ end
105
+
106
+ end
107
+
108
+ context "does not find matching resources" do
109
+ it "returns an empty PaginatedCollection" do
110
+ modules = PuppetForge::V3::Module.where_stateless(:owner => 'absentuser')
111
+
112
+ expect(modules).to be_a(PuppetForge::V3::Base::PaginatedCollection)
113
+
114
+ expect(modules.size).to eq(0)
115
+ expect(modules.empty?).to be(true)
116
+ end
117
+ end
118
+ end
78
119
  end
79
120
 
@@ -3,9 +3,10 @@ require 'spec_helper'
3
3
  describe PuppetForge::Tar::Mini do
4
4
  let(:entry_class) do
5
5
  Class.new do
6
- attr_accessor :typeflag, :name
7
- def initialize(name, typeflag)
6
+ attr_accessor :typeflag, :name, :full_name
7
+ def initialize(name, full_name, typeflag)
8
8
  @name = name
9
+ @full_name = full_name
9
10
  @typeflag = typeflag
10
11
  end
11
12
  end
@@ -15,9 +16,9 @@ describe PuppetForge::Tar::Mini do
15
16
  let(:sourcedir) { '/the/src/dir' }
16
17
  let(:destfile) { '/the/dest/file.tar.gz' }
17
18
  let(:minitar) { described_class.new }
18
- let(:tarfile_contents) { [entry_class.new('file', '0'), \
19
- entry_class.new('symlink', '2'), \
20
- entry_class.new('invalid', 'F')] }
19
+ let(:tarfile_contents) { [entry_class.new('file', 'full_file', '0'), \
20
+ entry_class.new('symlink', 'full_symlink', '2'), \
21
+ entry_class.new('invalid', 'full_invalid', 'F')] }
21
22
 
22
23
  it "unpacks a tar file" do
23
24
  unpacks_the_entry(:file_start, 'thefile')
@@ -66,13 +67,13 @@ describe PuppetForge::Tar::Mini do
66
67
 
67
68
  expect(Zlib::GzipReader).to receive(:open).with(sourcefile).and_yield(reader)
68
69
  expect(Archive::Tar::Minitar).to receive(:open).with(reader).and_return(tarfile_contents)
69
- expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, ['file']).and_yield(:file_start, 'thefile', nil)
70
-
70
+ expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, ['full_file']).and_yield(:file_start, 'thefile', nil)
71
+
71
72
  file_lists = minitar.unpack(sourcefile, destdir)
72
73
 
73
- expect(file_lists[:valid]).to eq(['file'])
74
- expect(file_lists[:invalid]).to eq(['invalid'])
75
- expect(file_lists[:symlinks]).to eq(['symlink'])
74
+ expect(file_lists[:valid]).to eq(['full_file'])
75
+ expect(file_lists[:invalid]).to eq(['full_invalid'])
76
+ expect(file_lists[:symlinks]).to eq(['full_symlink'])
76
77
  end
77
78
 
78
79
  def unpacks_the_entry(type, name)
@@ -17,12 +17,17 @@ describe PuppetForge::V3::Module do
17
17
 
18
18
  describe '::find' do
19
19
  let(:mod) { PuppetForge::V3::Module.find('puppetlabs-apache') }
20
+ let(:mod_stateless) { PuppetForge::V3::Module.find_stateless('puppetlabs-apache') }
20
21
  let(:missing_mod) { PuppetForge::V3::Module.find('absent-apache') }
21
22
 
22
23
  it 'can find modules that exist' do
23
24
  expect(mod.name).to eq('apache')
24
25
  end
25
26
 
27
+ it 'can find modules that exist from a stateless call' do
28
+ expect(mod_stateless.name).to eq('apache')
29
+ end
30
+
26
31
  it 'returns nil for non-existent modules' do
27
32
  expect { missing_mod }.to raise_error(Faraday::ResourceNotFound)
28
33
  end
metadata CHANGED
@@ -1,196 +1,173 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet_forge
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
5
- prerelease:
4
+ version: 2.1.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Puppet Labs
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2016-01-26 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: faraday
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.9.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.9.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: faraday_middleware
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.9.0
38
- - - <
34
+ - - "<"
39
35
  - !ruby/object:Gem::Version
40
36
  version: 0.11.0
41
37
  type: :runtime
42
38
  prerelease: false
43
39
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
40
  requirements:
46
- - - ! '>='
41
+ - - ">="
47
42
  - !ruby/object:Gem::Version
48
43
  version: 0.9.0
49
- - - <
44
+ - - "<"
50
45
  - !ruby/object:Gem::Version
51
46
  version: 0.11.0
52
47
  - !ruby/object:Gem::Dependency
53
48
  name: semantic_puppet
54
49
  requirement: !ruby/object:Gem::Requirement
55
- none: false
56
50
  requirements:
57
- - - ~>
51
+ - - "~>"
58
52
  - !ruby/object:Gem::Version
59
53
  version: 0.1.0
60
54
  type: :runtime
61
55
  prerelease: false
62
56
  version_requirements: !ruby/object:Gem::Requirement
63
- none: false
64
57
  requirements:
65
- - - ~>
58
+ - - "~>"
66
59
  - !ruby/object:Gem::Version
67
60
  version: 0.1.0
68
61
  - !ruby/object:Gem::Dependency
69
62
  name: minitar
70
63
  requirement: !ruby/object:Gem::Requirement
71
- none: false
72
64
  requirements:
73
- - - ! '>='
65
+ - - ">="
74
66
  - !ruby/object:Gem::Version
75
67
  version: '0'
76
68
  type: :runtime
77
69
  prerelease: false
78
70
  version_requirements: !ruby/object:Gem::Requirement
79
- none: false
80
71
  requirements:
81
- - - ! '>='
72
+ - - ">="
82
73
  - !ruby/object:Gem::Version
83
74
  version: '0'
84
75
  - !ruby/object:Gem::Dependency
85
76
  name: bundler
86
77
  requirement: !ruby/object:Gem::Requirement
87
- none: false
88
78
  requirements:
89
- - - ~>
79
+ - - "~>"
90
80
  - !ruby/object:Gem::Version
91
81
  version: '1.6'
92
82
  type: :development
93
83
  prerelease: false
94
84
  version_requirements: !ruby/object:Gem::Requirement
95
- none: false
96
85
  requirements:
97
- - - ~>
86
+ - - "~>"
98
87
  - !ruby/object:Gem::Version
99
88
  version: '1.6'
100
89
  - !ruby/object:Gem::Dependency
101
90
  name: rake
102
91
  requirement: !ruby/object:Gem::Requirement
103
- none: false
104
92
  requirements:
105
- - - ! '>='
93
+ - - ">="
106
94
  - !ruby/object:Gem::Version
107
95
  version: '0'
108
96
  type: :development
109
97
  prerelease: false
110
98
  version_requirements: !ruby/object:Gem::Requirement
111
- none: false
112
99
  requirements:
113
- - - ! '>='
100
+ - - ">="
114
101
  - !ruby/object:Gem::Version
115
102
  version: '0'
116
103
  - !ruby/object:Gem::Dependency
117
104
  name: rspec
118
105
  requirement: !ruby/object:Gem::Requirement
119
- none: false
120
106
  requirements:
121
- - - ~>
107
+ - - "~>"
122
108
  - !ruby/object:Gem::Version
123
109
  version: '3.0'
124
110
  type: :development
125
111
  prerelease: false
126
112
  version_requirements: !ruby/object:Gem::Requirement
127
- none: false
128
113
  requirements:
129
- - - ~>
114
+ - - "~>"
130
115
  - !ruby/object:Gem::Version
131
116
  version: '3.0'
132
117
  - !ruby/object:Gem::Dependency
133
118
  name: simplecov
134
119
  requirement: !ruby/object:Gem::Requirement
135
- none: false
136
120
  requirements:
137
- - - ! '>='
121
+ - - ">="
138
122
  - !ruby/object:Gem::Version
139
123
  version: '0'
140
124
  type: :development
141
125
  prerelease: false
142
126
  version_requirements: !ruby/object:Gem::Requirement
143
- none: false
144
127
  requirements:
145
- - - ! '>='
128
+ - - ">="
146
129
  - !ruby/object:Gem::Version
147
130
  version: '0'
148
131
  - !ruby/object:Gem::Dependency
149
132
  name: cane
150
133
  requirement: !ruby/object:Gem::Requirement
151
- none: false
152
134
  requirements:
153
- - - ! '>='
135
+ - - ">="
154
136
  - !ruby/object:Gem::Version
155
137
  version: '0'
156
138
  type: :development
157
139
  prerelease: false
158
140
  version_requirements: !ruby/object:Gem::Requirement
159
- none: false
160
141
  requirements:
161
- - - ! '>='
142
+ - - ">="
162
143
  - !ruby/object:Gem::Version
163
144
  version: '0'
164
145
  - !ruby/object:Gem::Dependency
165
146
  name: yard
166
147
  requirement: !ruby/object:Gem::Requirement
167
- none: false
168
148
  requirements:
169
- - - ! '>='
149
+ - - ">="
170
150
  - !ruby/object:Gem::Version
171
151
  version: '0'
172
152
  type: :development
173
153
  prerelease: false
174
154
  version_requirements: !ruby/object:Gem::Requirement
175
- none: false
176
155
  requirements:
177
- - - ! '>='
156
+ - - ">="
178
157
  - !ruby/object:Gem::Version
179
158
  version: '0'
180
159
  - !ruby/object:Gem::Dependency
181
160
  name: redcarpet
182
161
  requirement: !ruby/object:Gem::Requirement
183
- none: false
184
162
  requirements:
185
- - - ! '>='
163
+ - - ">="
186
164
  - !ruby/object:Gem::Version
187
165
  version: '0'
188
166
  type: :development
189
167
  prerelease: false
190
168
  version_requirements: !ruby/object:Gem::Requirement
191
- none: false
192
169
  requirements:
193
- - - ! '>='
170
+ - - ">="
194
171
  - !ruby/object:Gem::Version
195
172
  version: '0'
196
173
  description: Tools that can be used to access Forge API information on Modules, Users,
@@ -201,7 +178,7 @@ executables: []
201
178
  extensions: []
202
179
  extra_rdoc_files: []
203
180
  files:
204
- - .gitignore
181
+ - ".gitignore"
205
182
  - CHANGELOG.md
206
183
  - Gemfile
207
184
  - LICENSE.txt
@@ -275,30 +252,26 @@ files:
275
252
  homepage: https://github.com/puppetlabs/forge-ruby
276
253
  licenses:
277
254
  - Apache-2.0
255
+ metadata: {}
278
256
  post_install_message:
279
257
  rdoc_options: []
280
258
  require_paths:
281
259
  - lib
282
260
  required_ruby_version: !ruby/object:Gem::Requirement
283
- none: false
284
261
  requirements:
285
- - - ! '>='
262
+ - - ">="
286
263
  - !ruby/object:Gem::Version
287
264
  version: 1.9.3
288
265
  required_rubygems_version: !ruby/object:Gem::Requirement
289
- none: false
290
266
  requirements:
291
- - - ! '>='
267
+ - - ">="
292
268
  - !ruby/object:Gem::Version
293
269
  version: '0'
294
- segments:
295
- - 0
296
- hash: -3937561798561843992
297
270
  requirements: []
298
271
  rubyforge_project:
299
- rubygems_version: 1.8.29
272
+ rubygems_version: 2.2.5
300
273
  signing_key:
301
- specification_version: 3
274
+ specification_version: 4
302
275
  summary: Access the Puppet Forge API from Ruby for resource information and to download
303
276
  releases.
304
277
  test_files:
@@ -347,4 +320,3 @@ test_files:
347
320
  - spec/unit/forge/v3/module_spec.rb
348
321
  - spec/unit/forge/v3/release_spec.rb
349
322
  - spec/unit/forge/v3/user_spec.rb
350
- has_rdoc: