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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e5a8d520eb475e3eb5b3e75b3b175a4a66c3804584912afc9d4392c1d82f3d7
4
- data.tar.gz: 558bc615e123ceaf146c2107b71202fef3eaf307215c93aa8f421826e25a8d4a
3
+ metadata.gz: 933ed51cd69b305509c5195ee3f85ced1e940564477e97f1d3a699b47a355ba7
4
+ data.tar.gz: ff85eb5d04d318c96c6c34150e4aff31f5c5eb535cd7f4212bcf0d9e29cc05c2
5
5
  SHA512:
6
- metadata.gz: d60240815eee8a5001004f854ccfd1fe94f01023ca5099799100bcc04a99ae982bc96f14b746b4965c4afc2aba77d2138ebae96c41da075bb7b8c4f15b863493
7
- data.tar.gz: 4beb2d7f2cd09940e9159e5d4e1d1e62db2268f82b75ff86c344e7b11076a2e6d57865039fe19c361208c1fee8e5af8c3f72657880f6183107e8f90f33129e47
6
+ metadata.gz: b02588a3fb02ed15f9b5ae9753a9b1f7fefe9b312d54bbc14e8ce069e0fce321f33db8aff2f0728477e9923fabb3503a7c04bfd20a355a13718903a0a9d32867
7
+ data.tar.gz: de59b9bf5a34e5ece39915c193a5fdf680984695f2596913f83219c8053686c0656f57708a1d2fc0be04938acbc925ae6f9f69cdb220e1eeee4fcefe18285e97
@@ -11,15 +11,8 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby: [ "2.7", "3.0", "3.1", "3.2", jruby ]
15
- active_support: [ "6.0", "7.0" ]
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
@@ -2,7 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- rails_version = ENV.fetch("ACTIVE_SUPPORT_VERSION", "7.0")
5
+ rails_version = ENV.fetch("ACTIVE_SUPPORT_VERSION", "8.1")
6
6
 
7
7
  gem "activesupport", "~> #{rails_version}"
8
8
  gem "minitest", "~> 5.0"
9
+ gem "ostruct"
data/clockwork.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "clockwork"
3
- s.version = "3.0.2"
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
@@ -71,7 +71,15 @@ module Clockwork
71
71
  end
72
72
 
73
73
  def elapsed_ready?(t)
74
- @last.nil? || (t - @last.to_i).to_i >= @period
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 = MiniTest::Mock.new
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)
@@ -1,5 +1,6 @@
1
1
  require 'clockwork'
2
2
  require 'active_support/time'
3
+ require 'stringio'
3
4
 
4
5
  module Clockwork
5
6
  LOGFILE = File.expand_path('../../tmp/signal_test.log', __FILE__)
data/test/signal_test.rb CHANGED
@@ -1,34 +1,32 @@
1
- require 'test/unit'
1
+ require "minitest/autorun"
2
2
  require 'mocha/minitest'
3
3
  require 'fileutils'
4
4
 
5
- class SignalTest < Test::Unit::TestCase
6
- CMD = File.expand_path('../../bin/clockwork', __FILE__)
7
- SAMPLE = File.expand_path('../samples/signal_test.rb', __FILE__)
8
- LOGFILE = File.expand_path('../tmp/signal_test.log', __FILE__)
9
-
10
- setup do
11
- FileUtils.mkdir_p(File.dirname(LOGFILE))
12
- @pid = spawn(CMD, SAMPLE)
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
- teardown do
19
- FileUtils.rm_r(File.dirname(LOGFILE))
17
+ after do
18
+ FileUtils.rm_r(File.dirname(@logfile))
20
19
  end
21
20
 
22
- test 'should gracefully shutdown with SIGTERM' do
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(LOGFILE)
24
+ assert_equal 'done', File.read(@logfile)
26
25
  end
27
26
 
28
- test 'should forcely shutdown with SIGINT' do
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(LOGFILE)
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: 3.0.2
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: 2023-02-12 00:00:00.000000000 Z
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.0.3.1
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: