chrono 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82628fe0ca33aeac8bd5b8f6d72d570a250e5636
4
- data.tar.gz: 093720914965710dccca4dca1054616bc676e783
3
+ metadata.gz: 0d252cd6e02cae1bbb12c6a310402e15de067158
4
+ data.tar.gz: a8f41a68a6e85e74a05edc049cab7593f51e89e0
5
5
  SHA512:
6
- metadata.gz: 2bdc77b1029f70e80ccde05ac6c5a3f4fe84d8e39d34c1484cf1b56a84580b0234e0e01b9b1604937d705c4241940f953565f5ff436a193cfb26f930b7339751
7
- data.tar.gz: ff6f91a205265f49e78e208ada8f87f1c61d881d52c0bd9b6786eab1732944d8f72ce3fe1825327eacfa10f62507ca36a2cb92c11fbe709b6867bd1c41d95830
6
+ metadata.gz: 6e7cf6afc4ad77ade83fde6f5fea043dcfaa91167905cd2165e872840264f57395e93dbe22e11003568537b9998e90f42d0f066741b036b6dfac0fe57ce17f04
7
+ data.tar.gz: 29f662fa1ea7aa28d9e613e1bc73c80b6869662e003e52f92f5250e4c3da5c574b59d0829c4d16f478054db219f44723dcf405083d8c51435c31f811d6cec050
@@ -1,3 +1,7 @@
1
+ ## 0.4.0
2
+
3
+ - Raise ArgumentError on inifinite loop detected (thx @nurse)
4
+
1
5
  ## 0.3.0
2
6
  - Fix bug on day and wday specs
3
7
 
@@ -21,7 +21,10 @@ module Chrono
21
21
  end
22
22
 
23
23
  def to_time
24
- loop do
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
- break time
38
+ return @time
36
39
  end
37
40
  end
41
+ raise ArgumentError, "invalid cron string '#{@source}'"
38
42
  end
39
43
 
40
44
  private
@@ -1,3 +1,3 @@
1
1
  module Chrono
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -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
- it 'raises error when empty range is given' do
34
- expect { described_class.new('5-0 * * * *').next }.to raise_error(Chrono::Fields::Base::InvalidField)
35
- end
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
- it 'raises error when too large upper is given' do
38
- expect { described_class.new('5-60 * * * *').next }.to raise_error(Chrono::Fields::Base::InvalidField)
39
- end
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
- it 'raises error when too low lower is given' do
42
- expect { described_class.new('* * 0 * *').next }.to raise_error(Chrono::Fields::Base::InvalidField)
43
- end
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
- it 'raises error when unparsable field is given' do
46
- expect { described_class.new('a-z * * * *').next }.to raise_error(Chrono::Fields::Base::InvalidField)
47
- end
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.3.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: 2015-12-09 00:00:00.000000000 Z
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.4.5
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: