alexdunae-holidays 0.9.4
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.
- data/CHANGELOG +15 -0
- data/LICENSE +21 -0
- data/README.rdoc +77 -0
- data/REFERENCES +16 -0
- data/data/SYNTAX +111 -0
- data/data/au.yaml +106 -0
- data/data/build_defs.rb +152 -0
- data/data/ca.yaml +141 -0
- data/data/de.yaml +115 -0
- data/data/dk.yaml +117 -0
- data/data/es.yaml +161 -0
- data/data/fr.yaml +70 -0
- data/data/gb.yaml +106 -0
- data/data/ie.yaml +58 -0
- data/data/index.yaml +23 -0
- data/data/is.yaml +136 -0
- data/data/it.yaml +66 -0
- data/data/mx.yaml +106 -0
- data/data/nl.yaml +67 -0
- data/data/north_america_informal.yaml +49 -0
- data/data/nyse.yaml +63 -0
- data/data/pt.yaml +85 -0
- data/data/se.yaml +91 -0
- data/data/united_nations.yaml +188 -0
- data/data/ups.yaml +56 -0
- data/data/us.yaml +81 -0
- data/data/za.yaml +78 -0
- data/lib/holidays.rb +404 -0
- data/lib/holidays/MANIFEST +25 -0
- data/lib/holidays/au.rb +41 -0
- data/lib/holidays/ca.rb +68 -0
- data/lib/holidays/de.rb +52 -0
- data/lib/holidays/dk.rb +47 -0
- data/lib/holidays/es.rb +52 -0
- data/lib/holidays/europe.rb +215 -0
- data/lib/holidays/fr.rb +36 -0
- data/lib/holidays/gb.rb +40 -0
- data/lib/holidays/ie.rb +32 -0
- data/lib/holidays/is.rb +61 -0
- data/lib/holidays/it.rb +35 -0
- data/lib/holidays/mx.rb +51 -0
- data/lib/holidays/nl.rb +36 -0
- data/lib/holidays/north_america.rb +107 -0
- data/lib/holidays/nyse.rb +32 -0
- data/lib/holidays/pt.rb +37 -0
- data/lib/holidays/scandinavia.rb +114 -0
- data/lib/holidays/se.rb +52 -0
- data/lib/holidays/united_nations.rb +24 -0
- data/lib/holidays/ups.rb +31 -0
- data/lib/holidays/us.rb +48 -0
- data/lib/holidays/za.rb +35 -0
- data/test/defs/test_defs_au.rb +36 -0
- data/test/defs/test_defs_ca.rb +29 -0
- data/test/defs/test_defs_de.rb +46 -0
- data/test/defs/test_defs_dk.rb +30 -0
- data/test/defs/test_defs_es.rb +57 -0
- data/test/defs/test_defs_europe.rb +240 -0
- data/test/defs/test_defs_fr.rb +26 -0
- data/test/defs/test_defs_gb.rb +36 -0
- data/test/defs/test_defs_ie.rb +21 -0
- data/test/defs/test_defs_is.rb +33 -0
- data/test/defs/test_defs_it.rb +25 -0
- data/test/defs/test_defs_mx.rb +22 -0
- data/test/defs/test_defs_nl.rb +24 -0
- data/test/defs/test_defs_north_america.rb +54 -0
- data/test/defs/test_defs_nyse.rb +22 -0
- data/test/defs/test_defs_pt.rb +32 -0
- data/test/defs/test_defs_scandinavia.rb +75 -0
- data/test/defs/test_defs_se.rb +32 -0
- data/test/defs/test_defs_ups.rb +21 -0
- data/test/defs/test_defs_us.rb +23 -0
- data/test/defs/test_defs_za.rb +25 -0
- data/test/test_date.rb +87 -0
- data/test/test_helper.rb +11 -0
- data/test/test_holidays.rb +117 -0
- data/test/test_multiple_regions.rb +20 -0
- metadata +164 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
|
2
|
+
|
|
3
|
+
require 'holidays/ca'
|
|
4
|
+
|
|
5
|
+
# Re-include CA defs via holidays/north_america to ensure that individual
|
|
6
|
+
# defs aren't duplicated.
|
|
7
|
+
require 'holidays/north_america'
|
|
8
|
+
|
|
9
|
+
class HolidaysTests < Test::Unit::TestCase
|
|
10
|
+
def setup
|
|
11
|
+
@date = Date.civil(2008,1,1)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_on
|
|
15
|
+
h = Holidays.on(Date.civil(2008,9,1), :ca)
|
|
16
|
+
assert_equal 'Labour Day', h[0][:name]
|
|
17
|
+
|
|
18
|
+
holidays = Holidays.on(Date.civil(2008,7,4), :ca)
|
|
19
|
+
assert_equal 0, holidays.length
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_between
|
|
23
|
+
holidays = Holidays.between(Date.civil(2008,7,1), Date.civil(2008,7,1), :ca)
|
|
24
|
+
assert_equal 1, holidays.length
|
|
25
|
+
|
|
26
|
+
holidays = Holidays.between(Date.civil(2008,7,1), Date.civil(2008,7,31), :ca)
|
|
27
|
+
assert_equal 1, holidays.length
|
|
28
|
+
|
|
29
|
+
holidays = Holidays.between(Date.civil(2008,7,2), Date.civil(2008,7,31), :ca)
|
|
30
|
+
assert_equal 0, holidays.length
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_requires_valid_regions
|
|
34
|
+
assert_raises Holidays::UnkownRegionError do
|
|
35
|
+
Holidays.on(Date.civil(2008,1,1), :xx)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
assert_raises Holidays::UnkownRegionError do
|
|
39
|
+
Holidays.on(Date.civil(2008,1,1), [:ca,:xx])
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
assert_raises Holidays::UnkownRegionError do
|
|
43
|
+
Holidays.between(Date.civil(2008,1,1), Date.civil(2008,12,31), [:ca,:xx])
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_region_params
|
|
48
|
+
holidays = Holidays.on(@date, :ca)
|
|
49
|
+
assert_equal 1, holidays.length
|
|
50
|
+
|
|
51
|
+
holidays = Holidays.on(@date, [:ca_bc,:ca])
|
|
52
|
+
assert_equal 1, holidays.length
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_observed_dates
|
|
56
|
+
# Should fall on Tuesday the 1st
|
|
57
|
+
assert_equal 1, Holidays.on(Date.civil(2008,7,1), :ca, :observed).length
|
|
58
|
+
|
|
59
|
+
# Should fall on Monday the 2nd
|
|
60
|
+
assert_equal 1, Holidays.on(Date.civil(2007,7,2), :ca, :observed).length
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_any_region
|
|
64
|
+
# Should return Victoria Day.
|
|
65
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca)
|
|
66
|
+
assert_equal 1, holidays.length
|
|
67
|
+
|
|
68
|
+
# Should return Victoria Day and National Patriotes Day.
|
|
69
|
+
#
|
|
70
|
+
# Should be 2 in the CA region but other regional files are loaded during the
|
|
71
|
+
# unit tests add to the :any count.
|
|
72
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), [:any])
|
|
73
|
+
assert holidays.length >= 2
|
|
74
|
+
|
|
75
|
+
# Test blank region
|
|
76
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31))
|
|
77
|
+
assert holidays.length >= 3
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_sub_regions
|
|
81
|
+
# Should return Victoria Day.
|
|
82
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca)
|
|
83
|
+
assert_equal 1, holidays.length
|
|
84
|
+
|
|
85
|
+
# Should return Victoria Da and National Patriotes Day.
|
|
86
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca_qc)
|
|
87
|
+
assert 2, holidays.length
|
|
88
|
+
|
|
89
|
+
# Should return Victoria Day and National Patriotes Day.
|
|
90
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca_)
|
|
91
|
+
assert_equal 2, holidays.length
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_easter_sunday
|
|
95
|
+
assert_equal '1800-04-13', Holidays.easter(1800).to_s
|
|
96
|
+
assert_equal '1899-04-02', Holidays.easter(1899).to_s
|
|
97
|
+
assert_equal '1900-04-15', Holidays.easter(1900).to_s
|
|
98
|
+
assert_equal '1999-04-04', Holidays.easter(1999).to_s
|
|
99
|
+
assert_equal '2000-04-23', Holidays.easter(2000).to_s
|
|
100
|
+
assert_equal '2025-04-20', Holidays.easter(2025).to_s
|
|
101
|
+
assert_equal '2035-03-25', Holidays.easter(2035).to_s
|
|
102
|
+
assert_equal '2067-04-03', Holidays.easter(2067).to_s
|
|
103
|
+
assert_equal '2099-04-12', Holidays.easter(2099).to_s
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test_easter_lambda
|
|
107
|
+
[Date.civil(1800,4,11), Date.civil(1899,3,31), Date.civil(1900,4,13),
|
|
108
|
+
Date.civil(2008,3,21), Date.civil(2035,3,23)].each do |date|
|
|
109
|
+
assert_equal 'Good Friday', Holidays.on(date, :ca)[0][:name]
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
[Date.civil(1800,4,14), Date.civil(1899,4,3), Date.civil(1900,4,16),
|
|
113
|
+
Date.civil(2008,3,24), Date.civil(2035,3,26)].each do |date|
|
|
114
|
+
assert_equal 'Easter Monday', Holidays.on(date, :ca_qc, :informal)[0][:name]
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
|
2
|
+
require 'holidays/gb'
|
|
3
|
+
require 'holidays/ie'
|
|
4
|
+
|
|
5
|
+
class MultipleRegionsTests < Test::Unit::TestCase
|
|
6
|
+
def setup
|
|
7
|
+
@date = Date.civil(2008,1,1)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_defining_holidays
|
|
11
|
+
h = Holidays.on(Date.civil(2008,12,26), :ie)
|
|
12
|
+
assert_equal 'St. Stephen\'s Day', h[0][:name]
|
|
13
|
+
|
|
14
|
+
h = Holidays.on(Date.civil(2008,5,9), :je)
|
|
15
|
+
assert_equal 'Liberation Day', h[0][:name]
|
|
16
|
+
|
|
17
|
+
h = Holidays.on(Date.civil(2008,5,9), :gb)
|
|
18
|
+
assert h.empty?
|
|
19
|
+
end
|
|
20
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: alexdunae-holidays
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.9.4
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Alex Dunae
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2008-12-29 00:00:00 -08:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!
|
|
17
|
+
email: code@dunae.ca
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- README.rdoc
|
|
24
|
+
- data/SYNTAX
|
|
25
|
+
- lib/holidays/MANIFEST
|
|
26
|
+
- REFERENCES
|
|
27
|
+
- CHANGELOG
|
|
28
|
+
- LICENSE
|
|
29
|
+
files:
|
|
30
|
+
- data/au.yaml
|
|
31
|
+
- data/build_defs.rb
|
|
32
|
+
- data/ca.yaml
|
|
33
|
+
- data/de.yaml
|
|
34
|
+
- data/dk.yaml
|
|
35
|
+
- data/es.yaml
|
|
36
|
+
- data/fr.yaml
|
|
37
|
+
- data/gb.yaml
|
|
38
|
+
- data/ie.yaml
|
|
39
|
+
- data/index.yaml
|
|
40
|
+
- data/is.yaml
|
|
41
|
+
- data/it.yaml
|
|
42
|
+
- data/mx.yaml
|
|
43
|
+
- data/nl.yaml
|
|
44
|
+
- data/north_america_informal.yaml
|
|
45
|
+
- data/nyse.yaml
|
|
46
|
+
- data/pt.yaml
|
|
47
|
+
- data/se.yaml
|
|
48
|
+
- data/SYNTAX
|
|
49
|
+
- data/united_nations.yaml
|
|
50
|
+
- data/ups.yaml
|
|
51
|
+
- data/us.yaml
|
|
52
|
+
- data/za.yaml
|
|
53
|
+
- lib/holidays
|
|
54
|
+
- lib/holidays.rb
|
|
55
|
+
- lib/holidays/au.rb
|
|
56
|
+
- lib/holidays/ca.rb
|
|
57
|
+
- lib/holidays/de.rb
|
|
58
|
+
- lib/holidays/dk.rb
|
|
59
|
+
- lib/holidays/es.rb
|
|
60
|
+
- lib/holidays/europe.rb
|
|
61
|
+
- lib/holidays/fr.rb
|
|
62
|
+
- lib/holidays/gb.rb
|
|
63
|
+
- lib/holidays/ie.rb
|
|
64
|
+
- lib/holidays/is.rb
|
|
65
|
+
- lib/holidays/it.rb
|
|
66
|
+
- lib/holidays/MANIFEST
|
|
67
|
+
- lib/holidays/mx.rb
|
|
68
|
+
- lib/holidays/nl.rb
|
|
69
|
+
- lib/holidays/north_america.rb
|
|
70
|
+
- lib/holidays/nyse.rb
|
|
71
|
+
- lib/holidays/pt.rb
|
|
72
|
+
- lib/holidays/scandinavia.rb
|
|
73
|
+
- lib/holidays/se.rb
|
|
74
|
+
- lib/holidays/united_nations.rb
|
|
75
|
+
- lib/holidays/ups.rb
|
|
76
|
+
- lib/holidays/us.rb
|
|
77
|
+
- lib/holidays/za.rb
|
|
78
|
+
- test/defs
|
|
79
|
+
- test/test_date.rb
|
|
80
|
+
- test/test_helper.rb
|
|
81
|
+
- test/test_holidays.rb
|
|
82
|
+
- test/test_multiple_regions.rb
|
|
83
|
+
- test/defs/test_defs_au.rb
|
|
84
|
+
- test/defs/test_defs_ca.rb
|
|
85
|
+
- test/defs/test_defs_de.rb
|
|
86
|
+
- test/defs/test_defs_dk.rb
|
|
87
|
+
- test/defs/test_defs_es.rb
|
|
88
|
+
- test/defs/test_defs_europe.rb
|
|
89
|
+
- test/defs/test_defs_fr.rb
|
|
90
|
+
- test/defs/test_defs_gb.rb
|
|
91
|
+
- test/defs/test_defs_ie.rb
|
|
92
|
+
- test/defs/test_defs_is.rb
|
|
93
|
+
- test/defs/test_defs_it.rb
|
|
94
|
+
- test/defs/test_defs_mx.rb
|
|
95
|
+
- test/defs/test_defs_nl.rb
|
|
96
|
+
- test/defs/test_defs_north_america.rb
|
|
97
|
+
- test/defs/test_defs_nyse.rb
|
|
98
|
+
- test/defs/test_defs_pt.rb
|
|
99
|
+
- test/defs/test_defs_scandinavia.rb
|
|
100
|
+
- test/defs/test_defs_se.rb
|
|
101
|
+
- test/defs/test_defs_ups.rb
|
|
102
|
+
- test/defs/test_defs_us.rb
|
|
103
|
+
- test/defs/test_defs_za.rb
|
|
104
|
+
- README.rdoc
|
|
105
|
+
- REFERENCES
|
|
106
|
+
- CHANGELOG
|
|
107
|
+
- LICENSE
|
|
108
|
+
has_rdoc: true
|
|
109
|
+
homepage: http://code.dunae.ca/holidays
|
|
110
|
+
post_install_message:
|
|
111
|
+
rdoc_options:
|
|
112
|
+
- --all
|
|
113
|
+
- --inline-source
|
|
114
|
+
- --line-numbers
|
|
115
|
+
- --charset
|
|
116
|
+
- utf-8
|
|
117
|
+
require_paths:
|
|
118
|
+
- lib
|
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: "0"
|
|
124
|
+
version:
|
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: "0"
|
|
130
|
+
version:
|
|
131
|
+
requirements: []
|
|
132
|
+
|
|
133
|
+
rubyforge_project:
|
|
134
|
+
rubygems_version: 1.2.0
|
|
135
|
+
signing_key:
|
|
136
|
+
specification_version: 2
|
|
137
|
+
summary: A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!
|
|
138
|
+
test_files:
|
|
139
|
+
- test/defs
|
|
140
|
+
- test/test_date.rb
|
|
141
|
+
- test/test_helper.rb
|
|
142
|
+
- test/test_holidays.rb
|
|
143
|
+
- test/test_multiple_regions.rb
|
|
144
|
+
- test/defs/test_defs_au.rb
|
|
145
|
+
- test/defs/test_defs_ca.rb
|
|
146
|
+
- test/defs/test_defs_de.rb
|
|
147
|
+
- test/defs/test_defs_dk.rb
|
|
148
|
+
- test/defs/test_defs_es.rb
|
|
149
|
+
- test/defs/test_defs_europe.rb
|
|
150
|
+
- test/defs/test_defs_fr.rb
|
|
151
|
+
- test/defs/test_defs_gb.rb
|
|
152
|
+
- test/defs/test_defs_ie.rb
|
|
153
|
+
- test/defs/test_defs_is.rb
|
|
154
|
+
- test/defs/test_defs_it.rb
|
|
155
|
+
- test/defs/test_defs_mx.rb
|
|
156
|
+
- test/defs/test_defs_nl.rb
|
|
157
|
+
- test/defs/test_defs_north_america.rb
|
|
158
|
+
- test/defs/test_defs_nyse.rb
|
|
159
|
+
- test/defs/test_defs_pt.rb
|
|
160
|
+
- test/defs/test_defs_scandinavia.rb
|
|
161
|
+
- test/defs/test_defs_se.rb
|
|
162
|
+
- test/defs/test_defs_ups.rb
|
|
163
|
+
- test/defs/test_defs_us.rb
|
|
164
|
+
- test/defs/test_defs_za.rb
|