chrono 0.3.0 → 0.4.0
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/CHANGELOG.md +4 -0
- data/lib/chrono/next_time.rb +6 -2
- data/lib/chrono/version.rb +1 -1
- data/spec/chrono/iterator_spec.rb +17 -12
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d252cd6e02cae1bbb12c6a310402e15de067158
|
4
|
+
data.tar.gz: a8f41a68a6e85e74a05edc049cab7593f51e89e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e7cf6afc4ad77ade83fde6f5fea043dcfaa91167905cd2165e872840264f57395e93dbe22e11003568537b9998e90f42d0f066741b036b6dfac0fe57ce17f04
|
7
|
+
data.tar.gz: 29f662fa1ea7aa28d9e613e1bc73c80b6869662e003e52f92f5250e4c3da5c574b59d0829c4d16f478054db219f44723dcf405083d8c51435c31f811d6cec050
|
data/CHANGELOG.md
CHANGED
data/lib/chrono/next_time.rb
CHANGED
@@ -21,7 +21,10 @@ module Chrono
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def to_time
|
24
|
-
|
24
|
+
# the longest cycle is 4 years (leap year)
|
25
|
+
# Note that the combination of day-month and wday is OR
|
26
|
+
max_time = time + (365 * 3 + 366).days
|
27
|
+
while @time < max_time
|
25
28
|
case
|
26
29
|
when !scheduled_in_this_month?
|
27
30
|
carry_month
|
@@ -32,9 +35,10 @@ module Chrono
|
|
32
35
|
when !scheduled_in_this_minute?
|
33
36
|
carry_minute
|
34
37
|
else
|
35
|
-
|
38
|
+
return @time
|
36
39
|
end
|
37
40
|
end
|
41
|
+
raise ArgumentError, "invalid cron string '#{@source}'"
|
38
42
|
end
|
39
43
|
|
40
44
|
private
|
data/lib/chrono/version.rb
CHANGED
@@ -24,27 +24,32 @@ describe Chrono::Iterator do
|
|
24
24
|
"2000-01-01 00:20:00", "2000-01-01 01:01:00", "1-20/3 * * * *",
|
25
25
|
"2000-01-01 00:00:00", "2000-01-03 00:00:00", "0 0 1,15 * 1",
|
26
26
|
"2000-01-01 00:00:00", "2000-01-05 00:00:00", "0 0 5,15,25 * 5",
|
27
|
+
"2000-02-29 00:00:01", "2004-02-29 00:00:00", "0 0 29 2 *",
|
27
28
|
].each_slice(3) do |from, to, source|
|
28
29
|
it "ticks #{from} to #{to} by #{source}" do
|
29
30
|
now = Time.parse(from)
|
30
31
|
expect(described_class.new(source, now: now).next).to eq(Time.parse(to))
|
31
32
|
end
|
33
|
+
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
it 'raises error when empty range is given' do
|
36
|
+
expect { described_class.new('5-0 * * * *').next }.to raise_error(Chrono::Fields::Base::InvalidField)
|
37
|
+
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
it 'raises error when too large upper is given' do
|
40
|
+
expect { described_class.new('5-60 * * * *').next }.to raise_error(Chrono::Fields::Base::InvalidField)
|
41
|
+
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
it 'raises error when too low lower is given' do
|
44
|
+
expect { described_class.new('* * 0 * *').next }.to raise_error(Chrono::Fields::Base::InvalidField)
|
45
|
+
end
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
it 'raises error when unparsable field is given' do
|
48
|
+
expect { described_class.new('a-z * * * *').next }.to raise_error(Chrono::Fields::Base::InvalidField)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'raises error when unparsable field is given' do
|
52
|
+
expect { described_class.new('* * 31 11 *').next }.to raise_error(ArgumentError)
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chrono
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
147
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.
|
148
|
+
rubygems_version: 2.6.11
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: Provides a chain of logics about chronology.
|
@@ -154,4 +154,3 @@ test_files:
|
|
154
154
|
- spec/chrono/schedule_spec.rb
|
155
155
|
- spec/chrono/trigger_spec.rb
|
156
156
|
- spec/spec_helper.rb
|
157
|
-
has_rdoc:
|