hiccup 0.5.4 → 0.5.5

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: 76c7bd6b71cf03ea4f9897a640bb377c9b99fbcd
4
- data.tar.gz: 5d8d072d237f71ce14cc1e31da9ba3bb6917a854
3
+ metadata.gz: 73e0335450c98c244067b003167f60fdba6539e0
4
+ data.tar.gz: cca4f04660cef3cd3e98e9ff8114c80233793bd7
5
5
  SHA512:
6
- metadata.gz: 89735aa481b1b83673566f0aebc0454c8a391a0f385db052d6ca727ce731247b897318ff1df39ad0d6b6d9e98f0c7953bfe1076a8ded0aa54c459556dba099b5
7
- data.tar.gz: 5867b146eaecda8e888c3399cf7f46e63d163e5acfe09f63696d6856ef775cf3690e4da4f77f92dbbe75ade0a2e102e1aaac9968a2df0f5541ef2045fb89cd5c
6
+ metadata.gz: d84ff40e107f34bcb963f3b9be57bd41a5c7642258c982edf63d8b955d5e6065245c94cb4bc384b37eef8d79f493324e2fb3f9e613a3be3ef3de27105ed71aa4
7
+ data.tar.gz: e08c0c65406a0c1d4b82fd222e1058b76fa44103bd45bbb632be4b1269459344fc1499a75e60737681601ce27e86f27618462a3298261ed98fd35ba880fee6b4
@@ -26,11 +26,15 @@ module Hiccup
26
26
  def advance!
27
27
  @year += skip
28
28
  current_date
29
+ rescue
30
+ advance!
29
31
  end
30
32
 
31
33
  def rewind!
32
34
  @year -= skip
33
35
  current_date
36
+ rescue
37
+ rewind!
34
38
  end
35
39
 
36
40
 
@@ -43,6 +47,8 @@ module Hiccup
43
47
  @year += (skip - remainder) if remainder > 0
44
48
 
45
49
  current_date
50
+ rescue
51
+ advance!
46
52
  end
47
53
 
48
54
  def first_occurrence_on_or_before(date)
@@ -53,6 +59,8 @@ module Hiccup
53
59
  @year -= remainder if remainder > 0
54
60
 
55
61
  current_date
62
+ rescue
63
+ rewind!
56
64
  end
57
65
 
58
66
 
@@ -33,6 +33,8 @@ module Hiccup
33
33
  day = cycle[@position]
34
34
  return self.next if day > last_day_of_month
35
35
  Date.new(year, month, day)
36
+ rescue
37
+ advance!
36
38
  end
37
39
 
38
40
  def rewind!
@@ -42,6 +44,8 @@ module Hiccup
42
44
  day = cycle[@position]
43
45
  return self.prev if day > last_day_of_month
44
46
  Date.new(year, month, day)
47
+ rescue
48
+ rewind!
45
49
  end
46
50
 
47
51
 
@@ -56,6 +60,8 @@ module Hiccup
56
60
  day = cycle[@position]
57
61
  return self.next if day > last_day_of_month
58
62
  Date.new(year, month, day)
63
+ rescue
64
+ advance!
59
65
  end
60
66
 
61
67
  def first_occurrence_on_or_before(date)
@@ -68,6 +74,8 @@ module Hiccup
68
74
  day = cycle[@position]
69
75
  return self.prev if day > last_day_of_month
70
76
  Date.new(year, month, day)
77
+ rescue
78
+ rewind!
71
79
  end
72
80
 
73
81
 
@@ -1,3 +1,3 @@
1
1
  module Hiccup
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
@@ -367,6 +367,46 @@ class EnumerableTest < ActiveSupport::TestCase
367
367
 
368
368
 
369
369
 
370
+ context "when a weekly schedule includes October 1582" do
371
+ setup do
372
+ @schedule = Schedule.new(
373
+ kind: :weekly,
374
+ weekly_pattern: %w{Monday},
375
+ start_date: Date.new(1582, 10, 1))
376
+ end
377
+
378
+ should "just skip the invalid dates" do
379
+ assert_equal %w{10/01 10/18 10/25}, occurrences_during_month(@schedule, 1582, 10).map { |d| d.strftime("%m/%d") }
380
+ end
381
+ end
382
+
383
+ context "when a monthly schedule includes October 1582" do
384
+ setup do
385
+ @schedule = Schedule.new(
386
+ kind: :monthly,
387
+ monthly_pattern: [5, 19],
388
+ start_date: Date.new(1582, 9, 5))
389
+ end
390
+
391
+ should "just skip the invalid dates" do
392
+ assert_equal %w{10/19}, occurrences_during_month(@schedule, 1582, 10).map { |d| d.strftime("%m/%d") }
393
+ end
394
+ end
395
+
396
+ context "when a yearly schedule includes October 1582" do
397
+ setup do
398
+ @schedule = Schedule.new(
399
+ kind: :annually,
400
+ start_date: Date.new(1580, 10, 8))
401
+ end
402
+
403
+ should "just skip the invalid dates" do
404
+ assert_equal [], occurrences_during_month(@schedule, 1582, 10).map { |d| d.strftime("%m/%d") }
405
+ end
406
+ end
407
+
408
+
409
+
370
410
  if ENV['PERFORMANCE_TEST']
371
411
  test "performance test" do
372
412
  n = 1000
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiccup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Lail
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-15 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project: hiccup
196
- rubygems_version: 2.0.14
196
+ rubygems_version: 2.2.1
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: A library for working with things that recur