vrinek-cronos 0.6.1 → 0.6.2
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.
- data/CHANGELOG +3 -0
- data/lib/cronos.rb +10 -6
- data/spec/cronos_spec.rb +13 -0
- metadata +1 -1
data/CHANGELOG
CHANGED
data/lib/cronos.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Cronos
|
|
2
2
|
|
|
3
|
-
VERSION = '0.6.
|
|
3
|
+
VERSION = '0.6.2'
|
|
4
4
|
|
|
5
5
|
def self.schedule(task)
|
|
6
6
|
TaskInterval.new(task)
|
|
@@ -370,14 +370,18 @@ module Cronos
|
|
|
370
370
|
|
|
371
371
|
[:min, :hour, :day, :month, :wday].all? do |period|
|
|
372
372
|
p = eval(period.to_s)
|
|
373
|
-
|
|
373
|
+
now = eval("time.#{period}")
|
|
374
|
+
p.gsub! /\*/, now.to_s
|
|
375
|
+
|
|
376
|
+
p.split(',').collect{ |parts|
|
|
374
377
|
if parts[/-/]
|
|
375
|
-
|
|
376
|
-
|
|
378
|
+
eval(parts.gsub(/-/, '..')).to_a.include? now
|
|
379
|
+
elsif parts[/\//]
|
|
380
|
+
eval(parts.gsub(/\//, '%')).zero?
|
|
377
381
|
else
|
|
378
|
-
parts
|
|
382
|
+
parts.to_s == now.to_s
|
|
379
383
|
end
|
|
380
|
-
}.flatten.include?
|
|
384
|
+
}.flatten.include? true
|
|
381
385
|
end
|
|
382
386
|
end
|
|
383
387
|
end
|
data/spec/cronos_spec.rb
CHANGED
|
@@ -452,6 +452,13 @@ describe Cronos::Parser do
|
|
|
452
452
|
Cronos::Parser.new("20,40 * 5,12 * 2,3,6").now?(time).should == true
|
|
453
453
|
end
|
|
454
454
|
|
|
455
|
+
it "should return true if cron_string matches a division" do
|
|
456
|
+
Cronos::Parser.new("*/20 * * * *").now?(time).should == true
|
|
457
|
+
Cronos::Parser.new("40 */7 * * *").now?(time).should == true
|
|
458
|
+
Cronos::Parser.new("*/20 14 */5 * *").now?(time).should == true
|
|
459
|
+
Cronos::Parser.new("*/20 14 */6,5 * *").now?(time).should == true
|
|
460
|
+
end
|
|
461
|
+
|
|
455
462
|
it "should return false if cron_string does not match some parts" do
|
|
456
463
|
Cronos::Parser.new("* 15 * * *").now?(time).should == false
|
|
457
464
|
Cronos::Parser.new("45 14 * * *").now?(time).should == false
|
|
@@ -474,6 +481,12 @@ describe Cronos::Parser do
|
|
|
474
481
|
Cronos::Parser.new("20,40 14 3,8,12 * *").now?(time).should == false
|
|
475
482
|
Cronos::Parser.new("20,40 14 5,12 * 0,6").now?(time).should == false
|
|
476
483
|
end
|
|
484
|
+
|
|
485
|
+
it "should return false if cron_string matches a division" do
|
|
486
|
+
Cronos::Parser.new("*/30 * * * *").now?(time).should == false
|
|
487
|
+
Cronos::Parser.new("40 */5 * * *").now?(time).should == false
|
|
488
|
+
Cronos::Parser.new("*/20 14 */6 * *").now?(time).should == false
|
|
489
|
+
end
|
|
477
490
|
end
|
|
478
491
|
|
|
479
492
|
def time
|