holidays 4.7.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/CHANGELOG.md +9 -0
  4. data/CONTRIBUTING.md +21 -11
  5. data/Makefile +9 -6
  6. data/holidays.gemspec +1 -1
  7. data/lib/generated_definitions/MANIFEST +1 -0
  8. data/lib/generated_definitions/REGIONS.rb +1 -1
  9. data/lib/generated_definitions/hk.rb +112 -0
  10. data/lib/generated_definitions/kr.rb +4 -4
  11. data/lib/holidays/errors.rb +1 -0
  12. data/lib/holidays/finder/context/parse_options.rb +8 -3
  13. data/lib/holidays/load_all_definitions.rb +0 -11
  14. data/lib/holidays/version.rb +1 -1
  15. data/test/defs/test_defs_hk.rb +38 -0
  16. data/test/defs/test_defs_jp.rb +1 -0
  17. data/test/defs/test_defs_kr.rb +1 -1
  18. data/test/holidays/definition/validator/test_region.rb +4 -0
  19. data/test/holidays/finder/context/test_parse_options.rb +9 -1
  20. data/test/integration/test_all_regions.rb +4 -4
  21. data/test/integration/test_custom_holidays.rb +4 -4
  22. data/test/integration/test_holidays.rb +6 -6
  23. metadata +6 -60
  24. data/definitions/README.md +0 -353
  25. data/definitions/ar.yaml +0 -93
  26. data/definitions/at.yaml +0 -72
  27. data/definitions/au.yaml +0 -378
  28. data/definitions/be_fr.yaml +0 -69
  29. data/definitions/be_nl.yaml +0 -69
  30. data/definitions/bg.yaml +0 -127
  31. data/definitions/br.yaml +0 -77
  32. data/definitions/ca.yaml +0 -317
  33. data/definitions/ch.yaml +0 -193
  34. data/definitions/cl.yaml +0 -94
  35. data/definitions/cr.yaml +0 -65
  36. data/definitions/cz.yaml +0 -73
  37. data/definitions/de.yaml +0 -209
  38. data/definitions/dk.yaml +0 -130
  39. data/definitions/ecb_target.yaml +0 -44
  40. data/definitions/el.yaml +0 -84
  41. data/definitions/es.yaml +0 -203
  42. data/definitions/federal_reserve.yaml +0 -114
  43. data/definitions/fedex.yaml +0 -62
  44. data/definitions/fi.yaml +0 -115
  45. data/definitions/fr.yaml +0 -79
  46. data/definitions/gb.yaml +0 -151
  47. data/definitions/hr.yaml +0 -79
  48. data/definitions/hu.yaml +0 -63
  49. data/definitions/ie.yaml +0 -89
  50. data/definitions/index.yaml +0 -61
  51. data/definitions/is.yaml +0 -146
  52. data/definitions/it.yaml +0 -67
  53. data/definitions/jp.yaml +0 -321
  54. data/definitions/kr.yaml +0 -282
  55. data/definitions/li.yaml +0 -107
  56. data/definitions/lt.yaml +0 -89
  57. data/definitions/lu.yaml +0 -56
  58. data/definitions/ma.yaml +0 -52
  59. data/definitions/mx.yaml +0 -106
  60. data/definitions/my.yaml +0 -51
  61. data/definitions/nerc.yaml +0 -51
  62. data/definitions/nl.yaml +0 -73
  63. data/definitions/no.yaml +0 -90
  64. data/definitions/north_america_informal.yaml +0 -61
  65. data/definitions/nyse.yaml +0 -64
  66. data/definitions/nz.yaml +0 -163
  67. data/definitions/pe.yaml +0 -119
  68. data/definitions/ph.yaml +0 -94
  69. data/definitions/pl.yaml +0 -320
  70. data/definitions/pt.yaml +0 -89
  71. data/definitions/ro.yaml +0 -78
  72. data/definitions/se.yaml +0 -120
  73. data/definitions/sg.yaml +0 -56
  74. data/definitions/si.yaml +0 -86
  75. data/definitions/sk.yaml +0 -80
  76. data/definitions/united_nations.yaml +0 -189
  77. data/definitions/ups.yaml +0 -62
  78. data/definitions/us.yaml +0 -103
  79. data/definitions/ve.yaml +0 -74
  80. data/definitions/vi.yaml +0 -29
  81. data/definitions/za.yaml +0 -80
@@ -28,21 +28,21 @@ class AllRegionsTests < Test::Unit::TestCase
28
28
  end
29
29
 
30
30
  def test_unknown_region_raises_exception
31
- assert_raise Holidays::UnknownRegionError do
31
+ assert_raise Holidays::InvalidRegion do
32
32
  Holidays.on(Date.civil(2014, 1, 1), :something_we_do_not_recognize)
33
33
  end
34
34
 
35
- assert_raise Holidays::UnknownRegionError do
35
+ assert_raise Holidays::InvalidRegion do
36
36
  Holidays.on(Date.civil(2020, 1, 1), :something_we_do_not_recognize)
37
37
  end
38
38
 
39
- assert_raise Holidays::UnknownRegionError do
39
+ assert_raise Holidays::InvalidRegion do
40
40
  Holidays.on(Date.civil(2030, 1, 1), :something_we_do_not_recognize)
41
41
  end
42
42
  end
43
43
 
44
44
  def test_malicious_load_attempt_raises_exception
45
- assert_raise Holidays::UnknownRegionError do
45
+ assert_raise Holidays::InvalidRegion do
46
46
  Holidays.between(Date.civil(2014, 1, 1), Date.civil(2016, 1, 1), '../../../../../../../../../../../../tmp/profile_pic.jpg')
47
47
  end
48
48
  end
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
3
3
  class CustomHolidaysTest < Test::Unit::TestCase
4
4
 
5
5
  def test_custom_region_present_after_single_file_parsing
6
- assert_raises Holidays::UnknownRegionError do
6
+ assert_raises Holidays::InvalidRegion do
7
7
  Holidays.on(Date.civil(2013,6,20), :custom_single_file)
8
8
  end
9
9
 
@@ -19,15 +19,15 @@ class CustomHolidaysTest < Test::Unit::TestCase
19
19
  end
20
20
 
21
21
  def test_custom_holidays_present_after_multiple_file_parsing
22
- assert_raises Holidays::UnknownRegionError do
22
+ assert_raises Holidays::InvalidRegion do
23
23
  Holidays.on(Date.civil(2013, 10,5), :custom_multiple_files)
24
24
  end
25
25
 
26
- assert_raises Holidays::UnknownRegionError do
26
+ assert_raises Holidays::InvalidRegion do
27
27
  Holidays.on(Date.civil(2013,3,1), :custom_multiple_files)
28
28
  end
29
29
 
30
- assert_raises Holidays::UnknownRegionError do
30
+ assert_raises Holidays::InvalidRegion do
31
31
  Holidays.on(Date.civil(2013,3,1), :custom_multiple_files_govt)
32
32
  end
33
33
 
@@ -45,30 +45,30 @@ class HolidaysTests < Test::Unit::TestCase
45
45
  end
46
46
 
47
47
  def test_requires_valid_regions
48
- assert_raises Holidays::UnknownRegionError do
48
+ assert_raises Holidays::InvalidRegion do
49
49
  Holidays.on(Date.civil(2008,1,1), :xx)
50
50
  end
51
51
 
52
- assert_raises Holidays::UnknownRegionError do
52
+ assert_raises Holidays::InvalidRegion do
53
53
  Holidays.on(Date.civil(2008,1,1), [:ca,:xx])
54
54
  end
55
55
 
56
- assert_raises Holidays::UnknownRegionError do
56
+ assert_raises Holidays::InvalidRegion do
57
57
  Holidays.between(Date.civil(2008,1,1), Date.civil(2008,12,31), [:ca,:xx])
58
58
  end
59
59
  end
60
60
 
61
61
  def test_requires_valid_regions_holiday_next
62
- assert_raises Holidays::UnknownRegionError do
62
+ assert_raises Holidays::InvalidRegion do
63
63
  Holidays.next_holidays(1, [:xx], Date.civil(2008,1,1))
64
64
  end
65
65
 
66
- assert_raises Holidays::UnknownRegionError do
66
+ assert_raises Holidays::InvalidRegion do
67
67
  Holidays.next_holidays(1, [:ca,:xx], Date.civil(2008,1,1))
68
68
  Holidays.on(Date.civil(2008,1,1), [:ca,:xx])
69
69
  end
70
70
 
71
- assert_raises Holidays::UnknownRegionError do
71
+ assert_raises Holidays::InvalidRegion do
72
72
  Holidays.next_holidays(1, [:ca,:xx])
73
73
  end
74
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holidays
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dunae
@@ -103,6 +103,7 @@ executables: []
103
103
  extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
+ - ".gitmodules"
106
107
  - CHANGELOG.md
107
108
  - CODE_OF_CONDUCT.md
108
109
  - CONTRIBUTING.md
@@ -114,64 +115,6 @@ files:
114
115
  - Rakefile
115
116
  - bin/console
116
117
  - bin/setup
117
- - definitions/README.md
118
- - definitions/ar.yaml
119
- - definitions/at.yaml
120
- - definitions/au.yaml
121
- - definitions/be_fr.yaml
122
- - definitions/be_nl.yaml
123
- - definitions/bg.yaml
124
- - definitions/br.yaml
125
- - definitions/ca.yaml
126
- - definitions/ch.yaml
127
- - definitions/cl.yaml
128
- - definitions/cr.yaml
129
- - definitions/cz.yaml
130
- - definitions/de.yaml
131
- - definitions/dk.yaml
132
- - definitions/ecb_target.yaml
133
- - definitions/el.yaml
134
- - definitions/es.yaml
135
- - definitions/federal_reserve.yaml
136
- - definitions/fedex.yaml
137
- - definitions/fi.yaml
138
- - definitions/fr.yaml
139
- - definitions/gb.yaml
140
- - definitions/hr.yaml
141
- - definitions/hu.yaml
142
- - definitions/ie.yaml
143
- - definitions/index.yaml
144
- - definitions/is.yaml
145
- - definitions/it.yaml
146
- - definitions/jp.yaml
147
- - definitions/kr.yaml
148
- - definitions/li.yaml
149
- - definitions/lt.yaml
150
- - definitions/lu.yaml
151
- - definitions/ma.yaml
152
- - definitions/mx.yaml
153
- - definitions/my.yaml
154
- - definitions/nerc.yaml
155
- - definitions/nl.yaml
156
- - definitions/no.yaml
157
- - definitions/north_america_informal.yaml
158
- - definitions/nyse.yaml
159
- - definitions/nz.yaml
160
- - definitions/pe.yaml
161
- - definitions/ph.yaml
162
- - definitions/pl.yaml
163
- - definitions/pt.yaml
164
- - definitions/ro.yaml
165
- - definitions/se.yaml
166
- - definitions/sg.yaml
167
- - definitions/si.yaml
168
- - definitions/sk.yaml
169
- - definitions/united_nations.yaml
170
- - definitions/ups.yaml
171
- - definitions/us.yaml
172
- - definitions/ve.yaml
173
- - definitions/vi.yaml
174
- - definitions/za.yaml
175
118
  - holidays.gemspec
176
119
  - lib/generated_definitions/MANIFEST
177
120
  - lib/generated_definitions/REGIONS.rb
@@ -199,6 +142,7 @@ files:
199
142
  - lib/generated_definitions/fi.rb
200
143
  - lib/generated_definitions/fr.rb
201
144
  - lib/generated_definitions/gb.rb
145
+ - lib/generated_definitions/hk.rb
202
146
  - lib/generated_definitions/hr.rb
203
147
  - lib/generated_definitions/hu.rb
204
148
  - lib/generated_definitions/ie.rb
@@ -298,6 +242,7 @@ files:
298
242
  - test/defs/test_defs_fi.rb
299
243
  - test/defs/test_defs_fr.rb
300
244
  - test/defs/test_defs_gb.rb
245
+ - test/defs/test_defs_hk.rb
301
246
  - test/defs/test_defs_hr.rb
302
247
  - test/defs/test_defs_hu.rb
303
248
  - test/defs/test_defs_ie.rb
@@ -383,7 +328,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
383
328
  requirements:
384
329
  - - "~>"
385
330
  - !ruby/object:Gem::Version
386
- version: '2.0'
331
+ version: '2.1'
387
332
  required_rubygems_version: !ruby/object:Gem::Requirement
388
333
  requirements:
389
334
  - - ">="
@@ -426,6 +371,7 @@ test_files:
426
371
  - test/defs/test_defs_fi.rb
427
372
  - test/defs/test_defs_fr.rb
428
373
  - test/defs/test_defs_gb.rb
374
+ - test/defs/test_defs_hk.rb
429
375
  - test/defs/test_defs_hr.rb
430
376
  - test/defs/test_defs_hu.rb
431
377
  - test/defs/test_defs_ie.rb
@@ -1,353 +0,0 @@
1
- # Holiday Gem Definition Syntax
2
-
3
- All holidays are defined in YAML files in the `definitions/` directory. These definition files have three main top-level properties:
4
-
5
- * `months` - this is the meat! All definitions for months 1-12 are defined here
6
- * `methods` - this contains any custom logic that your definitions require
7
- * `tests` - this contains the tests for your definitions
8
-
9
- The `months` property is required. The two other properties are not strictly required but are almost always used.
10
-
11
- In fact, if you leave out `tests` your PR will probably not be accepted unless there is a very, very good reason for leaving it out.
12
-
13
- ## Key Words
14
-
15
- There are some terms that you should be familiar with before we dive into each section:
16
-
17
- #### `region`
18
-
19
- A region is a symbol that denotes the geographic or cultural region for that holiday. In general these symbols will be the [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166) code for a country or region.
20
-
21
- Please note that before version v1.1.0 the compliance with ISO 3166 was not as strict. There might be cases where an existing region symbol does not match the standard.
22
-
23
- In addition, some sub-regions do not have a matching ISO 3116 entry. In those cases we attempt to choose symbols that are reasonably clear.
24
-
25
- Examples: `:us` for USA, `:fr` for France, `:us_dc` for Washington, D.C in USA
26
-
27
- #### `formal`/`informal`
28
-
29
- We consider `formal` dates as government-defined holidays. These could be the kinds of holidays where everyone stays home from work or perhaps are bank holidays but it is *not required* for a holiday to have these features to be considered formal.
30
-
31
- `Informal` holidays are holidays that everyone knows about but aren't enshrined in law. For example, Valentine's Day in the US is considered an informal holiday.
32
-
33
- We recognize that these definitions can be highly subjective. If you disagree with the current status of a holiday please open an issue so we can discuss it.
34
-
35
- #### `observed`
36
-
37
- There are certain holidays that can be legally observed on different days than they occur. For example, if a holiday falls on a Saturday but it is legally observed on the following Monday then you can define it as `observed` on the Monday. Please see the section below for more details and examples.
38
-
39
- ## Months
40
-
41
- Holidays are grouped by month from 1 through 12. Each entry within a month can have several properties depending on the behavior of the holiday. Each section below lays out the various different ways you can define your holiday.
42
-
43
- The two required properties are:
44
-
45
- * `name` - The name of the holiday
46
- * `regions` - One or more region codes (targeted to match [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166))
47
-
48
- ### Dates defined by a fixed date (e.g. January 1st)
49
-
50
- * `mday` - A non-negative integer representing day of the month (1 through 31).
51
-
52
- For example, the following holiday is on the first of January and available in the `:ca`, `:us` and `:au` regions:
53
-
54
- ```yaml
55
- 1:
56
- - name: New Year's Day
57
- regions: [ca, us, au]
58
- mday: 1
59
- ```
60
-
61
- ### Dates defined by a week number (e.g. first Monday of a month)
62
-
63
- * `wday` - A non-negative integer representing day of the week (0 = Sunday through 6 = Saturday).
64
- * `week` - A non-negative integer representing week number (1 = first week, 3 = third week, -1 = last week),
65
-
66
- For example, the following holiday is on the first Monday of September and available in the `:ca` region:
67
-
68
- ```yaml
69
- 9:
70
- - name: Labour Day
71
- regions: [ca]
72
- week: 1
73
- wday: 1
74
- ```
75
-
76
- ### 'Formal' vs 'Informal' types
77
-
78
- As mentioned above you can specify two different types. By default a holiday is considered 'formal'. By adding a `type: informal` to a definition you will mark it as 'informal' and it will only show up if the user specifically asks for it.
79
-
80
- Example:
81
-
82
- ```yaml
83
- 9:
84
- - name: Some Holiday
85
- regions: [fr]
86
- mday: 1
87
- type: informal
88
- ```
89
-
90
- If a user submits:
91
-
92
- ```ruby
93
- Holidays.on(Date.civil(2016, 9, 1), :fr)
94
- ```
95
-
96
- then they will not see the holiday. However, if they submit:
97
-
98
- ```ruby
99
- Holidays.on(Date.civil(2016, 9, 1), :fr, :informal)
100
- ```
101
-
102
- Then the holiday will be returned. This is especially useful for holidays like "Valentine's Day" in the USA, where it is commonly recognized as a holiday in society but not as a day that is celebrated by taking the day off.
103
-
104
- ### Year ranges
105
-
106
- Certain holidays in various countries are only in effect during specific year ranges. For example, a new holiday might come into effect that is only valid after a specific year (say, 2017).
107
-
108
- To address this we have the ability to specify these 'year ranges' in the definition. The gem will then only return a match on a date that adheres to these rules.
109
-
110
- There are a total of four selectors that can be specified. All must be specified in terms of 'years'.
111
-
112
- #### `before`
113
-
114
- The 'before' selector will only find a match if the supplied date takes place
115
- before or equal to the holiday.
116
-
117
- Example:
118
-
119
- ```yaml
120
- 7:
121
- name: 振替休日
122
- regions: [jp]
123
- mday: 1
124
- year_ranges:
125
- - before: 2002
126
- ```
127
-
128
- This will return successfully:
129
-
130
- ```ruby
131
- Holidays.on(Date.civil(2000, 7, 1), :jp)
132
- ```
133
-
134
- This will not:
135
-
136
- ```ruby
137
- Holidays.on(Date.civil(2016, 7, 1), :jp)
138
- ```
139
-
140
- #### `after`
141
-
142
- The 'after' selector will only find a match if the supplied date takes place
143
- after or equal to the holiday.
144
-
145
- Example:
146
-
147
- ```yaml
148
- 7:
149
- name: 振替休日
150
- regions: [jp]
151
- mday: 1
152
- year_ranges:
153
- - after: 2002
154
- ```
155
-
156
- This will return successfully:
157
-
158
- ```ruby
159
- Holidays.on(Date.civil(2016, 7, 1), :jp)
160
- ```
161
-
162
- This will not:
163
-
164
- ```ruby
165
- Holidays.on(Date.civil(2000, 7, 1), :jp)
166
- ```
167
-
168
- #### `limited`
169
-
170
- The 'limited' selector will only find a match if the supplied date takes place during
171
- one of the specified years. Multiple years can be specified.
172
-
173
- An array of years *must* be supplied. Individual integers will result in an error.
174
-
175
- Example:
176
-
177
- ```yaml
178
- 7:
179
- name: 振替休日
180
- regions: [jp]
181
- mday: 1
182
- year_ranges:
183
- - limited: [2002]
184
- ```
185
-
186
- This will return successfully:
187
-
188
- ```ruby
189
- Holidays.on(Date.civil(2002, 7, 1), :jp)
190
- ```
191
-
192
- This will not:
193
-
194
- ```ruby
195
- Holidays.on(Date.civil(2000, 7, 1), :jp)
196
- ```
197
-
198
- #### `between`
199
-
200
- The 'between' selector will only find a match if the supplied date takes place during the specified range of years. Only a single range is allowed at this time.
201
-
202
- Example:
203
-
204
- ```yaml
205
- 7:
206
- name: 振替休日
207
- regions: [jp]
208
- mday: 1
209
- year_ranges:
210
- - between: 1996..2002
211
- ```
212
-
213
- This will return successfully:
214
-
215
- ```ruby
216
- Holidays.on(Date.civil(2000, 7, 1), :jp)
217
- ```
218
-
219
- This will not:
220
-
221
- ```ruby
222
- Holidays.on(Date.civil(2003, 7, 1), :jp)
223
- Holidays.on(Date.civil(1995, 7, 1), :jp)
224
- ```
225
-
226
- ## Methods
227
-
228
- In addition to defining holidays by day or week, you can create custom methods to calculate a date. These should be placed under the `methods` property. Methods named in this way can then be referenced by entries in the `months` property.
229
-
230
- For example, Canada celebrates Victoria Day, which falls on the Monday on or before May 24. So, under the `methods` property we create a custom method that returns a Date object.
231
-
232
- ```
233
- methods:
234
- ca_victoria_day:
235
- arguments: year
236
- source: |
237
- date = Date.civil(year, 5, 24)
238
- if date.wday > 1
239
- date -= (date.wday - 1)
240
- elsif date.wday == 0
241
- date -= 6
242
- end
243
-
244
- date
245
- ```
246
-
247
- This would be represented in `months` entry as:
248
-
249
- ```
250
- 5:
251
- - name: Victoria Day
252
- regions: [ca]
253
- function: ca_victoria_day(year)
254
- ```
255
-
256
- If a holiday can occur in different months (e.g. Easter) it can go in the '0' month.
257
-
258
- ```
259
- 0:
260
- - name: Easter Monday
261
- regions: [ca]
262
- function: easter(year)
263
- ```
264
-
265
- There are pre-existing methods for highly-used calculations. They are:
266
-
267
- * `easter(year)` - calculates Easter via Gregorian calendar for a given year
268
- * `orthodox_easter(year)` - calculates Easter via Julian calendar for a given year
269
- * `to_monday_if_sunday(date)` - returns date of the following Monday if the 'date' argument falls on a Sunday
270
- * `to_monday_if_weekend(date)` - returns date of the following Monday if the 'date' argument falls on a weekend (Saturday or Sunday)
271
- * `to_weekday_if_boxing_weekend(date)` - returns nearest following weekday if the 'date' argument falls on Boxing Day
272
- * `to_weekday_if_boxing_weekend_from_year(year)` - calculates nearest weekday following Boxing weekend for given year
273
- * `to_weekday_if_weekend(date)` - returns nearest weekday (Monday or Friday) if 'date' argument falls on a weekend (Saturday or Sunday)
274
-
275
- *Protip*: you can use the `easter` methods to calculate all of the dates that are based around Easter. It's especially useful to use since the Easter calculation is complex. For example, 'Good Friday' in the US is 2 days before Easter. Therefore you could do the following:
276
-
277
- ```
278
- 0:
279
- - name: Good Friday
280
- regions: [us]
281
- function: easter(year)
282
- function_modifier: -2
283
- type: informal
284
- ```
285
-
286
- Use the `function_modifier` property, which can be positive or negative, to modify the result of the function.
287
-
288
- In addition, you may only specify the following values for arguments into a custom method: `date`, `year`, `month`, `day`.
289
-
290
- If attempt to specify anything else then you will receive an error on definition generation. This is because these are the only values that are available to
291
- call into the custom methods will calculating the result of a function.
292
-
293
- Correct example:
294
-
295
- ```
296
- 1:
297
- - name: Custom Method
298
- regions: [us]
299
- function: custom_method(year, month, day)
300
- ```
301
-
302
- If you do the following:
303
-
304
- ```
305
- 1:
306
- - name: Custom Method
307
- regions: [us]
308
- function: custom_method(week)
309
- ```
310
-
311
- This will result in an error since `week` is not a recognized method argument.
312
-
313
- ### Calculating observed dates
314
-
315
- Users can specify that this gem only return holidays on their 'observed' day. This can be especially useful if they are using this gem for business-related logic. If you wish for your definitions to allow for this then you can add the `observed` property to your entry. This requires a method to help calculate the observed day.
316
-
317
- Several built-in methods are available for holidays that are observed on varying dates. For example, for a holiday that is observed on Monday if it falls on a weekend you could write:
318
-
319
- ```
320
- 7:
321
- - name: Canada Day
322
- regions: [ca]
323
- mday: 1
324
- observed: to_monday_if_weekend(date)
325
- ```
326
-
327
- If a user does not specify `observed` when calling the gem then 1/1 will be the date found for 'Canada Day', regardless of whether it falls on a Saturday or Sunday. If a user specifies 'observed' then it will show as the following Monday if the date falls on a Saturday or Sunday.
328
-
329
- ## Tests
330
-
331
- All definition files should have tests included. In the YAML file, tests are just a block of Ruby code:
332
-
333
- ```
334
- tests: |
335
- {Date.civil(2008,1,1) => 'New Year\'s Day',
336
- Date.civil(2008,3,21) => 'Good Friday',
337
- Date.civil(2008,3,24) => 'Easter Monday',
338
- Date.civil(2008,9,1) => 'Labour Day',
339
- Date.civil(2008,12,25) => 'Christmas Day',
340
- Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
341
- assert_equal name, (Holidays.on(date, :ca, :informal)[0] || {})[:name]
342
- end
343
-
344
- # Victoria Day
345
- [Date.civil(2004,5,24), Date.civil(2005,5,23), Date.civil(2006,5,22),
346
- Date.civil(2007,5,21), Date.civil(2008,5,19)].each do |date|
347
- assert_equal 'Victoria Day', Holidays.on(date, :ca)[0][:name]
348
- end
349
- ```
350
-
351
- These tests will be picked up by the `generate` process and written into actual Test::Unit tests that are run when a user executes the test suite.
352
-
353
- Please please please include tests. Your PR won't be accepted if tests are not included with your changes.