diffend-monitor 0.2.37 → 0.2.38

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: aa341aa9b12c2f69cb0969e0389520a76a4671b5c6327ce18ab4d118906aef09
4
- data.tar.gz: d437b9819524b22a2f5b3c8f7d07c46c3718b9e89eb495970619419e4ad1cc66
3
+ metadata.gz: b99c8d891fed663d4b7aec5213e3618eb406b5aa7a94ab5943aac352c830b346
4
+ data.tar.gz: a5b96e89b3d16b84d9dfa963f3de5aa2c60d616238b42ebb6fe61cbf54be7120
5
5
  SHA512:
6
- metadata.gz: 214128a06ab0e08bd584efd7d0798646202ea98a3e3b5bdf6ded87c90abce17b4baefc88b519fe9e2988c9ae3a9e6f25e8438838d17d5fa538542a5d5e14f41d
7
- data.tar.gz: 57c3f35405209ee2e651fa9f21105fe40bc57e402ea3ddbfd91f4032f218aad7cd7b2b7d02edb2a53128a9a472b462d8c34bdae3d9f498b5b1cf9d84921a142d
6
+ metadata.gz: 6e08f8e02f760d7b5ec8e3f7f33c2a3b840c5a3bdd5a64b4174c01c02fa0dce16c7ccf4ff540f42dad89cc3916b1bd82409e5f80ad03bde078f8c251bf0769a7
7
+ data.tar.gz: 16c6e6fab056f811ec6e46fd20e0252ca201a82d106a6bae3ce42b715fbaf5ae88c16cd3c5e6423358f39ff9457e2d5d4001613646303a448e9f3470fb35aaf1
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -12,10 +12,10 @@ jobs:
12
12
  - '2.7'
13
13
  - '2.6'
14
14
  - '2.5'
15
- - 'jruby-9.2.13.0'
15
+ - 'jruby-9.2.14.0'
16
16
  bundler:
17
17
  - '2.1.4'
18
- - '2.2.4'
18
+ - '2.2.5'
19
19
  include:
20
20
  - ruby: '2.7'
21
21
  coverage: 'true'
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## [Unreleased][master]
4
4
 
