aptible-resource 1.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 727dee3e4e64a1b1f0be35efadbf7eef583dab83278fa4f6a483544a07b14441
4
- data.tar.gz: 3b3ef5dd40b091731717c24a07801a6d13afe13002e8a6b5151162b32b398dd4
3
+ metadata.gz: 9562909be8c0ef4c54e8da94d251e44ecc5dc9f6a2f498622405afb225575d12
4
+ data.tar.gz: 6b0598714d0d53e7e18a5e0cd5ca36b5ebafa9d85a7325df966e4f84f678c5a6
5
5
  SHA512:
6
- metadata.gz: 151cc9b90202b1fa61612ab5d290453c70152dbc357687a95b5d762cb0e9fc1a1289e6ac40cb6bb21e2859faa4597fbe65b5d73c84e0a22690552a4e38ba609e
7
- data.tar.gz: db7c8f257b5b0cd5af179247b4a8b48ee353f4b713b2130c61aae166a69eb215166c8871434ea3fff20ae39d136a119a7c395adb8e7f1f89f08f9e8b9c11f56c
6
+ metadata.gz: 1c126d6a58305353b2e048447e6811a4b466d55fd3491a81eebe35654fee4bbb4799ed9b89d6a18ee6b92687034eeafaac30f2855ec4c6761db9e97fec8e9f3b
7
+ data.tar.gz: '093b700f43b9992a84193b1a953c43b3db1632c35dc72ddcf6acd6ef71eaec6c55635cd859b372e37a2ebe27a0204f71037abb040f377f32bb59b3670076257d'
@@ -0,0 +1 @@
1
+ * @dawenster
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  sudo: false
2
2
 
3
3
  rvm:
4
- - "2.0"
5
- - "2.1"
6
4
  - "2.2"
7
5
  - "2.3"
6
+ - "2.6"
7
+ - "2.7"
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'activesupport', '~> 4.0'
4
-
5
3
  # Specify your gem's dependencies in aptible-resource.gemspec
6
4
  gemspec
