hiccup 0.5.2 → 0.5.3

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: 04f487d3ef152b2d9acbe752721818bf43655d4a
4
- data.tar.gz: 6dd7029be2338fd9c38861c03d1e16e229df7ad9
3
+ metadata.gz: b30ca9bc9c9e2acf7107c08c0dd88ed0a869585c
4
+ data.tar.gz: 68dd036beda7f04cb915eae77a5fe0033b2454f3
5
5
  SHA512:
6
- metadata.gz: 199f5e264c7c492e68b12e4d5b6cbc55e86e308afe9171c5689e35fdaafd3f4dc1c9859098ceaa3668a6fc7aeb9eb150aa1089e41eae7111cc50f5b057684876
7
- data.tar.gz: 753a487f8efbf7f6f49769b2efda70cb84f8940fc1b37260ef04decc2ec3ce4e42752f7abc10d2220758428cb21bf0ef66cf2959b35a9d1049b049a050d45aba
6
+ metadata.gz: 66f8701394c598462e4178ccc5a10c915591c2206060a37c1724832a66c15712ea07652717e8f7d0bfdf8aa05c854507932b4b04907c219f5da62b8a58d8437f
7
+ data.tar.gz: c644a16b5d0c552c04ed193229236764d160f075f6679383f129812057da61ebb7d936976f0dffe70f0944f31a1e96e05dcbd2025f96a623c5ddeb6a22f04522
@@ -62,7 +62,7 @@ module Hiccup
62
62
  @year, @month = date.year, date.month
63
63
  get_context
64
64
 
65
- @position = cycle.index { |day| day <= date.day }
65
+ @position = cycle.rindex { |day| day <= date.day }
66
66
  prev_month unless @position
67
67
 
68
68
  day = cycle[@position]
@@ -1,3 +1,3 @@
1
1
  module Hiccup
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -0,0 +1,38 @@
1
+ require "test_helper"
2
+
3
+
4
+ class MonthlyEnumeratorTest < ActiveSupport::TestCase
5
+ include Hiccup
6
+
7
+
8
+ context "with a complex schedule" do
9
+ setup do
10
+ @schedule = Schedule.new({
11
+ :kind => :monthly,
12
+ :monthly_pattern => [
13
+ [1, "Sunday"],
14
+ [2, "Saturday"],
15
+ [2, "Sunday"],
16
+ [3, "Sunday"],
17
+ [4, "Saturday"],
18
+ [4, "Sunday"],
19
+ [5, "Sunday"] ],
20
+ start_date: Date.new(2005, 1, 8)
21
+ })
22
+ end
23
+
24
+ context "when enumerating backward" do
25
+
26
+ should "return the most-recent date prior to the start_date, NOT the earliest date in the month" do
27
+ # Start with a date in the middle of the month
28
+ # More than one date prior to the seed date, yet
29
+ # after the first of the month.
30
+ date = Date.new(2013, 10, 15)
31
+ enumerator = @schedule.enumerator.new(@schedule, date)
32
+ assert_equal Date.new(2013, 10, 13), enumerator.prev
33
+ end
34
+
35
+ end
36
+ end
37
+
38
+ end
@@ -93,6 +93,21 @@ class WeeklyEnumeratorTest < ActiveSupport::TestCase
93
93
 
94
94
 
95
95
 
96
+ context "with a complex schedule" do
97
+ setup do
98
+ @schedule = Schedule.new(
99
+ :kind => :weekly,
100
+ :start_date => Date.new(2013, 9, 26), # Thursday
101
+ :weekly_pattern => ["Tuesday", "Thursday", "Friday"])
102
+ end
103
+
104
+ should "pick the right date when enumerating backward" do
105
+ enumerator = @schedule.enumerator.new(@schedule, Date.new(2013, 10, 16)) # Wednesday!
106
+ assert_equal Date.new(2013, 10, 15), enumerator.prev
107
+ end
108
+ end
109
+
110
+
96
111
  private
97
112
 
98
113
  def cycle_for(options={})
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.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Lail
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-09 00:00:00.000000000 Z
11
+ date: 2013-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -168,6 +168,7 @@ files:
168
168
  - test/ical_serializable_test.rb
169
169
  - test/inferrable_test.rb
170
170
  - test/leap_year_test.rb
171
+ - test/monthly_enumerator_test.rb
171
172
  - test/performance_test.rb
172
173
  - test/test_helper.rb
173
174
  - test/validatable_test.rb
@@ -203,6 +204,7 @@ test_files:
203
204
  - test/ical_serializable_test.rb
204
205
  - test/inferrable_test.rb
205
206
  - test/leap_year_test.rb
207
+ - test/monthly_enumerator_test.rb
206
208
  - test/performance_test.rb
207
209
  - test/test_helper.rb
208
210
  - test/validatable_test.rb