5
+ ## [0.2.38] (2021-01-15)
6
+ - allow executing `bundle secure` without plugin being present in the Gemfile ([#96](https://github.com/diffend-io/diffend-ruby/pull/96))
7
+ - be explicit about `Bundler` scope ([#97](https://github.com/diffend-io/diffend-ruby/pull/97))
8
+ - switch to exponential backoff in `Diffend::Monitor` ([#98](https://github.com/diffend-io/diffend-ruby/pull/98))
9
+
5
10
  ## [0.2.37] (2021-01-05)
6
11
  - add support for ENV loaded at runtime ([#92](https://github.com/diffend-io/diffend-ruby/pull/92))
7
12
  - allow us to have more control over config errors ([#91](https://github.com/diffend-io/diffend-ruby/pull/91))
@@ -114,7 +119,9 @@
114
119
 
115
120
  - initial release
116
121
 
117
- [master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.36...HEAD
122
+ [master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.38...HEAD
123
+ [0.2.38]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.37...v0.2.38
124
+ [0.2.37]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.36...v0.2.37
118
125
  [0.2.36]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.35...v0.2.36
119
126
  [0.2.35]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.34...v0.2.35
120
127
  [0.2.34]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.33...v0.2.34
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- diffend (0.2.37)
4
+ diffend (0.2.38)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -37,4 +37,4 @@ DEPENDENCIES
37
37
  rspec
38
38
 
39
39
  BUNDLED WITH
40
- 2.2.4
40
+ 2.2.5
@@ -10,14 +10,14 @@ module Diffend
10
10
  # @param gemfile [String] path to Gemfile
11
11
  # @param lockfile [String] path to Gemfile.lock
12
12
  #
13
- # @return [Bundler::Definition]
13
+ # @return [::Bundler::Definition]
14
14
  def call(command, gemfile, lockfile)
15
15
  unlock = command == 'update' ? true : nil
16
16
 
17
- Bundler.configure
18
- Bundler::Fetcher.disable_endpoint = nil
17
+ ::Bundler.configure
18
+ ::Bundler::Fetcher.disable_endpoint = nil
19
19
 
20
- Bundler::Definition
20
+ ::Bundler::Definition
21
21
  .build(gemfile, lockfile, unlock)
22
22
  .tap(&:validate_runtime!)
23
23
  end
@@ -3,15 +3,13 @@
3
3
  module Diffend
4
4
  # Extend bundler with a new secure command to be able to run Diffend separately
5
5
  class BundleSecure
6
- Bundler::Plugin::API.command(Diffend::Commands::SECURE, self)
6
+ ::Bundler::Plugin::API.command(Diffend::Commands::SECURE, self)
7
7
 
8
8
  # Execute diffend check
9
9
  #
10
10
  # @param _name [String] command name
11
11
  # @param _args [Array] arguments from ARGV
12
12
  def exec(_name, _args)
13
- return unless Diffend::Enabled.call
14
-
15
13
  config = Diffend::Config.new(
16
14
  command: Diffend::Commands::SECURE,
17
15
  severity: Diffend::Logger::INFO
@@ -17,12 +17,12 @@ module Diffend
17
17
 
18
18
  # Build bundler definition
19
19
  #
20
- # @return [Bundler::Definition]
20
+ # @return [::Bundler::Definition]
21
21
  def build_definition(command)
22
22
  Diffend::BuildBundlerDefinition.call(
23
23
  command,
24
- Bundler.default_gemfile,
25
- Bundler.default_lockfile
24
+ ::Bundler.default_gemfile,
25
+ ::Bundler.default_lockfile
26
26
  )
27
27
  end
28
28
 
@@ -7,7 +7,7 @@ module Diffend
7
7
  # Build diffend, host, packages, and platform specific information
8
8
  #
9
9
  # @param config [Diffend::Config]
10
- # @param definition [Bundler::Definition] definition for your source
10
+ # @param definition [::Bundler::Definition] definition for your source
11
11
  #
12
12
  # @return [Hash] payload for diffend endpoint
13
13
  def call(config, definition)
@@ -9,8 +9,8 @@ module Diffend
9
9
  ME_PATH = '.'
10
10
  # Sources that we expect to match ourselves too
11
11
  ME_SOURCES = [
12
- Bundler::Source::Gemspec,
13
- Bundler::Source::Path
12
+ ::Bundler::Source::Gemspec,
13
+ ::Bundler::Source::Path
14
14
  ].freeze
15
15
  # List of dependency types
16
16
  DEPENDENCIES_TYPES = {
@@ -32,11 +32,11 @@ module Diffend
32
32
 
33
33
  class << self
34
34
  # @param command [String] command executed via bundler
35
- # @param definition [Bundler::Definition] definition for your source
35
+ # @param definition [::Bundler::Definition] definition for your source
36
36
  def call(command, definition)
37
37
  instance = new(command, definition)
38
38
 
39
- Bundler.ui.silence { instance.resolve }
39
+ ::Bundler.ui.silence { instance.resolve }
40
40
 
41
41
  case command
42
42
  when Commands::INSTALL, Commands::EXEC, Commands::SECURE then instance.build_install
@@ -48,7 +48,7 @@ module Diffend
48
48
  end
49
49
 
50
50
  # @param command [String] command executed via bundler
51
- # @param definition [Bundler::Definition] definition for your source
51
+ # @param definition [::Bundler::Definition] definition for your source
52
52
  #
53
53
  # @return [Hash] local dependencies
54
54
  def initialize(command, definition)
@@ -125,8 +125,8 @@ module Diffend
125
125
 
126
126
  # Build gem versions
127
127
  #
128
- # @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
129
- # @param locked_spec [Bundler::LazySpecification, Gem::Specification, NilClass]
128
+ # @param spec [::Bundler::StubSpecification, ::Bundler::LazySpecification, Gem::Specification]
129
+ # @param locked_spec [::Bundler::LazySpecification, Gem::Specification, NilClass]
130
130
  #
131
131
  # @return [Array<String>]
132
132
  def build_versions(spec, locked_spec = nil)
@@ -151,8 +151,8 @@ module Diffend
151
151
 
152
152
  # Build gem platform
153
153
  #
154
- # @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
155
- # @param locked_spec [Bundler::LazySpecification, Gem::Specification, NilClass]
154
+ # @param spec [::Bundler::StubSpecification, ::Bundler::LazySpecification, Gem::Specification]
155
+ # @param locked_spec [::Bundler::LazySpecification, Gem::Specification, NilClass]
156
156
  #
157
157
  # @return [String]
158
158
  def build_spec_platform(spec, locked_spec)
@@ -175,18 +175,18 @@ module Diffend
175
175
 
176
176
  # Build gem source type
177
177
  #
178
- # @param source [Bundler::Source] gem source type
178
+ # @param source [::Bundler::Source] gem source type
179
179
  #
180
180
  # @return [Integer] internal gem source type
181
181
  def build_spec_gem_source_type(source)
182
182
  case source
183
- when Bundler::Source::Metadata
183
+ when ::Bundler::Source::Metadata
184
184
  GEM_SOURCES_TYPES[:local]
185
- when Bundler::Source::Rubygems, Bundler::Source::Rubygems::Remote
185
+ when ::Bundler::Source::Rubygems, ::Bundler::Source::Rubygems::Remote
186
186
  GEM_SOURCES_TYPES[:gemfile_source]
187
- when Bundler::Source::Git
187
+ when ::Bundler::Source::Git
188
188
  GEM_SOURCES_TYPES[:gemfile_git]
189
- when Bundler::Source::Path
189
+ when ::Bundler::Source::Path
190
190
  GEM_SOURCES_TYPES[:gemfile_path]
191
191
  else
192
192
  raise ArgumentError, "unknown source #{source.class}"
@@ -195,7 +195,7 @@ module Diffend
195
195
 
196
196
  # Build gem source
197
197
  #
198
- # @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
198
+ # @param spec [::Bundler::StubSpecification, ::Bundler::LazySpecification, Gem::Specification]
199
199
  #
200
200
  # @return [Hash]
201
201
  def build_spec_source(spec)
@@ -209,16 +209,16 @@ module Diffend
209
209
 
210
210
  # Figure out source for gem
211
211
  #
212
- # @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
212
+ # @param spec [::Bundler::StubSpecification, ::Bundler::LazySpecification, Gem::Specification]
213
213
  #
214
- # @return [Bundler::Source] gem source type
214
+ # @return [::Bundler::Source] gem source type
215
215
  def source_for_spec(spec)
216
216
  return spec.remote if spec.remote
217
217
 
218
218
  case spec.source
219
- when Bundler::Source::Rubygems
220
- Bundler::Source::Rubygems::Remote.new(spec.source.remotes.last)
221
- when Bundler::Source::Metadata, Bundler::Source::Git, Bundler::Source::Path
219
+ when ::Bundler::Source::Rubygems
220
+ ::Bundler::Source::Rubygems::Remote.new(spec.source.remotes.last)
221
+ when ::Bundler::Source::Metadata, ::Bundler::Source::Git, ::Bundler::Source::Path
222
222
  spec.source
223
223
  else
224
224
  raise ArgumentError, "unknown source #{spec.source.class}"
@@ -227,25 +227,25 @@ module Diffend
227
227
 
228
228
  # Build gem source name
229
229
  #
230
- # @param source [Bundler::Source] gem source type
230
+ # @param source [::Bundler::Source] gem source type
231
231
  #
232
232
  # @return [String]
233
233
  def source_name_from_source(source)
234
234
  case source
235
- when Bundler::Source::Metadata
235
+ when ::Bundler::Source::Metadata
236
236
  ''
237
- when Bundler::Source::Rubygems::Remote
237
+ when ::Bundler::Source::Rubygems::Remote
238
238
  source_name(source.anonymized_uri)
239
- when Bundler::Source::Git
239
+ when ::Bundler::Source::Git
240
240
  source.instance_variable_get(:@safe_uri)
241
- when Bundler::Source::Path
241
+ when ::Bundler::Source::Path
242
242
  source.path
243
243
  else
244
244
  raise ArgumentError, "unknown source #{source.class}"
245
245
  end
246
246
  end
247
247
 
248
- # @param uri [Bundler::URI]
248
+ # @param uri [::Bundler::URI]
249
249
  #
250
250
  # @return [String]
251
251
  def source_name(uri)
@@ -272,7 +272,7 @@ module Diffend
272
272
 
273
273
  # Build gem source type
274
274
  #
275
- # @param remotes [Array<Bundler::URI>]
275
+ # @param remotes [Array<::Bundler::URI>]
276
276
  #
277
277
  # @return [Integer] internal source type
278
278
  def build_source_type(remotes)
@@ -281,7 +281,7 @@ module Diffend
281
281
 
282
282
  # Checks if we should skip a source
283
283
  #
284
- # @param source [Bundler::Source] gem source type
284
+ # @param source [::Bundler::Source] gem source type
285
285
  #
286
286
  # @return [Boolean] true if we should skip this source, false otherwise
287
287
  def skip?(source)
@@ -292,7 +292,7 @@ module Diffend
292
292
 
293
293
  # Checks if it's a self source, this happens for repositories that are a gem
294
294
  #
295
- # @param source [Bundler::Source] gem source type
295
+ # @param source [::Bundler::Source] gem source type
296
296
  #
297
297
  # @return [Boolean] true if it's a self source, false otherwise
298
298
  def me?(source)
@@ -12,7 +12,7 @@ module Diffend
12
12
  def call
13
13
  {
14
14
  'bundler' => {
15
- 'version' => Bundler::VERSION
15
+ 'version' => ::Bundler::VERSION
16
16
  },
17
17
  'environment' => environment,
18
18
  'ruby' => ruby_information,
@@ -55,11 +55,11 @@ module Diffend
55
55
 
56
56
  case severity
57
57
  when INFO
58
- Bundler.ui.confirm(message)
58
+ ::Bundler.ui.confirm(message)
59
59
  when WARN
60
- Bundler.ui.warn(message)
60
+ ::Bundler.ui.warn(message)
61
61
  when ERROR, FATAL
62
- Bundler.ui.error(message)
62
+ ::Bundler.ui.error(message)
63
63
  end
64
64
  end
65
65
  end
@@ -26,9 +26,18 @@
26
26
  track
27
27
  ].each { |file| require "diffend/#{file}" }
28
28
 
29
+ # Calculate exponential backoff
30
+ #
31
+ # @param retry_count [Integer]
32
+ #
33
+ # @return [Float] backoff value
34
+ def exponential_backoff(retry_count)
35
+ (0.25 * 1.5**retry_count.to_f).round(2)
36
+ end
37
+
29
38
  Thread.new do
30
39
  config = nil
31
- config_iterations = 0
40
+ retry_count = 0
32
41
 
33
42
  loop do
34
43
  config = Diffend::Config.new(
@@ -37,12 +46,11 @@ Thread.new do
37
46
  )
38
47
 
39
48
  break if config.valid?
49
+ break if retry_count == 12
40
50
 
41
- config_iterations += 1
42
-
43
- break if config_iterations == 12
51
+ sleep(exponential_backoff(retry_count))
44
52
 
45
- sleep 5
53
+ retry_count += 1
46
54
  end
47
55
 
48
56
  Thread.exit unless config.valid?
@@ -7,15 +7,15 @@ module Diffend
7
7
  module RequestVerdict
8
8
  # Exceptions that we handle when there is a resolve issue
9
9
  RESOLVE_EXCEPTIONS = [
10
- Bundler::GemNotFound,
11
- Bundler::GitError,
12
- Bundler::PermissionError,
13
- Bundler::VersionConflict
10
+ ::Bundler::GemNotFound,
11
+ ::Bundler::GitError,
12
+ ::Bundler::PermissionError,
13
+ ::Bundler::VersionConflict
14
14
  ].freeze
15
15
 
16
16
  class << self
17
17
  # @param config [Diffend::Config]
18
- # @param definition [Bundler::Definition] definition for your source
18
+ # @param definition [::Bundler::Definition] definition for your source
19
19
  def call(config, definition)
20
20
  payload = Diffend::LocalContext.call(config, definition)
21
21
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Diffend
4
4
  # Current version
5
- VERSION = '0.2.37'
5
+ VERSION = '0.2.38'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diffend-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.37
4
+ version: 0.2.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Pajor
@@ -34,7 +34,7 @@ cert_chain:
34
34
  9MmF6uCQa1EjK2p8tYT0MnbHrFkoehxdX4VO9y99GAkhZyJNKPYPtyAUFV27sT2V
35
35
  LfCJRk4ifKIN/FUCwDSn8Cz0m6oH265q0p6wdzI6qrWOjP8tGOMBTA==
36
36
  -----END CERTIFICATE-----
37
- date: 2021-01-05 00:00:00.000000000 Z
37
+ date: 2021-01-15 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: bundler
metadata.gz.sig CHANGED
Binary file