hiccup 0.5.17 → 0.5.18
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b2f49ba420f01d88054405099c8018481fbd287
|
4
|
+
data.tar.gz: 238c4d45fefd07b91b72ec70c8cd43c23a324e40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6b93567956cd2211d490e8aea9533c4f18cbb2f5262f9ecf97e94084c31aa0261071bd9b345b19fa45ed97b9c15d90ffe710fd5fcd5fa9ae3d312e72bab782b
|
7
|
+
data.tar.gz: 8bfbda4a4ba9b3d338d4b579cbe86f3b1fceffab2bb3f6f153d22854d1d4516054d0a0c193b136c8551e8fb94573580b07d881a48c4168f0f55e8ae0b5c7a355
|
@@ -110,7 +110,8 @@ module Hiccup
|
|
110
110
|
if ordinal < 0
|
111
111
|
wday_of_last_of_month = Date.new(year, month, -1).wday
|
112
112
|
day = day + 7 if wday <= wday_of_last_of_month
|
113
|
-
day = day - wday_of_last_of_month + (ordinal * 7)
|
113
|
+
day = day - wday_of_last_of_month + (ordinal * 7)
|
114
|
+
day = last_day_of_month + day
|
114
115
|
else
|
115
116
|
wday_of_first_of_month = Date.new(year, month, 1).wday
|
116
117
|
day = day + 7 if (wday < wday_of_first_of_month)
|
@@ -119,7 +120,7 @@ module Hiccup
|
|
119
120
|
end
|
120
121
|
day
|
121
122
|
else
|
122
|
-
occurrence
|
123
|
+
coerce_day_to_positive(occurrence)
|
123
124
|
end
|
124
125
|
end
|
125
126
|
end
|
@@ -165,6 +166,12 @@ module Hiccup
|
|
165
166
|
end
|
166
167
|
|
167
168
|
|
169
|
+
def coerce_day_to_positive(index)
|
170
|
+
# Converts e.g. -1 (last day of the month) to 31
|
171
|
+
return index if index > 0
|
172
|
+
last_day_of_month + index + 1
|
173
|
+
end
|
174
|
+
|
168
175
|
end
|
169
176
|
end
|
170
177
|
end
|
data/lib/hiccup/version.rb
CHANGED
@@ -71,16 +71,15 @@ class MonthlyEnumeratorTest < ActiveSupport::TestCase
|
|
71
71
|
|
72
72
|
context "last of the month" do
|
73
73
|
should "return the last day of the month" do
|
74
|
-
date = Date.new(2014, 12,
|
74
|
+
date = Date.new(2014, 12, 30)
|
75
75
|
@schedule = Schedule.new(
|
76
76
|
kind: :monthly,
|
77
77
|
monthly_pattern: [-1],
|
78
78
|
start_date: date
|
79
79
|
)
|
80
80
|
enumerator = @schedule.enumerator.new(@schedule, date)
|
81
|
+
assert_equal Date.new(2014, 12, 31), enumerator.next
|
81
82
|
assert_equal Date.new(2015, 1, 31), enumerator.next
|
82
|
-
assert_equal Date.new(2015, 2, 28), enumerator.next
|
83
|
-
assert_equal Date.new(2015, 3, 31), enumerator.next
|
84
83
|
end
|
85
84
|
|
86
85
|
should "return the last sunday of the month" do
|
@@ -126,6 +125,27 @@ class MonthlyEnumeratorTest < ActiveSupport::TestCase
|
|
126
125
|
enumerator = @schedule.enumerator.new(@schedule, Date.new(2015, 2, 28))
|
127
126
|
assert_equal Date.new(2015, 2, 17), enumerator.prev
|
128
127
|
end
|
128
|
+
|
129
|
+
should "find the correct occurence on or after a date in the same month" do
|
130
|
+
date = Date.new(2016, 1, 1)
|
131
|
+
@schedule = Schedule.new(
|
132
|
+
kind: :monthly,
|
133
|
+
monthly_pattern: [[-1, "Sunday"]],
|
134
|
+
start_date: date
|
135
|
+
)
|
136
|
+
enumerator = @schedule.enumerator.new(@schedule, date)
|
137
|
+
assert_equal Date.new(2016, 1, 31), enumerator.next
|
138
|
+
end
|
139
|
+
|
140
|
+
should "find the correct occurence on or before a date in a subsequent month" do
|
141
|
+
@schedule = Schedule.new(
|
142
|
+
kind: :monthly,
|
143
|
+
monthly_pattern: [[-1, "Friday"]],
|
144
|
+
start_date: Date.new(2016, 1, 1)
|
145
|
+
)
|
146
|
+
enumerator = @schedule.enumerator.new(@schedule, Date.new(2016, 2, 1))
|
147
|
+
assert_equal Date.new(2016, 1, 29), enumerator.prev
|
148
|
+
end
|
129
149
|
end
|
130
150
|
|
131
151
|
context "with an empty schedule" do
|
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
|
+
version: 0.5.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Lail
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|