hiccup 0.5.8 → 0.5.9
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/lib/hiccup/enumerable/weekly_enumerator.rb +9 -2
- data/lib/hiccup/version.rb +1 -1
- data/test/weekly_enumerator_test.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb92bb351bb70b127d803017a755fbb60486e493
|
4
|
+
data.tar.gz: b16ac99ffe79acf0874df41d347b23820fbf395c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dfff15d9adb485161d7bc857e25a8836ad255d4bd9a49aaa8c1bd6a52eac5d25ace2ebca34ae5c2306bf7aad74477242b2c221eab4bbc9f47568bd838753dde
|
7
|
+
data.tar.gz: b972f70010604a6d1e7463351b6f60bf58ab1d8167101e0bed45ba9d033cb0cb4167fe7e8495be49fc0ca76d29a1d1808eac6452950e4d1bb00b722aadf7abb2
|
@@ -11,6 +11,13 @@ module Hiccup
|
|
11
11
|
Date::DAYNAMES.index(weekday)
|
12
12
|
end.sort
|
13
13
|
|
14
|
+
if @wday_pattern.empty?
|
15
|
+
@base_date = start_date
|
16
|
+
@starting_index = 0
|
17
|
+
@cycle = []
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
14
21
|
start_wday = start_date.wday
|
15
22
|
if start_wday <= @wday_pattern.first or start_wday > @wday_pattern.last
|
16
23
|
@base_date = start_date
|
@@ -60,7 +67,7 @@ module Hiccup
|
|
60
67
|
|
61
68
|
result = temp if !result || (temp < result)
|
62
69
|
end
|
63
|
-
@position = position_of(result)
|
70
|
+
@position = position_of(result) if result
|
64
71
|
result
|
65
72
|
end
|
66
73
|
|
@@ -77,7 +84,7 @@ module Hiccup
|
|
77
84
|
|
78
85
|
result = temp if !result || (temp > result)
|
79
86
|
end
|
80
|
-
@position = position_of(result)
|
87
|
+
@position = position_of(result) if result
|
81
88
|
result
|
82
89
|
end
|
83
90
|
|
data/lib/hiccup/version.rb
CHANGED
@@ -108,6 +108,28 @@ class WeeklyEnumeratorTest < ActiveSupport::TestCase
|
|
108
108
|
end
|
109
109
|
|
110
110
|
|
111
|
+
|
112
|
+
context "Given an invalid schedule with no weekly pattern, it" do
|
113
|
+
setup do
|
114
|
+
@schedule = Schedule.new(
|
115
|
+
:kind => :weekly,
|
116
|
+
:start_date => Date.new(2013, 9, 26),
|
117
|
+
:weekly_pattern => [])
|
118
|
+
end
|
119
|
+
|
120
|
+
should "return nil for prev rather than raising an exception" do
|
121
|
+
enumerator = @schedule.enumerator.new(@schedule, Date.today)
|
122
|
+
assert_equal nil, enumerator.prev
|
123
|
+
end
|
124
|
+
|
125
|
+
should "return nil for next rather than raising an exception" do
|
126
|
+
enumerator = @schedule.enumerator.new(@schedule, Date.today)
|
127
|
+
assert_equal nil, enumerator.next
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
|
111
133
|
private
|
112
134
|
|
113
135
|
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.
|
4
|
+
version: 0.5.9
|
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-
|
11
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|