rocketjob 3.3.3 → 3.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rocket_job/plugins/cron.rb +14 -2
- data/lib/rocket_job/version.rb +1 -1
- data/test/plugins/cron_test.rb +16 -0
- data/test/test_db.sqlite3 +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6c4cf70983793dd982cefbc5b58b7ae33d6b8f1
|
4
|
+
data.tar.gz: 2c593219205c7ff16dbd02dce31c57b8c67dcfa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dd940e8008cc81dd36085bc12f705c87a12a348e1edf29c3dbf34c1b6000bcfaf3ed085505968c35f94072f862cd13f524371836b5fe0eb7b0697da7181ca47
|
7
|
+
data.tar.gz: b2e616a1ef53886ea4a5c2fef6c097d3fc640ce9a71971f1ebdb9ee4d1fc1bcd57372773af8e81003d873b4e30eb2497c2708755067b51d3994d8d74104cc288
|
@@ -32,6 +32,8 @@ module RocketJob
|
|
32
32
|
# - The job will not be restarted if:
|
33
33
|
# - A validation fails after cloning this job.
|
34
34
|
# - The job has expired.
|
35
|
+
# - Any time the `cron_schedule` is changed, the `run_at` is automatically set before saving the changes.
|
36
|
+
# - However, if the `run_at` is explicitly set then it will not be overriden.
|
35
37
|
#
|
36
38
|
# Example:
|
37
39
|
#
|
@@ -102,7 +104,7 @@ module RocketJob
|
|
102
104
|
|
103
105
|
field :cron_schedule, type: String, class_attribute: true, user_editable: true, copy_on_restart: true
|
104
106
|
|
105
|
-
|
107
|
+
before_save :rocket_job_set_run_at
|
106
108
|
|
107
109
|
validates_presence_of :cron_schedule
|
108
110
|
validates_each :cron_schedule do |record, attr, value|
|
@@ -114,10 +116,20 @@ module RocketJob
|
|
114
116
|
end
|
115
117
|
end
|
116
118
|
|
119
|
+
# Returns [Time] the next time this job will be scheduled to run at.
|
120
|
+
#
|
121
|
+
# Parameters
|
122
|
+
# time: [Time]
|
123
|
+
# The next time as of this time.
|
124
|
+
# Default: Time.now
|
125
|
+
def rocket_job_cron_next_time(time = Time.now)
|
126
|
+
RocketJob::Plugins::Rufus::CronLine.new(cron_schedule).next_time(time)
|
127
|
+
end
|
128
|
+
|
117
129
|
private
|
118
130
|
|
119
131
|
def rocket_job_set_run_at
|
120
|
-
self.run_at =
|
132
|
+
self.run_at = rocket_job_cron_next_time if cron_schedule_changed? && !run_at_changed?
|
121
133
|
end
|
122
134
|
|
123
135
|
end
|
data/lib/rocket_job/version.rb
CHANGED
data/test/plugins/cron_test.rb
CHANGED
@@ -54,6 +54,22 @@ module Plugins
|
|
54
54
|
|
55
55
|
end
|
56
56
|
|
57
|
+
describe '#save' do
|
58
|
+
it 'updates run_at for a new record' do
|
59
|
+
@job = CronJob.create!(cron_schedule: '* 1 * * *')
|
60
|
+
assert @job.run_at
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'updates run_at for a modified record' do
|
64
|
+
@job = CronJob.create!(cron_schedule: '* 1 * * * UTC')
|
65
|
+
assert run_at = @job.run_at
|
66
|
+
@job.cron_schedule = '* 2 * * * UTC'
|
67
|
+
assert_equal run_at, @job.run_at
|
68
|
+
@job.save!
|
69
|
+
assert run_at < @job.run_at
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
57
73
|
describe '#valid?' do
|
58
74
|
it 'fails on missing cron schedule' do
|
59
75
|
@job = CronJob.new
|
data/test/test_db.sqlite3
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocketjob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|