cutoff 0.5.0 → 0.5.1

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: d13746c455ac05f8491ccd8e5f8834370c0e4d41b77b440a2ee33f7c9bafb9db
4
- data.tar.gz: 883490b2c6661605d81cf299f809175cadfd1e51b4c68bb218dfa8f996af23cc
3
+ metadata.gz: 7ab1dba25fcad8b3f65d816d1740dbd2c2e1b6102f4009e19fa36fd0baf8236c
4
+ data.tar.gz: 7a86b6dbf5c0d0bd6631281687c674ec21dc19102097bee351b8e13a3b2a53c3
5
5
  SHA512:
6
- metadata.gz: e544dff1eb63defd93d8f1f260c12e843bb3178a1a523d63b327ea76ddea533bcd6ce7c68c2b697d859ad795ad62f8048549ae82997c0d6c9edbee92089de6c0
7
- data.tar.gz: a1612206aaf0400aa50988b32b35fd7e27418d047e5aab6d7919dfedd30efeaa3675e97f9b6134233f13a54794c01ff7d8868ac892ebf711fc42ef2a65388de5
6
+ metadata.gz: e23dcd3d2fa5b44bcc3630aa4976cff12eef9771f4c1010a2cd12cc820ef5caabf1e54b0dba83de60af1ce2142eea4d53bae7c79e5c02ac34ec91d1e07cfba62
7
+ data.tar.gz: bfc01027499784eaeaf89f5bc4114483bf89bc41eb2db6668a297ace172b58136ae58b214df6f0929a027729aff417ff56b9fb4dfacd45cb979d280b675f3868
data/.yardopts CHANGED
@@ -1,3 +1,4 @@
1
1
  --markup markdown
2
2
  --markup-provider redcarpet
3
3
  --no-private
4
+ --no-api
data/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.1] - 2022-09-06
11
+
12
+ ### Changed
13
+
14
+ - Upgrade rubocop to latest version #12 justinhoward
15
+ - Add codecov.io code coverage #11 justinhoward
16
+ - Complete yard documentation and fix warnings #13 justinhoward
17
+
18
+ ### Fixed
19
+
20
+ - Pull cutoff option from job, not worker #14 mperham
21
+
10
22
  ## [0.5.0] - 2022-08-10
11
23
 
12
24
  ### Changed
@@ -58,7 +70,8 @@ to `Timeout::Error`. `CutoffError` changes from a class to a module.
58
70
  - Cutoff class
59
71
  - Mysql2 patch
60
72
 
61
- [Unreleased]: https://github.com/justinhoward/cutoff/compare/v0.5.0...HEAD
73
+ [Unreleased]: https://github.com/justinhoward/cutoff/compare/v0.5.1...HEAD
74
+ [0.5.1]: https://github.com/justinhoward/cutoff/compare/v0.5.0...v0.5.1
62
75
  [0.5.0]: https://github.com/justinhoward/cutoff/compare/v0.4.2...v0.5.0
63
76
  [0.4.2]: https://github.com/justinhoward/cutoff/compare/v0.4.1...v0.4.2
64
77
  [0.4.1]: https://github.com/justinhoward/cutoff/compare/v0.4.0...v0.4.1
