schedule_job 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/schedule_job/cron.rb +37 -17
- data/lib/schedule_job/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a0f470384777a45f805dc1ff41c9f6386db8378c509eec95b647a577f43e06e
|
4
|
+
data.tar.gz: 9fa202bc1743951f7a2e350c379a1d0d79e0a5f2926fad5aa3c9393be042287d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddd20ca47d699cf56bd6e653a84065fe45c10133fd716af28fc092e2550deffe9a5465041e21ee287a3f4e9bfb34a9cdb14dd642ee5db1b3a807b6430fd9da28
|
7
|
+
data.tar.gz: 2e268c4aaa999e4c75df56aa0d4396a0269d9064cc9c46498598c0a5a0086ac1fe7e809cf243b8ddb2df98020b13fde6f6d40fd076e43ad440dc518918dadf81
|
data/Gemfile.lock
CHANGED
data/lib/schedule_job/cron.rb
CHANGED
@@ -82,14 +82,18 @@ module ScheduleJob
|
|
82
82
|
puts "Scheduling: #{job.to_s}"
|
83
83
|
install_cron_job(job)
|
84
84
|
end
|
85
|
-
|
86
|
-
cron_parser = CronParser.new(job.schedule_spec)
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
85
|
+
|
86
|
+
cron_parser = CronParser.new(job.schedule_spec) rescue nil
|
87
|
+
if cron_parser
|
88
|
+
puts "Next three runs:"
|
89
|
+
first_run_time = cron_parser.next(Time.now)
|
90
|
+
second_run_time = cron_parser.next(first_run_time)
|
91
|
+
third_run_time = cron_parser.next(second_run_time)
|
92
|
+
|
93
|
+
puts "1. #{first_run_time}"
|
94
|
+
puts "2. #{second_run_time}"
|
95
|
+
puts "3. #{third_run_time}"
|
96
|
+
end
|
93
97
|
end
|
94
98
|
|
95
99
|
def install_cron_job(job)
|
@@ -161,14 +165,14 @@ module ScheduleJob
|
|
161
165
|
hour = next_moment.hour
|
162
166
|
day = next_moment.day
|
163
167
|
schedule_spec = case duration_unit_of_time
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
168
|
+
when "m"
|
169
|
+
"*/#{duration_quantity} * * * *"
|
170
|
+
when "h"
|
171
|
+
"#{minute} */#{duration_quantity} * * *"
|
172
|
+
when "d"
|
173
|
+
"#{minute} #{hour} */#{duration_quantity} * *"
|
174
|
+
when "M"
|
175
|
+
"#{minute} #{hour} #{day} */#{duration_quantity} *"
|
172
176
|
end
|
173
177
|
self.new(schedule_spec, command)
|
174
178
|
end
|
@@ -218,7 +222,23 @@ module ScheduleJob
|
|
218
222
|
end
|
219
223
|
|
220
224
|
def to_s
|
221
|
-
schedule =
|
225
|
+
schedule = case @schedule_spec
|
226
|
+
when "@reboot"
|
227
|
+
"at every reboot"
|
228
|
+
when "@yearly", "@annually"
|
229
|
+
"every year"
|
230
|
+
when "@monthly"
|
231
|
+
"every month"
|
232
|
+
when "@weekly"
|
233
|
+
"every week"
|
234
|
+
when "@daily"
|
235
|
+
"every day"
|
236
|
+
when "@hourly"
|
237
|
+
"every hour"
|
238
|
+
else
|
239
|
+
Cronex::ExpressionDescriptor.new(@schedule_spec).description
|
240
|
+
end
|
241
|
+
|
222
242
|
# str = "#{@command} #{schedule} (line #{@line_number}, pos #{@pos_offset})"
|
223
243
|
str = "#{@command} #{schedule}"
|
224
244
|
end
|
data/lib/schedule_job/version.rb
CHANGED