cutoff 0.5.0 → 0.5.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: d13746c455ac05f8491ccd8e5f8834370c0e4d41b77b440a2ee33f7c9bafb9db
4
- data.tar.gz: 883490b2c6661605d81cf299f809175cadfd1e51b4c68bb218dfa8f996af23cc
3
+ metadata.gz: a1a055e4f571fa6ec2e9282d58bd6980a0ac7524ec80c36f6a9cbc0b2c4fc079
4
+ data.tar.gz: f95e79306f4477b491dc12bb5fc22e034a2e75bfbc4450e5ff16b8320237b17c
5
5
  SHA512:
6
- metadata.gz: e544dff1eb63defd93d8f1f260c12e843bb3178a1a523d63b327ea76ddea533bcd6ce7c68c2b697d859ad795ad62f8048549ae82997c0d6c9edbee92089de6c0
7
- data.tar.gz: a1612206aaf0400aa50988b32b35fd7e27418d047e5aab6d7919dfedd30efeaa3675e97f9b6134233f13a54794c01ff7d8868ac892ebf711fc42ef2a65388de5
6
+ metadata.gz: bf825fd9ef07bc8ef7bd8d36fbf65f1bb51d397d38466128d374237b8159ae13639bcc5801df5dacbaa86cd399e3303f8ddafd9765092d00f923291d51fedf22
7
+ data.tar.gz: 6e492e4abb51dba9911ccbfd0792e5eb0970f39bb774890d9c440578dce7ea9e0a46f455b0be295e3303868c80ea770f3ac3b5b42ec8e00b4f583237e426f36b
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,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.2] - 2022-09-06
11
+
12
+ ### Changed
13
+
14
+ - Switch http URLs in specs to https #15 justinhoward
15
+ - Switch CI to support jruby and truffleruby head #18 justinhoward
16
+
17
+ ### Added
18
+
19
+ - Add Rails 6 support #17 maksymst
20
+
21
+ ## [0.5.1] - 2022-09-06
22
+
23
+ ### Changed
24
+
25
+ - Upgrade rubocop to latest version #12 justinhoward
26
+ - Add codecov.io code coverage #11 justinhoward
27
+ - Complete yard documentation and fix warnings #13 justinhoward
28
+
29
+ ### Fixed
30
+
31
+ - Pull cutoff option from job, not worker #14 mperham
32
+
10
33
  ## [0.5.0] - 2022-08-10
11
34
 
12
35
  ### Changed
@@ -58,7 +81,9 @@ to `Timeout::Error`. `CutoffError` changes from a class to a module.
58
81
  - Cutoff class
59
82
  - Mysql2 patch
60
83
 
61
- [Unreleased]: https://github.com/justinhoward/cutoff/compare/v0.5.0...HEAD
84
+ [Unreleased]: https://github.com/justinhoward/cutoff/compare/v0.5.2...HEAD
85
+ [0.5.2]: https://github.com/justinhoward/cutoff/compare/v0.5.1...v0.5.2
86
+ [0.5.1]: https://github.com/justinhoward/cutoff/compare/v0.5.0...v0.5.1
62
87
  [0.5.0]: https://github.com/justinhoward/cutoff/compare/v0.4.2...v0.5.0
63
88
  [0.4.2]: https://github.com/justinhoward/cutoff/compare/v0.4.1...v0.4.2
64
89
  [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,7 @@ class Cutoff
45
46
  end
46
47
  end
47
48
 
48
- ActionController::Base.extend(Cutoff::Rails::Controller)
49
+ # @api external
50
+ ActiveSupport.on_load(:action_controller_base) do
51
+ ActionController::Base.extend(Cutoff::Rails::Controller)
52
+ 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.2')
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.2
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-12-05 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.2
88
+ rubygems_mfa_required: 'true'
116
89
  post_install_message:
117
90
  rdoc_options: []
118
91
  require_paths:
@@ -128,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
101
  - !ruby/object:Gem::Version
129
102
  version: '0'
130
103
  requirements: []
131
- rubygems_version: 3.1.2
104
+ rubygems_version: 3.3.5
132
105
  signing_key:
133
106
  specification_version: 4
134
107
  summary: Deadlines for ruby