data/README.md CHANGED
@@ -4,7 +4,7 @@ Cutoff
4
4
  [![Gem Version](https://badge.fury.io/rb/cutoff.svg)](https://badge.fury.io/rb/cutoff)
5
5
  [![CI](https://github.com/justinhoward/cutoff/workflows/CI/badge.svg)](https://github.com/justinhoward/cutoff/actions?query=workflow%3ACI+branch%3Amaster)
6
6
  [![Code Quality](https://app.codacy.com/project/badge/Grade/2748da79ec294f909996a56f11caac4a)](https://www.codacy.com/gh/justinhoward/cutoff/dashboard?utm_source=github.com&utm_medium=referral&utm_content=justinhoward/cutoff&utm_campaign=Badge_Grade)
7
- [![Code Coverage](https://app.codacy.com/project/badge/Coverage/2748da79ec294f909996a56f11caac4a)](https://www.codacy.com/gh/justinhoward/cutoff/dashboard?utm_source=github.com&utm_medium=referral&utm_content=justinhoward/cutoff&utm_campaign=Badge_Coverage)
7
+ [![Code Coverage](https://codecov.io/gh/justinhoward/cutoff/branch/master/graph/badge.svg?token=COVM3D2PTG)](https://codecov.io/gh/justinhoward/cutoff)
8
8
  [![Inline docs](http://inch-ci.org/github/justinhoward/cutoff.svg?branch=master)](http://inch-ci.org/github/justinhoward/cutoff)
9
9
 
10
10
  A deadlines library for Ruby inspired by Shopify and
@@ -167,4 +167,9 @@ class Cutoff
167
167
  end
168
168
  end
169
169
 
170
- Mysql2::Client.prepend(Cutoff::Patch::Mysql2)
170
+ # @api external
171
+ module Mysql2
172
+ class Client
173
+ prepend Cutoff::Patch::Mysql2
174
+ end
175
+ end
@@ -8,21 +8,26 @@ class Cutoff
8
8
  # to the remaining cutoff time. You can select this patch with
9
9
  # `exclude` or `only` using the checkpoint name `:net_http`.
10
10
  module NetHttp
11
- def self.gen_timeout_method(name)
12
- <<~RUBY
13
- if #{name}.nil? || #{name} > remaining
14
- self.#{name} = cutoff.seconds_remaining
15
- end
16
- RUBY
17
- end
11
+ class << self
12
+ private
13
+
14
+ def gen_timeout_method(name)
15
+ <<~RUBY
16
+ if #{name}.nil? || #{name} > remaining
17
+ self.#{name} = cutoff.seconds_remaining
18
+ end
19
+ RUBY
20
+ end
18
21
 
19
- def self.use_write_timeout?
20
- Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.6')
22
+ def use_write_timeout?
23
+ Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.6')
24
+ end
21
25
  end
22
26
 
23
27
  # Same as the original start, but adds a checkpoint for starting HTTP
24
28
  # requests and sets network timeouts to the remaining time
25
29
  #
30
+ # @method start
26
31
  # @see Net::HTTP#start
27
32
  module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
28
33
  def start
@@ -41,4 +46,9 @@ class Cutoff
41
46
  end
42
47
  end
43
48
 
44
- Net::HTTP.prepend(Cutoff::Patch::NetHttp)
49
+ # @api external
50
+ module Net
51
+ class HTTP
52
+ prepend Cutoff::Patch::NetHttp
53
+ end
54
+ end
@@ -3,6 +3,7 @@
3
3
  require 'action_controller'
4
4
 
5
5
  class Cutoff
6
+ # Cutoff Rails extensions
6
7
  module Rails
7
8
  # Rails controller integration
8
9
  module Controller
@@ -45,4 +46,9 @@ class Cutoff
45
46
  end
46
47
  end
47
48
 
48
- ActionController::Base.extend(Cutoff::Rails::Controller)
49
+ # @api external
50
+ module ActionController
51
+ class Base
52
+ extend Cutoff::Rails::Controller
53
+ end
54
+ end
@@ -3,6 +3,7 @@
3
3
  require 'sidekiq'
4
4
 
5
5
  class Cutoff
6
+ # Cutoff sidekiq extensions
6
7
  module Sidekiq
7
8
  # Add an option `cutoff` for sidekiq workers
8
9
  #
@@ -17,14 +18,14 @@ class Cutoff
17
18
  # end
18
19
  # end
19
20
  class ServerMiddleware
20
- # @param worker [Object] the worker instance
21
- # @param _job [Hash] the full job payload
21
+ # @param _worker [Object] the worker instance
22
+ # @param job [Hash] the full job payload
22
23
  # @param _queue [String] queue the name of the queue the job was pulled
23
24
  # from
24
25
  # @yield the next middleware in the chain or worker `perform` method
25
26
  # @return [void]
26
- def call(worker, _job, _queue)
27
- allowed_seconds = worker.class.sidekiq_options['cutoff']
27
+ def call(_worker, job, _queue)
28
+ allowed_seconds = job['cutoff']
28
29
  return yield if allowed_seconds.nil?
29
30
 
30
31
  Cutoff.wrap(allowed_seconds) { yield }
data/lib/cutoff/timer.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal:true
2
2
 
3
3
  class Cutoff
4
+ # Tracks the current time for cutoff
4
5
  module Timer
5
6
  if defined?(Process::CLOCK_MONOTONIC)
6
7
  # The current relative time
@@ -3,6 +3,6 @@
3
3
  class Cutoff
4
4
  # @return [Gem::Version] The current version of the cutoff gem
5
5
  def self.version
6
- Gem::Version.new('0.5.0')
6
+ Gem::Version.new('0.5.1')
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cutoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-10 00:00:00.000000000 Z
11
+ date: 2022-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,34 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rubocop
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 0.81.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 0.81.0
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop-rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '='
60
- - !ruby/object:Gem::Version
61
- version: 1.38.1
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '='
67
- - !ruby/object:Gem::Version
68
- version: 1.38.1
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: timecop
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -112,7 +84,8 @@ licenses:
112
84
  - MIT
113
85
  metadata:
114
86
  changelog_uri: https://github.com/justinhoward/cutoff/blob/master/CHANGELOG.md
115
- documentation_uri: https://www.rubydoc.info/gems/cutoff/0.5.0
87
+ documentation_uri: https://www.rubydoc.info/gems/cutoff/0.5.1
88
+ rubygems_mfa_required: 'true'
116
89
  post_install_message:
117
90
  rdoc_options: []
118
91
  require_paths: