hiccup 0.5.20 → 0.6.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/.ruby-version +1 -0
- data/.travis.yml +1 -1
- data/README.mdown +3 -2
- data/hiccup.gemspec +9 -6
- data/lib/hiccup/schedule.rb +2 -1
- data/lib/hiccup/version.rb +1 -1
- data/test/core_ext_date_test.rb +2 -2
- data/test/enumerable_test.rb +5 -5
- data/test/humanizable_test.rb +2 -2
- data/test/inferrable_test.rb +27 -27
- data/test/leap_year_test.rb +1 -1
- data/test/performance_test.rb +2 -2
- data/test/test_helper.rb +8 -6
- data/test/weekly_enumerator_test.rb +8 -8
- metadata +49 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65667b19946a8c1a0f340632b1573a086cbf6703
|
4
|
+
data.tar.gz: 13711342f02bbfe9aafdd40d7dd176869acf21d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0499a77cc41eb22337b6ffea764a6658cc9566b61dac2e1789294ee08494bb749d9214c5d5730a0a363078cd6fefabfd62f79cadd4d4f6b7d533e3f387fdad71
|
7
|
+
data.tar.gz: 3bfde7a8eba8c66e6c7b30ff1fe2b86ae1501cc6a910364de860c22cd8be87cdf80417c0237c17661a0063df08a46c76fa06ea09b92736b7a8603f5566a3d9a2
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
CHANGED
data/README.mdown
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Hiccup
|
2
2
|
|
3
|
-
[](https://rubygems.org/gems/hiccup)
|
4
|
+
[](https://codeclimate.com/github/boblail/hiccup)
|
5
|
+
[](https://travis-ci.org/boblail/hiccup)
|
5
6
|
|
6
7
|
Hiccup mixes a-la-cart recurrence features into your recurring model. It doesn't dictate the data structure of your model, just the interface. It works like Devise does for authenticatable models.
|
7
8
|
|
data/hiccup.gemspec
CHANGED
@@ -10,19 +10,22 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "http://boblail.github.com/hiccup/"
|
11
11
|
s.summary = %q{A library for working with things that recur}
|
12
12
|
s.description = %q{Hiccup mixes a-la-cart recurrence features into your data structure. It doesn't dictate the data structure, just the interface.}
|
13
|
-
|
13
|
+
|
14
14
|
s.rubyforge_project = "hiccup"
|
15
|
-
|
15
|
+
|
16
16
|
s.add_dependency "activesupport", ">= 3.2.8"
|
17
|
+
s.add_dependency "activemodel", ">= 3.2.8"
|
17
18
|
s.add_dependency "builder"
|
18
|
-
|
19
|
+
|
19
20
|
s.add_development_dependency "ri_cal"
|
20
|
-
s.add_development_dependency "
|
21
|
-
s.add_development_dependency "
|
21
|
+
s.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
s.add_development_dependency "rake", "~> 10.0"
|
23
|
+
s.add_development_dependency "minitest-reporters"
|
24
|
+
s.add_development_dependency "minitest-reporters-turn_reporter"
|
22
25
|
s.add_development_dependency "simplecov"
|
23
26
|
s.add_development_dependency "shoulda-context"
|
24
27
|
s.add_development_dependency "pry"
|
25
|
-
|
28
|
+
|
26
29
|
s.files = `git ls-files`.split("\n")
|
27
30
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
28
31
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
data/lib/hiccup/schedule.rb
CHANGED
data/lib/hiccup/version.rb
CHANGED
data/test/core_ext_date_test.rb
CHANGED
@@ -4,7 +4,7 @@ require "test_helper"
|
|
4
4
|
class CoreExtDateTest < ActiveSupport::TestCase
|
5
5
|
|
6
6
|
|
7
|
-
|
7
|
+
should "correctly identify the nth weekday of the month of a date" do
|
8
8
|
assert_equal 1, Date.new(2012, 7, 1).get_nth_wday_of_month
|
9
9
|
assert_equal 1, Date.new(2012, 7, 7).get_nth_wday_of_month
|
10
10
|
assert_equal 2, Date.new(2012, 7, 8).get_nth_wday_of_month
|
@@ -16,7 +16,7 @@ class CoreExtDateTest < ActiveSupport::TestCase
|
|
16
16
|
assert_equal 5, Date.new(2012, 7, 29).get_nth_wday_of_month
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
should "correctly identify the nth weekday of the month of a date as a string" do
|
20
20
|
assert_equal "1 Sunday", Date.new(2012, 7, 1).get_nth_wday_string
|
21
21
|
assert_equal "1 Saturday", Date.new(2012, 7, 7).get_nth_wday_string
|
22
22
|
assert_equal "2 Sunday", Date.new(2012, 7, 8).get_nth_wday_string
|
data/test/enumerable_test.rb
CHANGED
@@ -90,7 +90,7 @@ class EnumerableTest < ActiveSupport::TestCase
|
|
90
90
|
assert_equal expected_dates, dates, "occurrences_during_month did not correctly observe end date for weekly schedule"
|
91
91
|
end
|
92
92
|
|
93
|
-
|
93
|
+
should "keep weekly occurrences during a week together when skipping" do
|
94
94
|
schedule = Schedule.new(
|
95
95
|
:kind => :weekly,
|
96
96
|
:weekly_pattern => %w{Tuesday Thursday},
|
@@ -235,7 +235,7 @@ class EnumerableTest < ActiveSupport::TestCase
|
|
235
235
|
|
236
236
|
|
237
237
|
|
238
|
-
|
238
|
+
should "not throw an exception when calculating monthly recurrence and skip causes a guess to be discarded" do
|
239
239
|
schedule = Schedule.new({
|
240
240
|
:kind => :monthly,
|
241
241
|
:monthly_pattern => [
|
@@ -253,7 +253,7 @@ class EnumerableTest < ActiveSupport::TestCase
|
|
253
253
|
|
254
254
|
|
255
255
|
|
256
|
-
|
256
|
+
should "not predict dates before the beginning of a schedule" do
|
257
257
|
schedule = Schedule.new({
|
258
258
|
:kind => :weekly,
|
259
259
|
:weekly_pattern => %w{Monday},
|
@@ -266,7 +266,7 @@ class EnumerableTest < ActiveSupport::TestCase
|
|
266
266
|
assert_equal [], schedule.n_occurrences_on_or_before(10, Date.new(2011,1,2))
|
267
267
|
end
|
268
268
|
|
269
|
-
|
269
|
+
should "predict nonrecurring dates before a date later than them" do
|
270
270
|
schedule = Schedule.new({
|
271
271
|
:kind => :never,
|
272
272
|
:start_date => Date.new(2011, 1, 3)})
|
@@ -274,7 +274,7 @@ class EnumerableTest < ActiveSupport::TestCase
|
|
274
274
|
assert_equal [], schedule.n_occurrences_on_or_before(10, Date.new(2011,1,2))
|
275
275
|
end
|
276
276
|
|
277
|
-
|
277
|
+
should "not predict dates after the end of a schedule" do
|
278
278
|
schedule = Schedule.new({
|
279
279
|
:kind => :weekly,
|
280
280
|
:weekly_pattern => %w{Monday},
|
data/test/humanizable_test.rb
CHANGED
@@ -75,7 +75,7 @@ class HumanizableTest < ActiveSupport::TestCase
|
|
75
75
|
|
76
76
|
|
77
77
|
|
78
|
-
|
78
|
+
should "not have spaces in front of day numbers" do
|
79
79
|
independence_day = Schedule.new({
|
80
80
|
:kind => :annually,
|
81
81
|
:start_date => Date.new(2012, 7, 4)
|
@@ -83,7 +83,7 @@ class HumanizableTest < ActiveSupport::TestCase
|
|
83
83
|
assert_equal "Every year on July 4", independence_day.humanize
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
should "let you supply a format for strftime" do
|
87
87
|
assert_equal "July 4, 1776", Schedule.new(start_date: Date.new(1776, 7, 4)).humanize(format: "%B %-d, %Y")
|
88
88
|
end
|
89
89
|
|
data/test/inferrable_test.rb
CHANGED
@@ -8,7 +8,7 @@ class InferableTest < ActiveSupport::TestCase
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
should "raise an error if not given an array of dates" do
|
12
12
|
assert_raises ArgumentError do
|
13
13
|
Schedule.infer(["what's this?"])
|
14
14
|
end
|
@@ -30,7 +30,7 @@ class InferableTest < ActiveSupport::TestCase
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
|
33
|
+
should "prefer guesses that predict too many results over guesses that predict too few" do
|
34
34
|
|
35
35
|
# In this stream of dates, we could guess an annual recurrence on 1/15
|
36
36
|
# or a monthly recurrence on the 15th.
|
@@ -56,7 +56,7 @@ class InferableTest < ActiveSupport::TestCase
|
|
56
56
|
|
57
57
|
# Infers annual schedules
|
58
58
|
|
59
|
-
|
59
|
+
should "infer an annual" do
|
60
60
|
dates = %w{2010-3-4 2011-3-4 2012-3-4}
|
61
61
|
schedules = Schedule.infer(dates)
|
62
62
|
assert_equal ["Every year on March 4"], schedules.map(&:humanize)
|
@@ -65,7 +65,7 @@ class InferableTest < ActiveSupport::TestCase
|
|
65
65
|
|
66
66
|
# ... with skips
|
67
67
|
|
68
|
-
|
68
|
+
should "infer a schedule that occurs every other year" do
|
69
69
|
dates = %w{2010-3-4 2012-3-4 2014-3-4}
|
70
70
|
schedules = Schedule.infer(dates)
|
71
71
|
assert_equal ["Every other year on March 4"], schedules.map(&:humanize)
|
@@ -73,13 +73,13 @@ class InferableTest < ActiveSupport::TestCase
|
|
73
73
|
|
74
74
|
# ... where some of the input is wrong
|
75
75
|
|
76
|
-
|
76
|
+
should "infer a yearly schedule when one of the dates was rescheduled" do
|
77
77
|
dates = %w{2010-3-4 2011-9-15 2012-3-4 2013-3-4}
|
78
78
|
schedules = Schedule.infer(dates)
|
79
79
|
assert_equal ["Every year on March 4"], schedules.map(&:humanize)
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
should "infer a yearly schedule when the first date was rescheduled" do
|
83
83
|
dates = %w{2010-3-6 2011-3-4 2012-3-4 2013-3-4}
|
84
84
|
schedules = Schedule.infer(dates)
|
85
85
|
assert_equal ["Every year on March 4"], schedules.map(&:humanize)
|
@@ -91,7 +91,7 @@ class InferableTest < ActiveSupport::TestCase
|
|
91
91
|
|
92
92
|
# Infers monthly schedules
|
93
93
|
|
94
|
-
|
94
|
+
should "infer a monthly schedule that occurs on a date" do
|
95
95
|
dates = %w{2012-2-4 2012-3-4 2012-4-4}
|
96
96
|
schedules = Schedule.infer(dates)
|
97
97
|
assert_equal ["The 4th of every month"], schedules.map(&:humanize)
|
@@ -101,13 +101,13 @@ class InferableTest < ActiveSupport::TestCase
|
|
101
101
|
assert_equal ["The 17th of every month"], schedules.map(&:humanize)
|
102
102
|
end
|
103
103
|
|
104
|
-
|
104
|
+
should "infer a monthly schedule that occurs on a weekday" do
|
105
105
|
dates = %w{2012-7-9 2012-8-13 2012-9-10}
|
106
106
|
schedules = Schedule.infer(dates)
|
107
107
|
assert_equal ["The second Monday of every month"], schedules.map(&:humanize)
|
108
108
|
end
|
109
109
|
|
110
|
-
|
110
|
+
should "infer a schedule that occurs several times a month" do
|
111
111
|
dates = %w{2012-7-9 2012-7-23 2012-8-13 2012-8-27 2012-9-10 2012-9-24}
|
112
112
|
schedules = Schedule.infer(dates)
|
113
113
|
assert_equal ["The second Monday and fourth Monday of every month"], schedules.map(&:humanize)
|
@@ -116,7 +116,7 @@ class InferableTest < ActiveSupport::TestCase
|
|
116
116
|
|
117
117
|
# ... with skips
|
118
118
|
|
119
|
-
|
119
|
+
should "infer a schedule that occurs every third month" do
|
120
120
|
dates = %w{2012-2-4 2012-5-4 2012-8-4}
|
121
121
|
schedules = Schedule.infer(dates)
|
122
122
|
assert_equal ["The 4th of every third month"], schedules.map(&:humanize)
|
@@ -125,32 +125,32 @@ class InferableTest < ActiveSupport::TestCase
|
|
125
125
|
|
126
126
|
# ... when some dates are wrong in the input group
|
127
127
|
|
128
|
-
|
128
|
+
should "infer a monthly (by day) schedule when one day was rescheduled" do
|
129
129
|
dates = %w{2012-10-02 2012-11-02 2012-12-03}
|
130
130
|
schedules = Schedule.infer(dates)
|
131
131
|
assert_equal ["The 2nd of every month"], schedules.map(&:humanize)
|
132
132
|
end
|
133
133
|
|
134
|
-
|
134
|
+
should "infer a monthly (by day) schedule when the first day was rescheduled" do
|
135
135
|
dates = %w{2012-10-03 2012-11-02 2012-12-02}
|
136
136
|
schedules = Schedule.infer(dates)
|
137
137
|
assert_equal ["The 2nd of every month"], schedules.map(&:humanize)
|
138
138
|
end
|
139
139
|
|
140
140
|
|
141
|
-
|
141
|
+
should "infer a monthly (by weekday) schedule when one day was rescheduled" do
|
142
142
|
dates = %w{2012-10-02 2012-11-06 2012-12-05} # 1st Tuesday, 1st Tuesday, 1st Wednesday
|
143
143
|
schedules = Schedule.infer(dates)
|
144
144
|
assert_equal ["The first Tuesday of every month"], schedules.map(&:humanize)
|
145
145
|
end
|
146
146
|
|
147
|
-
|
147
|
+
should "infer a monthly (by weekday) schedule when the first day was rescheduled" do
|
148
148
|
dates = %w{2012-10-03 2012-11-01 2012-12-06} # 1st Wednesday, 1st Thursday, 1st Thursday
|
149
149
|
schedules = Schedule.infer(dates)
|
150
150
|
assert_equal ["The first Thursday of every month"], schedules.map(&:humanize)
|
151
151
|
end
|
152
152
|
|
153
|
-
|
153
|
+
should "infer a monthly (by weekday) schedule when the first day was rescheduled 2" do
|
154
154
|
dates = %w{2012-10-11 2012-11-01 2012-12-06} # 2nd Thursday, 1st Thursday, 1st Thursday
|
155
155
|
schedules = Schedule.infer(dates)
|
156
156
|
assert_equal ["The first Thursday of every month"], schedules.map(&:humanize)
|
@@ -162,13 +162,13 @@ class InferableTest < ActiveSupport::TestCase
|
|
162
162
|
|
163
163
|
# Infers weekly schedules
|
164
164
|
|
165
|
-
|
165
|
+
should "infer a weekly schedule" do
|
166
166
|
dates = %w{2012-3-4 2012-3-11 2012-3-18}
|
167
167
|
schedules = Schedule.infer(dates)
|
168
168
|
assert_equal ["Every Sunday"], schedules.map(&:humanize)
|
169
169
|
end
|
170
170
|
|
171
|
-
|
171
|
+
should "infer a schedule that occurs several times a week" do
|
172
172
|
dates = %w{2012-3-6 2012-3-8 2012-3-13 2012-3-15 2012-3-20 2012-3-22}
|
173
173
|
schedules = Schedule.infer(dates)
|
174
174
|
assert_equal ["Every Tuesday and Thursday"], schedules.map(&:humanize)
|
@@ -177,7 +177,7 @@ class InferableTest < ActiveSupport::TestCase
|
|
177
177
|
|
178
178
|
# ... with skips
|
179
179
|
|
180
|
-
|
180
|
+
should "infer weekly recurrence for something that occurs every other week" do
|
181
181
|
dates = %w{2012-3-6 2012-3-8 2012-3-20 2012-3-22}
|
182
182
|
schedules = Schedule.infer(dates)
|
183
183
|
assert_equal ["Tuesday and Thursday of every other week"], schedules.map(&:humanize)
|
@@ -186,13 +186,13 @@ class InferableTest < ActiveSupport::TestCase
|
|
186
186
|
|
187
187
|
# ... when some dates are missing from the input array
|
188
188
|
|
189
|
-
|
189
|
+
should "infer a weekly schedule (missing dates)" do
|
190
190
|
dates = %w{2012-3-4 2012-3-11 2012-3-25}
|
191
191
|
schedules = Schedule.infer(dates)
|
192
192
|
assert_equal ["Every Sunday"], schedules.map(&:humanize)
|
193
193
|
end
|
194
194
|
|
195
|
-
|
195
|
+
should "infer a schedule that occurs several times a week (missing dates)" do
|
196
196
|
dates = %w{2012-3-6 2012-3-8 2012-3-15 2012-3-20 2012-3-27 2012-3-29}
|
197
197
|
schedules = Schedule.infer(dates)
|
198
198
|
assert_equal ["Every Tuesday and Thursday"], schedules.map(&:humanize)
|
@@ -201,13 +201,13 @@ class InferableTest < ActiveSupport::TestCase
|
|
201
201
|
|
202
202
|
# ... when some dates are wrong in the input group
|
203
203
|
|
204
|
-
|
204
|
+
should "infer a weekly schedule when one day was rescheduled" do
|
205
205
|
dates = %w{2012-10-02 2012-10-09 2012-10-15} # a Tuesday, a Tuesday, and a Monday
|
206
206
|
schedules = Schedule.infer(dates)
|
207
207
|
assert_equal ["Every Tuesday"], schedules.map(&:humanize)
|
208
208
|
end
|
209
209
|
|
210
|
-
|
210
|
+
should "infer a weekly schedule when the first day was rescheduled" do
|
211
211
|
dates = %w{2012-10-07 2012-10-10 2012-10-17} # a Sunday, a Wednesday, and a Wednesday
|
212
212
|
schedules = Schedule.infer(dates)
|
213
213
|
assert_equal ["Every Wednesday"], schedules.map(&:humanize)
|
@@ -218,7 +218,7 @@ class InferableTest < ActiveSupport::TestCase
|
|
218
218
|
|
219
219
|
# Correctly identifies scenarios where there is no pattern
|
220
220
|
|
221
|
-
|
221
|
+
should "not try to guess a pattern for input where there is none" do
|
222
222
|
arbitrary_date_ranges = [
|
223
223
|
%w{2013-01-01 2013-03-30 2014-08-19},
|
224
224
|
%w{2012-10-01 2012-10-09 2012-10-17}, # a Monday, a Tuesday, and a Wednesday
|
@@ -230,7 +230,7 @@ class InferableTest < ActiveSupport::TestCase
|
|
230
230
|
end
|
231
231
|
end
|
232
232
|
|
233
|
-
|
233
|
+
should "create one non-recurring schedule for each break if asked" do
|
234
234
|
dates = %w{2012-03-05 2012-11-28 2012-12-05 2012-12-12} # a random Monday, then three Wednesdays
|
235
235
|
schedules = Schedule.infer(dates, allow_null_schedules: true)
|
236
236
|
|
@@ -239,7 +239,7 @@ class InferableTest < ActiveSupport::TestCase
|
|
239
239
|
|
240
240
|
|
241
241
|
|
242
|
-
|
242
|
+
should "infer multiple schedules from mixed input" do
|
243
243
|
dates = %w{2012-11-05 2012-11-12 2012-11-19 2012-11-28 2012-12-05 2012-12-12} # three Mondays then three Wednesdays
|
244
244
|
schedules = Schedule.infer(dates)
|
245
245
|
|
@@ -248,13 +248,13 @@ class InferableTest < ActiveSupport::TestCase
|
|
248
248
|
|
249
249
|
|
250
250
|
|
251
|
-
|
251
|
+
should "reject diabolically complex schedules by default" do
|
252
252
|
dates = %w{2012-11-06 2012-11-08 2012-11-15 2012-11-20 2012-11-27 2012-11-29 2013-02-05 2013-02-14 2013-02-21 2013-02-19 2013-02-26 2013-05-07 2013-05-09 2013-05-16 2013-05-28 2013-05-21 2013-05-30}
|
253
253
|
schedules = Schedule.infer(dates)
|
254
254
|
refute_equal ["The first Tuesday, second Thursday, third Thursday, third Tuesday, fourth Tuesday, and fifth Thursday of every third month"], schedules.map(&:humanize)
|
255
255
|
end
|
256
256
|
|
257
|
-
|
257
|
+
should "infer diabolically complex schedules on demand" do
|
258
258
|
dates = %w{2012-11-06 2012-11-08 2012-11-15 2012-11-20 2012-11-27 2012-11-29 2013-02-05 2013-02-14 2013-02-21 2013-02-19 2013-02-26 2013-05-07 2013-05-09 2013-05-16 2013-05-28 2013-05-21 2013-05-30}
|
259
259
|
schedules = Schedule.infer(dates, max_complexity: 99)
|
260
260
|
assert_equal ["The first Tuesday, second Thursday, third Thursday, third Tuesday, fourth Tuesday, and fifth Thursday of every third month"], schedules.map(&:humanize)
|
data/test/leap_year_test.rb
CHANGED
@@ -6,7 +6,7 @@ class LeapYearTest < ActiveSupport::TestCase
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
should "correctly determine whether a year is a leap year or not" do
|
10
10
|
enum = Enumerable::ScheduleEnumerator.new(Schedule.new, Date.today)
|
11
11
|
|
12
12
|
assert enum.send(:leap_year?, 1988), "1988 is a leap year"
|
data/test/performance_test.rb
CHANGED
@@ -8,7 +8,7 @@ class PerformanceTest < ActiveSupport::TestCase
|
|
8
8
|
{ 100 => 50,
|
9
9
|
500 => 50,
|
10
10
|
1000 => 50 }.each do |number, expected_duration|
|
11
|
-
|
11
|
+
should "generated guesses from #{number} dates in under #{expected_duration}ms" do
|
12
12
|
guesser = Hiccup::Inferable::Guesser.new(Hiccup::Schedule)
|
13
13
|
dates = (0...number).map { |i| Date.new(2010, 1, 1) + i.week }
|
14
14
|
duration = Benchmark.ms { guesser.generate_guesses(dates) }
|
@@ -24,7 +24,7 @@ class PerformanceTest < ActiveSupport::TestCase
|
|
24
24
|
{ 10 => 0.1.seconds,
|
25
25
|
50 => 0.5.seconds,
|
26
26
|
100 => 1.0.seconds }.each do |number, expected_duration|
|
27
|
-
|
27
|
+
should "infer a schedule from #{number} dates in under #{expected_duration} second(s)" do
|
28
28
|
dates = (0...number).map { |i| Date.new(2010, 1, 1) + i.week }
|
29
29
|
duration = Benchmark.ms { Schedule.infer(dates, verbosity: 0) } / 1000
|
30
30
|
assert duration <= expected_duration, "It took %.2f seconds" % duration
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require "rubygems"
|
2
|
-
|
3
|
-
|
4
|
-
require "rails/test_help"
|
5
|
-
require "active_support/core_ext"
|
6
|
-
require "turn"
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
7
4
|
require "hiccup/schedule"
|
5
|
+
|
6
|
+
require "minitest/reporters/turn_reporter"
|
7
|
+
MiniTest::Reporters.use! Minitest::Reporters::TurnReporter.new
|
8
|
+
|
9
|
+
require "active_support/core_ext"
|
8
10
|
require "shoulda/context"
|
9
|
-
require "
|
11
|
+
require "minitest/autorun"
|
@@ -6,13 +6,13 @@ class WeeklyEnumeratorTest < ActiveSupport::TestCase
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
should "generate a cycle of [7] for something that occurs every week on one day" do
|
10
10
|
assert_equal [7], cycle_for(
|
11
11
|
:start_date => Date.new(2013, 9, 23),
|
12
12
|
:weekly_pattern => ["Monday"])
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
should "generate a cycle of [21] for something that occurs every _third_ week on one day" do
|
16
16
|
assert_equal [21], cycle_for(
|
17
17
|
:start_date => Date.new(2013, 9, 23),
|
18
18
|
:weekly_pattern => ["Monday"],
|
@@ -21,14 +21,14 @@ class WeeklyEnumeratorTest < ActiveSupport::TestCase
|
|
21
21
|
|
22
22
|
|
23
23
|
|
24
|
-
|
24
|
+
should "generate a cycle of [6, 8] for something that occurs every other Saturday and Sunday when the start date is a Sunday" do
|
25
25
|
assert_equal [6, 8], cycle_for(
|
26
26
|
:start_date => Date.new(2013, 9, 22),
|
27
27
|
:weekly_pattern => ["Saturday", "Sunday"],
|
28
28
|
:skip => 2)
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
should "generate a cycle of [8, 6] for something that occurs every other Saturday and Sunday when the start date is a Saturday" do
|
32
32
|
assert_equal [8, 6], cycle_for(
|
33
33
|
:start_date => Date.new(2013, 9, 28),
|
34
34
|
:weekly_pattern => ["Saturday", "Sunday"],
|
@@ -37,21 +37,21 @@ class WeeklyEnumeratorTest < ActiveSupport::TestCase
|
|
37
37
|
|
38
38
|
|
39
39
|
|
40
|
-
|
40
|
+
should "generate a cycle of [2, 2, 10] for something that occurs every other Monday, Wednesday, Friday when the start date is a Monday" do
|
41
41
|
assert_equal [2, 2, 10], cycle_for(
|
42
42
|
:start_date => Date.new(2013, 9, 23),
|
43
43
|
:weekly_pattern => ["Monday", "Wednesday", "Friday"],
|
44
44
|
:skip => 2)
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
should "generate a cycle of [2, 10, 2] for something that occurs every other Monday, Wednesday, Friday when the start date is a Wednesday" do
|
48
48
|
assert_equal [2, 10, 2], cycle_for(
|
49
49
|
:start_date => Date.new(2013, 9, 25),
|
50
50
|
:weekly_pattern => ["Monday", "Wednesday", "Friday"],
|
51
51
|
:skip => 2)
|
52
52
|
end
|
53
53
|
|
54
|
-
|
54
|
+
should "generate a cycle of [10, 2, 2] for something that occurs every other Monday, Wednesday, Friday when the start date is a Friday" do
|
55
55
|
assert_equal [10, 2, 2], cycle_for(
|
56
56
|
:start_date => Date.new(2013, 9, 27),
|
57
57
|
:weekly_pattern => ["Monday", "Wednesday", "Friday"],
|
@@ -60,7 +60,7 @@ class WeeklyEnumeratorTest < ActiveSupport::TestCase
|
|
60
60
|
|
61
61
|
|
62
62
|
|
63
|
-
|
63
|
+
should "generate a cycle of [2, 5] for something that occurs every Tuesday and Thursday when the start date is a Friday" do
|
64
64
|
assert_equal [2, 5], cycle_for(
|
65
65
|
:start_date => Date.new(2013, 9, 27),
|
66
66
|
:weekly_pattern => ["Tuesday", "Thursday"])
|
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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Lail
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activemodel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.8
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.8
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: builder
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,27 +67,49 @@ dependencies:
|
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - "
|
73
|
+
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
|
75
|
+
version: '1.10'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.10'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
63
88
|
- !ruby/object:Gem::Version
|
64
|
-
version:
|
89
|
+
version: '10.0'
|
65
90
|
type: :development
|
66
91
|
prerelease: false
|
67
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest-reporters
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
68
100
|
requirements:
|
69
101
|
- - ">="
|
70
102
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
72
|
-
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
73
109
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
110
|
+
version: '0'
|
75
111
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
112
|
+
name: minitest-reporters-turn_reporter
|
77
113
|
requirement: !ruby/object:Gem::Requirement
|
78
114
|
requirements:
|
79
115
|
- - ">="
|
@@ -137,6 +173,7 @@ extensions: []
|
|
137
173
|
extra_rdoc_files: []
|
138
174
|
files:
|
139
175
|
- ".gitignore"
|
176
|
+
- ".ruby-version"
|
140
177
|
- ".simplecov"
|
141
178
|
- ".travis.yml"
|
142
179
|
- Gemfile
|
@@ -200,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
237
|
version: '0'
|
201
238
|
requirements: []
|
202
239
|
rubyforge_project: hiccup
|
203
|
-
rubygems_version: 2.
|
240
|
+
rubygems_version: 2.5.1
|
204
241
|
signing_key:
|
205
242
|
specification_version: 4
|
206
243
|
summary: A library for working with things that recur
|