timetress 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/timetress/holiday.rb +6 -0
- data/lib/timetress/version.rb +1 -1
- data/spec/holiday_spec.rb +9 -0
- metadata +2 -2
data/lib/timetress/holiday.rb
CHANGED
@@ -60,6 +60,12 @@ module Timetress
|
|
60
60
|
private
|
61
61
|
|
62
62
|
def next_holiday(holiday, given_date)
|
63
|
+
given_date ||= Date.today
|
64
|
+
|
65
|
+
unless given_date.respond_to?(:to_datetime)
|
66
|
+
raise ArgumentError.new("#{given_date.inspect} must be a date or time object")
|
67
|
+
end
|
68
|
+
|
63
69
|
the_day = self.send(holiday.to_sym, given_date.year)
|
64
70
|
|
65
71
|
if the_day < given_date
|
data/lib/timetress/version.rb
CHANGED
data/spec/holiday_spec.rb
CHANGED
@@ -105,5 +105,14 @@ describe Timetress::Holiday do
|
|
105
105
|
Timetress.next_pi_day(pi_day + 1).should eq(next_pi_day)
|
106
106
|
end
|
107
107
|
|
108
|
+
it "default is relative to today" do
|
109
|
+
Timetress::Norway.next_pi_day.should eq(Timetress::Norway.next_pi_day(Date.today))
|
110
|
+
end
|
111
|
+
|
112
|
+
it "complains if given a non-date argument" do
|
113
|
+
->{ Timetress::Norway.next_pi_day("a string") }.should raise_error(ArgumentError)
|
114
|
+
->{ Timetress::Norway.next_pi_day(1) }.should raise_error(ArgumentError)
|
115
|
+
end
|
116
|
+
|
108
117
|
end
|
109
118
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timetress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Answers the age-old question 'When is mothersday this year?'
|
15
15
|
email:
|