clockwork 3.0.2 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +2 -9
- data/CHANGELOG.md +11 -0
- data/Gemfile +2 -1
- data/clockwork.gemspec +1 -2
- data/lib/clockwork/event.rb +9 -1
- data/test/event_test.rb +31 -0
- data/test/manager_test.rb +2 -1
- data/test/samples/signal_test.rb +1 -0
- data/test/signal_test.rb +15 -17
- metadata +3 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 933ed51cd69b305509c5195ee3f85ced1e940564477e97f1d3a699b47a355ba7
|
|
4
|
+
data.tar.gz: ff85eb5d04d318c96c6c34150e4aff31f5c5eb535cd7f4212bcf0d9e29cc05c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b02588a3fb02ed15f9b5ae9753a9b1f7fefe9b312d54bbc14e8ce069e0fce321f33db8aff2f0728477e9923fabb3503a7c04bfd20a355a13718903a0a9d32867
|
|
7
|
+
data.tar.gz: de59b9bf5a34e5ece39915c193a5fdf680984695f2596913f83219c8053686c0656f57708a1d2fc0be04938acbc925ae6f9f69cdb220e1eeee4fcefe18285e97
|
data/.github/workflows/tests.yml
CHANGED
|
@@ -11,15 +11,8 @@ jobs:
|
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
strategy:
|
|
13
13
|
matrix:
|
|
14
|
-
ruby: [ "2
|
|
15
|
-
active_support: [ "
|
|
16
|
-
exclude:
|
|
17
|
-
- ruby: "3.0"
|
|
18
|
-
active_support: "6.0"
|
|
19
|
-
- ruby: "3.1"
|
|
20
|
-
active_support: "6.0"
|
|
21
|
-
- ruby: "3.2"
|
|
22
|
-
active_support: "6.0"
|
|
14
|
+
ruby: [ "3.2", "3.3", "3.4", "4.0" ]
|
|
15
|
+
active_support: [ "8.0", "8.1" ]
|
|
23
16
|
name: Ruby ${{ matrix.ruby }} - ActiveSupport ${{ matrix.active_support }}
|
|
24
17
|
env:
|
|
25
18
|
ACTIVE_SUPPORT_VERSION: ${{ matrix.active_support }}
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## 4.0.1 ##
|
|
2
|
+
|
|
3
|
+
* Update ACTIVE_SUPPORT_VERSION default to 8.1 (81b6cd2)
|
|
4
|
+
* Drop test-unit dependency with migrated test (eac1064)
|
|
5
|
+
* Remove unused base64, bigdecimal and ostruct dependencies (f171d8f)
|
|
6
|
+
|
|
7
|
+
## 4.0.0 ##
|
|
8
|
+
|
|
9
|
+
* BREAKING CHANGE: Drop EOL versions of Ruby and ActiveSupport, drop JRuby support (4f0d4a7)
|
|
10
|
+
* Add Spring DST fix for Issue 60 with tests (89f15ed)
|
|
11
|
+
|
|
1
12
|
## 3.0.2 ##
|
|
2
13
|
|
|
3
14
|
* Fixing clockworkd on Ruby 3.2 (a73a9d5)
|
data/Gemfile
CHANGED
data/clockwork.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = "clockwork"
|
|
3
|
-
s.version = "
|
|
3
|
+
s.version = "4.0.1"
|
|
4
4
|
|
|
5
5
|
s.authors = ["Adam Wiggins", "tomykaira"]
|
|
6
6
|
s.license = 'MIT'
|
|
@@ -24,5 +24,4 @@ Gem::Specification.new do |s|
|
|
|
24
24
|
s.add_development_dependency "daemons"
|
|
25
25
|
s.add_development_dependency "minitest", "~> 5.8"
|
|
26
26
|
s.add_development_dependency "mocha"
|
|
27
|
-
s.add_development_dependency "test-unit"
|
|
28
27
|
end
|
data/lib/clockwork/event.rb
CHANGED
|
@@ -71,7 +71,15 @@ module Clockwork
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
def elapsed_ready?(t)
|
|
74
|
-
|
|
74
|
+
# We only need to calculate this if the period is >= 1 day. The UTC offset check only makes sense
|
|
75
|
+
# for periods >= 1.day since these are the shortest period where increasing the date by a day, may not
|
|
76
|
+
# exactly match the exact elapsed time.
|
|
77
|
+
change_in_utc_offset = if @period >= 1.day
|
|
78
|
+
t.utc_offset - (t - @period).utc_offset
|
|
79
|
+
else
|
|
80
|
+
0
|
|
81
|
+
end
|
|
82
|
+
@last.nil? || (t - @last.to_i).to_i >= (@period - change_in_utc_offset)
|
|
75
83
|
end
|
|
76
84
|
|
|
77
85
|
def run_at?(t)
|
data/test/event_test.rb
CHANGED
|
@@ -70,5 +70,36 @@ describe Clockwork::Event do
|
|
|
70
70
|
assert_equal true, event.run_now?(Time.now)
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
|
+
|
|
74
|
+
describe 'with Pacific Time TZ' do
|
|
75
|
+
before do
|
|
76
|
+
@manager = Class.new
|
|
77
|
+
@manager.stubs(:config).returns({ :tz => 'America/Los_Angeles' })
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe 'event non DST to DST transition' do
|
|
81
|
+
it 'returns true when it crosses the transition' do
|
|
82
|
+
event = Clockwork::Event.new(@manager, 1.day, nil, nil)
|
|
83
|
+
starting_time = Time.utc(2022, 3, 13, 6)
|
|
84
|
+
assert_equal true, event.run_now?(starting_time)
|
|
85
|
+
event.instance_variable_set('@last', starting_time)
|
|
86
|
+
# This will return true, since the UTC offset is moved forward by 1 hour. With the 1 hour, it will be
|
|
87
|
+
# equal to 1 day since the last time it was run.
|
|
88
|
+
assert_equal true, event.run_now?(starting_time + 23.hours)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe 'event DST to non DST transition' do
|
|
93
|
+
it 'returns true when it crosses the transition' do
|
|
94
|
+
event = Clockwork::Event.new(@manager, 1.day, nil, nil)
|
|
95
|
+
starting_time = Time.utc(2021, 11, 7, 5)
|
|
96
|
+
assert_equal true, event.run_now?(starting_time)
|
|
97
|
+
event.instance_variable_set('@last', starting_time)
|
|
98
|
+
# This returns false since it hasn't reached a full 'real' day yet.
|
|
99
|
+
assert_equal false, event.run_now?(starting_time + 24.hours)
|
|
100
|
+
assert_equal true, event.run_now?(starting_time + 25.hours)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
73
104
|
end
|
|
74
105
|
end
|
data/test/manager_test.rb
CHANGED
|
@@ -3,6 +3,7 @@ require "minitest/autorun"
|
|
|
3
3
|
require 'mocha/minitest'
|
|
4
4
|
require 'time'
|
|
5
5
|
require 'active_support/time'
|
|
6
|
+
require 'stringio'
|
|
6
7
|
|
|
7
8
|
describe Clockwork::Manager do
|
|
8
9
|
before do
|
|
@@ -117,7 +118,7 @@ describe Clockwork::Manager do
|
|
|
117
118
|
@manager.handler { raise 'boom' }
|
|
118
119
|
@manager.every(1.minute, 'myjob')
|
|
119
120
|
|
|
120
|
-
mocked_logger =
|
|
121
|
+
mocked_logger = Minitest::Mock.new
|
|
121
122
|
mocked_logger.expect :error, true, [RuntimeError]
|
|
122
123
|
@manager.configure { |c| c[:logger] = mocked_logger }
|
|
123
124
|
@manager.tick(Time.now)
|
data/test/samples/signal_test.rb
CHANGED
data/test/signal_test.rb
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "minitest/autorun"
|
|
2
2
|
require 'mocha/minitest'
|
|
3
3
|
require 'fileutils'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
until File.exist?(LOGFILE)
|
|
5
|
+
describe "SignalTest" do
|
|
6
|
+
before do
|
|
7
|
+
@command = File.expand_path('../../bin/clockwork', __FILE__)
|
|
8
|
+
@sample = File.expand_path('../samples/signal_test.rb', __FILE__)
|
|
9
|
+
@logfile = File.expand_path('../tmp/signal_test.log', __FILE__)
|
|
10
|
+
FileUtils.mkdir_p(File.dirname(@logfile))
|
|
11
|
+
@pid = spawn(@command, @sample)
|
|
12
|
+
until File.exist?(@logfile)
|
|
14
13
|
sleep 0.1
|
|
15
14
|
end
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
FileUtils.rm_r(File.dirname(
|
|
17
|
+
after do
|
|
18
|
+
FileUtils.rm_r(File.dirname(@logfile))
|
|
20
19
|
end
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
it 'should gracefully shutdown with SIGTERM' do
|
|
23
22
|
Process.kill(:TERM, @pid)
|
|
24
23
|
sleep 0.2
|
|
25
|
-
assert_equal 'done', File.read(
|
|
24
|
+
assert_equal 'done', File.read(@logfile)
|
|
26
25
|
end
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
it 'should forcely shutdown with SIGINT' do
|
|
29
28
|
Process.kill(:INT, @pid)
|
|
30
29
|
sleep 0.2
|
|
31
|
-
assert_equal 'start', File.read(
|
|
30
|
+
assert_equal 'start', File.read(@logfile)
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
|
-
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: clockwork
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Wiggins
|
|
8
8
|
- tomykaira
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: tzinfo
|
|
@@ -95,20 +94,6 @@ dependencies:
|
|
|
95
94
|
- - ">="
|
|
96
95
|
- !ruby/object:Gem::Version
|
|
97
96
|
version: '0'
|
|
98
|
-
- !ruby/object:Gem::Dependency
|
|
99
|
-
name: test-unit
|
|
100
|
-
requirement: !ruby/object:Gem::Requirement
|
|
101
|
-
requirements:
|
|
102
|
-
- - ">="
|
|
103
|
-
- !ruby/object:Gem::Version
|
|
104
|
-
version: '0'
|
|
105
|
-
type: :development
|
|
106
|
-
prerelease: false
|
|
107
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
-
requirements:
|
|
109
|
-
- - ">="
|
|
110
|
-
- !ruby/object:Gem::Version
|
|
111
|
-
version: '0'
|
|
112
97
|
description: A scheduler process to replace cron, using a more flexible Ruby syntax
|
|
113
98
|
running as a single long-running process. Inspired by rufus-scheduler and resque-scheduler.
|
|
114
99
|
email:
|
|
@@ -157,7 +142,6 @@ homepage: http://github.com/Rykian/clockwork
|
|
|
157
142
|
licenses:
|
|
158
143
|
- MIT
|
|
159
144
|
metadata: {}
|
|
160
|
-
post_install_message:
|
|
161
145
|
rdoc_options: []
|
|
162
146
|
require_paths:
|
|
163
147
|
- lib
|
|
@@ -172,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
172
156
|
- !ruby/object:Gem::Version
|
|
173
157
|
version: '0'
|
|
174
158
|
requirements: []
|
|
175
|
-
rubygems_version: 3.
|
|
176
|
-
signing_key:
|
|
159
|
+
rubygems_version: 3.6.9
|
|
177
160
|
specification_version: 4
|
|
178
161
|
summary: A scheduler process to replace cron.
|
|
179
162
|
test_files:
|