norwegian_holidays 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/norwegian_holidays.rb +5 -3
- data/norwegian_holidays.gemspec +2 -7
- data/spec/norwegian_holidays_spec.rb +74 -28
- metadata +6 -29
- data/lib/norwegian_holidays/version.rb +0 -3
data/lib/norwegian_holidays.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
require 'date'
|
2
|
-
require "norwegian_holidays/version"
|
3
2
|
|
4
3
|
module NorwegianHolidays
|
5
4
|
|
6
5
|
class << self
|
7
6
|
|
8
|
-
|
9
|
-
def christmas(year)
|
7
|
+
def christmas_eve(year)
|
10
8
|
Date.new(year, 12, 24)
|
11
9
|
end
|
12
10
|
|
11
|
+
def christmas(year)
|
12
|
+
Date.new(year, 12, 25)
|
13
|
+
end
|
14
|
+
|
13
15
|
def valentines_day(year)
|
14
16
|
Date.new(year, 2, 14)
|
15
17
|
end
|
data/norwegian_holidays.gemspec
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "norwegian_holidays/version"
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "norwegian_holidays"
|
7
|
-
s.version =
|
6
|
+
s.version = "0.0.4"
|
8
7
|
s.authors = ["Katrina Owen"]
|
9
8
|
s.email = ["katrina.owen@gmail.com"]
|
10
|
-
s.homepage = ""
|
9
|
+
s.homepage = "http://github.com/kytrinyx/norwegian_holidays"
|
11
10
|
s.summary = %q{A Norwegian holiday calendar.}
|
12
11
|
s.description = %q{A Norwegian holiday calendar. Answers the age-old question: "When is mothersday this year?"}
|
13
12
|
|
@@ -18,9 +17,5 @@ Gem::Specification.new do |s|
|
|
18
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
18
|
s.require_paths = ["lib"]
|
20
19
|
|
21
|
-
# specify any dependencies here; for example:
|
22
20
|
s.add_development_dependency "rspec"
|
23
|
-
s.add_development_dependency "active_support"
|
24
|
-
s.add_development_dependency "i18n" #active support requires i18n but doesn't add dependency in bundle
|
25
|
-
# s.add_runtime_dependency "rest-client"
|
26
21
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'norwegian_holidays'
|
2
|
-
require 'active_support/core_ext'
|
3
2
|
|
4
3
|
describe NorwegianHolidays do
|
5
4
|
describe "#second_sunday_in(month, year)" do
|
@@ -16,34 +15,79 @@ describe NorwegianHolidays do
|
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
describe "Christmas" do
|
18
|
+
describe "Christmas Eve" do
|
19
|
+
let(:last_christmas) { Date.new(2010, 12, 24) }
|
20
20
|
let(:christmas) { Date.new(2011, 12, 24) }
|
21
|
+
let(:next_christmas) { Date.new(2012, 12, 24) }
|
21
22
|
|
22
|
-
it "is on
|
23
|
-
NorwegianHolidays.
|
23
|
+
it "is on Dec 24th" do
|
24
|
+
NorwegianHolidays.christmas_eve(2011).should eq(christmas)
|
24
25
|
end
|
25
26
|
|
26
27
|
describe "#next_christmas" do
|
27
28
|
|
28
29
|
it "is on Dec 24th" do
|
29
|
-
NorwegianHolidays.
|
30
|
+
NorwegianHolidays.next_christmas_eve(christmas - 1).should eq(christmas)
|
30
31
|
end
|
31
32
|
|
32
33
|
it "is this year if today is Christmas Eve" do
|
34
|
+
NorwegianHolidays.next_christmas_eve(christmas).should eq(christmas)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "is next year if it's already passed" do
|
38
|
+
NorwegianHolidays.next_christmas_eve(christmas + 1).should eq(next_christmas)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#christmas_for_season(date, timespan)" do
|
43
|
+
let(:timeframe) { 60 } # 60 days
|
44
|
+
let(:cutoff) { christmas - timeframe }
|
45
|
+
|
46
|
+
it "is this year if it's coming up within the timeframe" do
|
47
|
+
NorwegianHolidays.christmas_eve_for_season(cutoff + 1, timeframe).should eq(christmas)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "is this year if it's coming up in exactly the timeframe" do
|
51
|
+
NorwegianHolidays.christmas_eve_for_season(cutoff, timeframe).should eq(christmas)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "is last year if it's too long til the next one" do
|
55
|
+
NorwegianHolidays.christmas_eve_for_season(cutoff - 1, timeframe).should eq(last_christmas)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
describe "Christmas" do
|
62
|
+
let(:last_christmas) { Date.new(2010, 12, 25) }
|
63
|
+
let(:christmas) { Date.new(2011, 12, 25) }
|
64
|
+
let(:next_christmas) { Date.new(2012, 12, 25) }
|
65
|
+
|
66
|
+
it "is on Dec 25th" do
|
67
|
+
NorwegianHolidays.christmas(2011).should eq(christmas)
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#next_christmas" do
|
71
|
+
|
72
|
+
it "is on Dec 25th" do
|
73
|
+
NorwegianHolidays.next_christmas(christmas - 1).should eq(christmas)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "is this year if today is Christmas" do
|
33
77
|
NorwegianHolidays.next_christmas(christmas).should eq(christmas)
|
34
78
|
end
|
35
79
|
|
36
80
|
it "is next year if it's already passed" do
|
37
|
-
NorwegianHolidays.next_christmas(christmas + 1
|
81
|
+
NorwegianHolidays.next_christmas(christmas + 1).should eq(next_christmas)
|
38
82
|
end
|
39
83
|
end
|
40
84
|
|
41
85
|
describe "#christmas_for_season(date, timespan)" do
|
42
|
-
let(:timeframe) {
|
43
|
-
let(:cutoff) { christmas -
|
86
|
+
let(:timeframe) { 60 } # 60 days
|
87
|
+
let(:cutoff) { christmas - timeframe }
|
44
88
|
|
45
89
|
it "is this year if it's coming up within the timeframe" do
|
46
|
-
NorwegianHolidays.christmas_for_season(cutoff + 1
|
90
|
+
NorwegianHolidays.christmas_for_season(cutoff + 1, timeframe).should eq(christmas)
|
47
91
|
end
|
48
92
|
|
49
93
|
it "is this year if it's coming up in exactly the timeframe" do
|
@@ -51,13 +95,15 @@ describe NorwegianHolidays do
|
|
51
95
|
end
|
52
96
|
|
53
97
|
it "is last year if it's too long til the next one" do
|
54
|
-
NorwegianHolidays.christmas_for_season(cutoff - 1
|
98
|
+
NorwegianHolidays.christmas_for_season(cutoff - 1, timeframe).should eq(last_christmas)
|
55
99
|
end
|
56
100
|
end
|
57
101
|
end
|
58
102
|
|
59
103
|
describe "Valentines Day" do
|
104
|
+
let(:last_valentines_day) { Date.new(2010, 2, 14) }
|
60
105
|
let(:valentines_day) { Date.new(2011, 2, 14) }
|
106
|
+
let(:next_valentines_day) { Date.new(2012, 2, 14) }
|
61
107
|
|
62
108
|
it "is on Feb 14th" do
|
63
109
|
NorwegianHolidays.valentines_day(2011).should eq(valentines_day)
|
@@ -66,7 +112,7 @@ describe NorwegianHolidays do
|
|
66
112
|
describe "#next_valentines_day" do
|
67
113
|
|
68
114
|
it "is on Feb 14th" do
|
69
|
-
NorwegianHolidays.next_valentines_day(valentines_day - 1
|
115
|
+
NorwegianHolidays.next_valentines_day(valentines_day - 1).should eq(valentines_day)
|
70
116
|
end
|
71
117
|
|
72
118
|
it "is this year if today is valentines day" do
|
@@ -74,16 +120,16 @@ describe NorwegianHolidays do
|
|
74
120
|
end
|
75
121
|
|
76
122
|
it "is next year if it's already passed" do
|
77
|
-
NorwegianHolidays.next_valentines_day(valentines_day + 1
|
123
|
+
NorwegianHolidays.next_valentines_day(valentines_day + 1).should eq(next_valentines_day)
|
78
124
|
end
|
79
125
|
end
|
80
126
|
|
81
127
|
describe "#valentines_day_for_season(date, timespan)" do
|
82
|
-
let(:timeframe) {
|
83
|
-
let(:cutoff) { valentines_day -
|
128
|
+
let(:timeframe) { 60 } # 60 days
|
129
|
+
let(:cutoff) { valentines_day - timeframe }
|
84
130
|
|
85
131
|
it "is this year if it's coming up within the timeframe" do
|
86
|
-
NorwegianHolidays.valentines_day_for_season(cutoff + 1
|
132
|
+
NorwegianHolidays.valentines_day_for_season(cutoff + 1, timeframe).should eq(valentines_day)
|
87
133
|
end
|
88
134
|
|
89
135
|
it "is this year if it's coming up in exactly the timeframe" do
|
@@ -91,7 +137,7 @@ describe NorwegianHolidays do
|
|
91
137
|
end
|
92
138
|
|
93
139
|
it "is last year if it's too long til the next one" do
|
94
|
-
NorwegianHolidays.valentines_day_for_season(cutoff - 1
|
140
|
+
NorwegianHolidays.valentines_day_for_season(cutoff - 1, timeframe).should eq(last_valentines_day)
|
95
141
|
end
|
96
142
|
end
|
97
143
|
|
@@ -130,13 +176,13 @@ describe NorwegianHolidays do
|
|
130
176
|
|
131
177
|
context "before mothersday" do
|
132
178
|
it "is this year" do
|
133
|
-
NorwegianHolidays.next_mothersday(mothersday_2010 - 1
|
179
|
+
NorwegianHolidays.next_mothersday(mothersday_2010 - 1).should eq(mothersday_2010)
|
134
180
|
end
|
135
181
|
end
|
136
182
|
|
137
183
|
context "after mothersday" do
|
138
184
|
it "is next year" do
|
139
|
-
NorwegianHolidays.next_mothersday(mothersday_2010 + 1
|
185
|
+
NorwegianHolidays.next_mothersday(mothersday_2010 + 1).should eq(mothersday_2011)
|
140
186
|
end
|
141
187
|
end
|
142
188
|
end
|
@@ -145,11 +191,11 @@ describe NorwegianHolidays do
|
|
145
191
|
let(:mothersday) { mothersday_2011 }
|
146
192
|
let(:last_mothersday) { mothersday_2010 }
|
147
193
|
|
148
|
-
let(:
|
149
|
-
let(:
|
194
|
+
let(:timeframe) { 60 } # 60 days
|
195
|
+
let(:cutoff) { mothersday - timeframe }
|
150
196
|
|
151
197
|
it "is this year if it's coming up within the timeframe" do
|
152
|
-
NorwegianHolidays.mothersday_for_season(cutoff + 1
|
198
|
+
NorwegianHolidays.mothersday_for_season(cutoff + 1, timeframe).should eq(mothersday)
|
153
199
|
end
|
154
200
|
|
155
201
|
it "is this year if it's coming up in exactly the timeframe" do
|
@@ -157,7 +203,7 @@ describe NorwegianHolidays do
|
|
157
203
|
end
|
158
204
|
|
159
205
|
it "is last year if it's too long til the next one" do
|
160
|
-
NorwegianHolidays.mothersday_for_season(cutoff - 1
|
206
|
+
NorwegianHolidays.mothersday_for_season(cutoff - 1, timeframe).should eq(last_mothersday)
|
161
207
|
end
|
162
208
|
end
|
163
209
|
end
|
@@ -194,13 +240,13 @@ describe NorwegianHolidays do
|
|
194
240
|
|
195
241
|
context "before fathersday" do
|
196
242
|
it "is this year" do
|
197
|
-
NorwegianHolidays.next_fathersday(fathersday_2010 - 1
|
243
|
+
NorwegianHolidays.next_fathersday(fathersday_2010 - 1).should eq(fathersday_2010)
|
198
244
|
end
|
199
245
|
end
|
200
246
|
|
201
247
|
context "after fathersday" do
|
202
248
|
it "is next year" do
|
203
|
-
NorwegianHolidays.next_fathersday(fathersday_2010 + 1
|
249
|
+
NorwegianHolidays.next_fathersday(fathersday_2010 + 1).should eq(fathersday_2011)
|
204
250
|
end
|
205
251
|
end
|
206
252
|
end
|
@@ -208,11 +254,11 @@ describe NorwegianHolidays do
|
|
208
254
|
describe "#fathersday_for_season(date, timespan)" do
|
209
255
|
let(:fathersday) { fathersday_2011 }
|
210
256
|
let(:last_fathersday) { fathersday_2010 }
|
211
|
-
let(:timeframe) {
|
212
|
-
let(:cutoff) { fathersday -
|
257
|
+
let(:timeframe) { 60 } # 60 days
|
258
|
+
let(:cutoff) { fathersday - timeframe }
|
213
259
|
|
214
260
|
it "is this year if it's coming up within the timeframe" do
|
215
|
-
NorwegianHolidays.fathersday_for_season(cutoff + 1
|
261
|
+
NorwegianHolidays.fathersday_for_season(cutoff + 1, timeframe).should eq(fathersday)
|
216
262
|
end
|
217
263
|
|
218
264
|
it "is this year if it's coming up in exactly the timeframe" do
|
@@ -220,7 +266,7 @@ describe NorwegianHolidays do
|
|
220
266
|
end
|
221
267
|
|
222
268
|
it "is last year if it's too long til the next one" do
|
223
|
-
NorwegianHolidays.fathersday_for_season(cutoff - 1
|
269
|
+
NorwegianHolidays.fathersday_for_season(cutoff - 1, timeframe).should eq(last_fathersday)
|
224
270
|
end
|
225
271
|
end
|
226
272
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: norwegian_holidays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70247961821980 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,29 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: active_support
|
27
|
-
requirement: &70358087822000 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ! '>='
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '0'
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70358087822000
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: i18n
|
38
|
-
requirement: &70358087821580 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ! '>='
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0'
|
44
|
-
type: :development
|
45
|
-
prerelease: false
|
46
|
-
version_requirements: *70358087821580
|
24
|
+
version_requirements: *70247961821980
|
47
25
|
description: ! 'A Norwegian holiday calendar. Answers the age-old question: "When
|
48
26
|
is mothersday this year?"'
|
49
27
|
email:
|
@@ -58,10 +36,9 @@ files:
|
|
58
36
|
- README.md
|
59
37
|
- Rakefile
|
60
38
|
- lib/norwegian_holidays.rb
|
61
|
-
- lib/norwegian_holidays/version.rb
|
62
39
|
- norwegian_holidays.gemspec
|
63
40
|
- spec/norwegian_holidays_spec.rb
|
64
|
-
homepage:
|
41
|
+
homepage: http://github.com/kytrinyx/norwegian_holidays
|
65
42
|
licenses: []
|
66
43
|
post_install_message:
|
67
44
|
rdoc_options: []
|
@@ -81,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
58
|
version: '0'
|
82
59
|
requirements: []
|
83
60
|
rubyforge_project: norwegian_holidays
|
84
|
-
rubygems_version: 1.8.
|
61
|
+
rubygems_version: 1.8.15
|
85
62
|
signing_key:
|
86
63
|
specification_version: 3
|
87
64
|
summary: A Norwegian holiday calendar.
|