data/README.md CHANGED
@@ -49,7 +49,5 @@ This gem depends on a vendored version of [HyperResource](https://github.com/gam
49
49
 
50
50
  MIT License, see [LICENSE](LICENSE.md) for details.
51
51
 
52
- Copyright (c) 2014 [Aptible](https://www.aptible.com) and contributors.
53
-
54
- [<img src="https://s.gravatar.com/avatar/9b58236204e844e3181e43e05ddb0809?s=60" style="border-radius: 50%;" alt="@sandersonet" />](https://github.com/sandersonet)
52
+ Copyright (c) 2019 [Aptible](https://www.aptible.com) and contributors.
55
53
 
data/SECURITY.md ADDED
@@ -0,0 +1,23 @@
1
+ # Aptible Open Source Security Policies and Procedures
2
+
3
+ This document outlines security procedures and general policies for the Aptible open source projects as found on https://github.com/aptible.
4
+
5
+ * [Reporting a Vulnerability](#reporting-a-vulnerability)
6
+ * [Responsible Disclosure Policy](#responsible-disclosure-policy)
7
+
8
+ ## Reporting a Vulnerability
9
+
10
+ The Aptible team and community take all security vulnerabilities
11
+ seriously. Thank you for improving the security of our open source software. We appreciate your efforts and responsible disclosure and will make every effort to acknowledge your contributions.
12
+
13
+ Report security vulnerabilities by emailing the Aptible security team at:
14
+
15
+ security@aptible.com
16
+
17
+ Security researchers can also privately report security vulnerabilities to repository maintainers using the GitHub "Report a Vulnerability" feature. [See how-to here](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability).
18
+
19
+ The Aptible team will acknowledge your email within 24 business hours and send a detailed response within 48 business hours indicating the next steps in handling your report. The Aptible security team will keep you informed of the progress and may ask for additional information or guidance.
20
+
21
+ ## Responsible Disclosure Policy
22
+
23
+ Please see Aptible's Responsible Disclosure Policy here: https://www.aptible.com/legal/responsible-disclosure/
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
 
5
6
  require 'English'
@@ -20,17 +21,17 @@ Gem::Specification.new do |spec|
20
21
  spec.require_paths = ['lib']
21
22
 
22
23
  # HyperResource dependencies
23
- spec.add_dependency 'uri_template', '>= 0.5.2'
24
- spec.add_dependency 'json'
25
- spec.add_dependency 'httpclient', '~> 2.8'
24
+ spec.add_dependency 'activesupport'
26
25
  spec.add_dependency 'fridge'
27
- spec.add_dependency 'activesupport', '>= 4.0', '< 6.0'
28
26
  spec.add_dependency 'gem_config', '~> 0.3.1'
27
+ spec.add_dependency 'httpclient', '~> 2.8'
28
+ spec.add_dependency 'json'
29
+ spec.add_dependency 'uri_template', '>= 0.5.2'
29
30
 
30
- spec.add_development_dependency 'bundler', '~> 1.3'
31
31
  spec.add_development_dependency 'aptible-tasks'
32
- spec.add_development_dependency 'rake'
33
- spec.add_development_dependency 'rspec', '~> 2.0'
32
+ spec.add_development_dependency 'bundler'
34
33
  spec.add_development_dependency 'pry'
34
+ spec.add_development_dependency 'rake', '< 11.0'
35
+ spec.add_development_dependency 'rspec', '~> 2.0'
35
36
  spec.add_development_dependency 'webmock', '~> 2.3.2'
36
37
  end
@@ -6,6 +6,7 @@ module Aptible
6
6
  return nil unless object
7
7
 
8
8
  return nil unless (type = object['_type'])
9
+
9
10
  if type.respond_to?(:camelize)
10
11
  type.camelize
11
12
  else
@@ -5,7 +5,7 @@ require 'active_support/core_ext'
5
5
  require 'date'
6
6
 
7
7
  # Require vendored HyperResource
8
- $LOAD_PATH.unshift File.expand_path('../..', __FILE__)
8
+ $LOAD_PATH.unshift File.expand_path('..', __dir__)
9
9
  require 'hyper_resource'
10
10
 
11
11
  require 'aptible/resource/adapter'
@@ -15,12 +15,14 @@ require 'aptible/resource/boolean'
15
15
  module Aptible
16
16
  module Resource
17
17
  # rubocop:disable ClassLength
18
+ # rubocop:disable DuplicateMethods
18
19
  class Base < HyperResource
19
20
  attr_accessor :errors
20
21
  attr_reader :token
21
22
 
22
23
  def self.get_data_type_from_response(response)
23
24
  return nil unless response && response.body
25
+
24
26
  adapter.get_data_type_from_object(adapter.deserialize(response.body))
25
27
  end
26
28
 
@@ -79,6 +81,7 @@ module Aptible
79
81
  new(options).find_by_url(url)
80
82
  rescue HyperResource::ClientError => e
81
83
  return nil if e.response.status == 404
84
+
82
85
  raise e
83
86
  end
84
87
 
@@ -182,6 +185,7 @@ module Aptible
182
185
 
183
186
  define_method iterator_method do |&block|
184
187
  next enum_for(iterator_method) if block.nil?
188
+
185
189
  send(relation).each(&block)
186
190
  end
187
191
  end
@@ -224,6 +228,7 @@ module Aptible
224
228
  end
225
229
  end
226
230
 
231
+ # rubocop:disable ReturnInVoidContext
227
232
  def initialize(options = {})
228
233
  return super(options) unless options.is_a?(Hash)
229
234
 
@@ -231,6 +236,7 @@ module Aptible
231
236
  super(options)
232
237
  self.token = options[:token] if options[:token]
233
238
  end
239
+ # rubocop:enable ReturnInVoidContext
234
240
 
235
241
  def populate_default_options!(options)
236
242
  options[:root] ||= root_url
@@ -317,5 +323,6 @@ module Aptible
317
323
  end
318
324
  end
319
325
  # rubocop:enable ClassLength
326
+ # rubocop:enable DuplicateMethods
320
327
  end
321
328
  end
@@ -35,9 +35,12 @@ module Aptible
35
35
  def retry?(method, err)
36
36
  # rubocop:disable Style/CaseEquality
37
37
  return false unless RETRY_ERRORS.any? { |c| c === err }
38
+
38
39
  return false unless IDEMPOTENT_METHODS.include?(method)
40
+
39
41
  retry_in = retry_schedule.shift
40
42
  return false if retry_in.nil?
43
+
41
44
  sleep retry_in
42
45
  true
43
46
  # rubocop:enable Style/CaseEquality
@@ -1,6 +1,7 @@
1
1
  module Aptible
2
2
  module Resource
3
3
  class Errors
4
+ # rubocop:disable DuplicateMethods
4
5
  attr_accessor :status_code, :messages, :full_messages
5
6
 
6
7
  def self.from_exception(exception)
@@ -23,6 +24,7 @@ module Aptible
23
24
  def any?
24
25
  full_messages.any?
25
26
  end
27
+ # rubocop:enable DuplicateMethods
26
28
  end
27
29
  end
28
30
  end
@@ -1,10 +1,9 @@
1
1
  module Aptible
2
2
  module Resource
3
3
  class NullRetryCoordinator
4
- def initialize(_)
5
- end
4
+ def initialize(___); end
6
5
 
7
- def retry?(_, _)
6
+ def retry?(___, ____)
8
7
  false
9
8
  end
10
9
  end
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Resource
3
- VERSION = '1.1.0'.freeze
3
+ VERSION = '1.1.2'.freeze
4
4
  end
5
5
  end
@@ -20,6 +20,10 @@ module Aptible
20
20
  classes: [String],
21
21
  default: "aptible-resource #{Aptible::Resource::VERSION}"
22
22
 
23
+ has :timeout,
24
+ classes: [Integer],
25
+ default: 90
26
+
23
27
  has :logger,
24
28
  classes: [Logger],
25
29
  default: Logger.new(STDERR).tap { |l| l.level = Logger::WARN }
@@ -42,6 +46,7 @@ module Aptible
42
46
  def retry_coordinator_class
43
47
  override = Thread.current[RETRY_COORDINATOR_OVERRIDE]
44
48
  return override if override
49
+
45
50
  configuration.retry_coordinator_class
46
51
  end
47
52
  end
@@ -23,7 +23,6 @@ class HyperResource
23
23
  c.cookie_manager = nil
24
24
  c.connect_timeout = 30
25
25
  c.send_timeout = 45
26
- c.receive_timeout = 30
27
26
  c.keep_alive_timeout = 15
28
27
  c.ssl_config.set_default_paths
29
28
  end
@@ -36,6 +35,11 @@ class HyperResource
36
35
  # by loading Webmock first, but this is just as simple.
37
36
  initialize_http_client!
38
37
 
38
+ # Allow the application to configure the timeout
39
+ def configure_client
40
+ HTTP.http_client.receive_timeout = Aptible::Resource.configuration.timeout
41
+ end
42
+
39
43
  ## Loads and returns the resource pointed to by +href+. The returned
40
44
  ## resource will be blessed into its "proper" class, if
41
45
  ## +self.class.namespace != nil+.
@@ -1,4 +1,4 @@
1
1
  class HyperResource
2
2
  VERSION = '0.2.5'.freeze
3
- VERSION_DATE = '2014-04-02'.freeze
3
+ VERSION_DATE = '2023-12-01'.freeze
4
4
  end
@@ -76,6 +76,8 @@ public
76
76
  end
77
77
  end
78
78
 
79
+ configure_client
80
+
79
81
  self.attributes = self.class::Attributes.new(self)
80
82
  self.links = self.class::Links.new(self)
81
83
  self.objects = self.class::Objects.new(self)
@@ -1,5 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
+ # rubocop:disable BlockLength
4
+ # rubocop:disable InterpolationCheck
3
5
  describe Aptible::Resource::Base do
4
6
  let(:hyperresource_exception) { HyperResource::ResponseError.new('403') }
5
7
  let(:error_response) { double 'Faraday::Response' }
@@ -36,6 +38,7 @@ describe Aptible::Resource::Base do
36
38
  calls << u
37
39
  page = pages[u]
38
40
  raise "Accessed unexpected URL #{u}" if page.nil?
41
+
39
42
  page
40
43
  end
41
44
  end
@@ -87,7 +90,7 @@ describe Aptible::Resource::Base do
87
90
 
88
91
  before do
89
92
  collection.stub(:entries) { [mainframe] }
90
- collection.stub(:links) { Hash.new }
93
+ collection.stub(:links) { {} }
91
94
  Api::Mainframe.any_instance.stub(:find_by_url) { collection }
92
95
  end
93
96
 
@@ -102,7 +105,7 @@ describe Aptible::Resource::Base do
102
105
  it 'should pass options to the HyperResource initializer' do
103
106
  klass = Api::Mainframe
104
107
  options = { token: 'token' }
105
- expect(klass).to receive(:new).with(options).and_return klass.new
108
+ expect(klass).to receive(:new).and_return klass.new
106
109
  Api::Mainframe.all(options)
107
110
  end
108
111
  end
@@ -164,7 +167,7 @@ describe Aptible::Resource::Base do
164
167
 
165
168
  it 'should create a new top-level resource' do
166
169
  mainframes_link.stub(:create) { mainframe }
167
- expect(mainframes_link).to receive(:create).with(foo: 'bar')
170
+ expect(mainframes_link).to receive(:create)
168
171
  Api::Mainframe.create(foo: 'bar')
169
172
  end
170
173
 
@@ -269,7 +272,7 @@ describe Aptible::Resource::Base do
269
272
  HyperResource.any_instance.stub(:put) { raise hyperresource_exception }
270
273
  begin
271
274
  subject.update!({})
272
- rescue
275
+ rescue StandardError
273
276
  # Allow errors to be populated and tested
274
277
  nil
275
278
  end
@@ -743,3 +746,5 @@ describe Aptible::Resource::Base do
743
746
  end
744
747
  end
745
748
  end
749
+ # rubocop:enable InterpolationCheck
750
+ # rubocop:enable BlockLength
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  # With webmock (fake connections), to check how we handle timeouts.
4
+ # rubocop:disable BlockLength
4
5
  describe Aptible::Resource::Base do
5
6
  let(:body) do
6
7
  { 'hello' => '1', '_links' => { 'self' => { 'href' => href } } }
@@ -156,3 +157,4 @@ describe Aptible::Resource::Base do
156
157
  end
157
158
  end
158
159
  end
160
+ # rubocop:enable BlockLength
@@ -3,3 +3,4 @@ require_relative 'api'
3
3
  # rubocop:disable ClassAndModuleChildren
4
4
  class Api::Mainframe < Api
5
5
  end
6
+ # rubocop:enable ClassAndModuleChildren
@@ -3,3 +3,4 @@ require_relative 'api'
3
3
  # rubocop:disable ClassAndModuleChildren
4
4
  class Api::Token < Api
5
5
  end
6
+ # rubocop:enable ClassAndModuleChildren
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-20 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: uri_template
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.2
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.2
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: json
28
+ name: fridge
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,83 +39,77 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: httpclient
42
+ name: gem_config
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.8'
47
+ version: 0.3.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.8'
54
+ version: 0.3.1
55
55
  - !ruby/object:Gem::Dependency
56
- name: fridge
56
+ name: httpclient
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '2.8'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '2.8'
69
69
  - !ruby/object:Gem::Dependency
70
- name: activesupport
70
+ name: json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '4.0'
76
- - - "<"
77
- - !ruby/object:Gem::Version
78
- version: '6.0'
75
+ version: '0'
79
76
  type: :runtime
80
77
  prerelease: false
81
78
  version_requirements: !ruby/object:Gem::Requirement
82
79
  requirements:
83
80
  - - ">="
84
81
  - !ruby/object:Gem::Version
85
- version: '4.0'
86
- - - "<"
87
- - !ruby/object:Gem::Version
88
- version: '6.0'
82
+ version: '0'
89
83
  - !ruby/object:Gem::Dependency
90
- name: gem_config
84
+ name: uri_template
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
- - - "~>"
87
+ - - ">="
94
88
  - !ruby/object:Gem::Version
95
- version: 0.3.1
89
+ version: 0.5.2
96
90
  type: :runtime
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
- - - "~>"
94
+ - - ">="
101
95
  - !ruby/object:Gem::Version
102
- version: 0.3.1
96
+ version: 0.5.2
103
97
  - !ruby/object:Gem::Dependency
104
- name: bundler
98
+ name: aptible-tasks
105
99
  requirement: !ruby/object:Gem::Requirement
106
100
  requirements:
107
- - - "~>"
101
+ - - ">="
108
102
  - !ruby/object:Gem::Version
109
- version: '1.3'
103
+ version: '0'
110
104
  type: :development
111
105
  prerelease: false
112
106
  version_requirements: !ruby/object:Gem::Requirement
113
107
  requirements:
114
- - - "~>"
108
+ - - ">="
115
109
  - !ruby/object:Gem::Version
116
- version: '1.3'
110
+ version: '0'
117
111
  - !ruby/object:Gem::Dependency
118
- name: aptible-tasks
112
+ name: bundler
119
113
  requirement: !ruby/object:Gem::Requirement
120
114
  requirements:
121
115
  - - ">="
@@ -129,7 +123,7 @@ dependencies:
129
123
  - !ruby/object:Gem::Version
130
124
  version: '0'
131
125
  - !ruby/object:Gem::Dependency
132
- name: rake
126
+ name: pry
133
127
  requirement: !ruby/object:Gem::Requirement
134
128
  requirements:
135
129
  - - ">="
@@ -143,33 +137,33 @@ dependencies:
143
137
  - !ruby/object:Gem::Version
144
138
  version: '0'
145
139
  - !ruby/object:Gem::Dependency
146
- name: rspec
140
+ name: rake
147
141
  requirement: !ruby/object:Gem::Requirement
148
142
  requirements:
149
- - - "~>"
143
+ - - "<"
150
144
  - !ruby/object:Gem::Version
151
- version: '2.0'
145
+ version: '11.0'
152
146
  type: :development
153
147
  prerelease: false
154
148
  version_requirements: !ruby/object:Gem::Requirement
155
149
  requirements:
156
- - - "~>"
150
+ - - "<"
157
151
  - !ruby/object:Gem::Version
158
- version: '2.0'
152
+ version: '11.0'
159
153
  - !ruby/object:Gem::Dependency
160
- name: pry
154
+ name: rspec
161
155
  requirement: !ruby/object:Gem::Requirement
162
156
  requirements:
163
- - - ">="
157
+ - - "~>"
164
158
  - !ruby/object:Gem::Version
165
- version: '0'
159
+ version: '2.0'
166
160
  type: :development
167
161
  prerelease: false
168
162
  version_requirements: !ruby/object:Gem::Requirement
169
163
  requirements:
170
- - - ">="
164
+ - - "~>"
171
165
  - !ruby/object:Gem::Version
172
- version: '0'
166
+ version: '2.0'
173
167
  - !ruby/object:Gem::Dependency
174
168
  name: webmock
175
169
  requirement: !ruby/object:Gem::Requirement
@@ -191,6 +185,7 @@ executables: []
191
185
  extensions: []
192
186
  extra_rdoc_files: []
193
187
  files:
188
+ - ".github/CODEOWNERS"
194
189
  - ".gitignore"
195
190
  - ".rspec"
196
191
  - ".rubocop.yml"
@@ -199,6 +194,7 @@ files:
199
194
  - LICENSE.md
200
195
  - README.md
201
196
  - Rakefile
197
+ - SECURITY.md
202
198
  - aptible-resource.gemspec
203
199
  - lib/aptible/resource.rb
204
200
  - lib/aptible/resource/adapter.rb
@@ -232,7 +228,7 @@ homepage: https://github.com/aptible/aptible-resource
232
228
  licenses:
233
229
  - MIT
234
230
  metadata: {}
235
- post_install_message:
231
+ post_install_message:
236
232
  rdoc_options: []
237
233
  require_paths:
238
234
  - lib
@@ -247,9 +243,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
243
  - !ruby/object:Gem::Version
248
244
  version: '0'
249
245
  requirements: []
250
- rubyforge_project:
251
- rubygems_version: 2.7.6
252
- signing_key:
246
+ rubygems_version: 3.0.3
247
+ signing_key:
253
248
  specification_version: 4
254
249
  summary: Foundation classes for Aptible resource server gems
255
250
  test_files: