holidays 7.1.0 → 8.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -1
  3. data/README.md +3 -4
  4. data/doc/CONTRIBUTING.md +2 -1
  5. data/holidays.gemspec +5 -5
  6. data/lib/generated_definitions/MANIFEST +3 -0
  7. data/lib/generated_definitions/REGIONS.rb +2 -2
  8. data/lib/generated_definitions/au.rb +8 -2
  9. data/lib/generated_definitions/ca.rb +14 -13
  10. data/lib/generated_definitions/ch.rb +13 -1
  11. data/lib/generated_definitions/cl.rb +5 -5
  12. data/lib/generated_definitions/de.rb +5 -4
  13. data/lib/generated_definitions/es.rb +4 -2
  14. data/lib/generated_definitions/europe.rb +83 -23
  15. data/lib/generated_definitions/gb.rb +6 -4
  16. data/lib/generated_definitions/hr.rb +8 -6
  17. data/lib/generated_definitions/hu.rb +3 -2
  18. data/lib/generated_definitions/it.rb +14 -5
  19. data/lib/generated_definitions/jp.rb +26 -21
  20. data/lib/generated_definitions/kz.rb +38 -0
  21. data/lib/generated_definitions/lu.rb +2 -0
  22. data/lib/generated_definitions/lv.rb +52 -0
  23. data/lib/generated_definitions/mx.rb +3 -3
  24. data/lib/generated_definitions/ng.rb +33 -0
  25. data/lib/generated_definitions/northamerica.rb +21 -21
  26. data/lib/generated_definitions/ro.rb +5 -2
  27. data/lib/generated_definitions/southamerica.rb +5 -5
  28. data/lib/generated_definitions/tr.rb +5 -3
  29. data/lib/generated_definitions/ua.rb +6 -6
  30. data/lib/generated_definitions/us.rb +5 -6
  31. data/lib/holidays.rb +2 -0
  32. data/lib/holidays/definition/context/generator.rb +20 -34
  33. data/lib/holidays/definition/repository/holidays_by_month.rb +9 -1
  34. data/lib/holidays/finder/context/search.rb +34 -31
  35. data/lib/holidays/finder/rules/year_range.rb +30 -54
  36. data/lib/holidays/version.rb +1 -1
  37. data/test/coverage_report.rb +23 -5
  38. data/test/data/test_custom_year_range_holiday_defs.yaml +6 -10
  39. data/test/data/test_multiple_regions_with_conflicts_region_1.yaml +38 -0
  40. data/test/data/test_multiple_regions_with_conflicts_region_2.yaml +38 -0
  41. data/test/defs/test_defs_ca.rb +27 -5
  42. data/test/defs/test_defs_ch.rb +4 -0
  43. data/test/defs/test_defs_co.rb +3 -3
  44. data/test/defs/test_defs_de.rb +2 -0
  45. data/test/defs/test_defs_es.rb +2 -0
  46. data/test/defs/test_defs_europe.rb +156 -11
  47. data/test/defs/test_defs_federalreservebanks.rb +20 -0
  48. data/test/defs/test_defs_gb.rb +16 -0
  49. data/test/defs/test_defs_hr.rb +6 -6
  50. data/test/defs/test_defs_hu.rb +12 -4
  51. data/test/defs/test_defs_it.rb +20 -0
  52. data/test/defs/test_defs_jp.rb +5 -3
  53. data/test/defs/test_defs_kz.rb +39 -0
  54. data/test/defs/test_defs_lu.rb +6 -0
  55. data/test/defs/test_defs_lv.rb +90 -0
  56. data/test/defs/test_defs_ng.rb +29 -0
  57. data/test/defs/test_defs_northamerica.rb +33 -15
  58. data/test/defs/test_defs_ro.rb +14 -0
  59. data/test/defs/test_defs_southamerica.rb +3 -3
  60. data/test/defs/test_defs_tr.rb +7 -0
  61. data/test/defs/test_defs_us.rb +6 -10
  62. data/test/holidays/core_extensions/test_date.rb +3 -2
  63. data/test/holidays/definition/context/test_generator.rb +5 -18
  64. data/test/holidays/definition/repository/test_holidays_by_month.rb +121 -1
  65. data/test/holidays/finder/rules/test_year_range.rb +43 -47
  66. data/test/integration/test_available_regions.rb +1 -1
  67. data/test/integration/test_custom_year_range_holidays.rb +0 -7
  68. data/test/integration/test_holidays.rb +1 -23
  69. data/test/integration/test_holidays_between.rb +10 -0
  70. data/test/integration/test_multiple_regions_with_conflict.rb +29 -0
  71. metadata +28 -14
@@ -18,6 +18,6 @@ class AvailableRegionsTests < Test::Unit::TestCase
18
18
  # This test might fail if we add new regions. Since this is an integration test
19
19
  # I am fine with that!
20
20
  def test_available_regions_returns_correct_number_of_regions
21
- assert_equal 244, Holidays.available_regions.count
21
+ assert_equal 258, Holidays.available_regions.count
22
22
  end
23
23
  end
@@ -32,11 +32,4 @@ class CustomYearRangeHolidaysTest < Test::Unit::TestCase
32
32
  assert_not_equal [], Holidays.on(Date.civil(2019,6,4), :custom_year_range_file)
33
33
  assert_equal [], Holidays.on(Date.civil(2020,6,4), :custom_year_range_file)
34
34
  end
35
-
36
- def test_multiple_condition
37
- Holidays.load_custom('test/data/test_custom_year_range_holiday_defs.yaml')
38
- assert_not_equal [], Holidays.on(Date.civil(2015,6,5), :custom_year_range_file)
39
- assert_equal [], Holidays.on(Date.civil(2016,6,5), :custom_year_range_file)
40
- assert_not_equal [], Holidays.on(Date.civil(2017,6,5), :custom_year_range_file)
41
- end
42
35
  end
@@ -142,28 +142,6 @@ class HolidaysTests < Test::Unit::TestCase
142
142
  assert_empty holidays
143
143
  end
144
144
 
145
- def test_year_holidays_feb_29_on_non_leap_year
146
- assert_raises ArgumentError do
147
- Holidays.year_holidays([:ca_on], Date.civil(2015, 2, 29))
148
- end
149
-
150
- assert_raises ArgumentError do
151
- Holidays.year_holidays([:ca_on], Date.civil(2019, 2, 29))
152
- end
153
-
154
- assert_raises ArgumentError do
155
- Holidays.year_holidays([:ca_on], Date.civil(2021, 2, 29))
156
- end
157
-
158
- assert_raises ArgumentError do
159
- Holidays.year_holidays([:us], Date.civil(2023, 2, 29))
160
- end
161
-
162
- assert_raises ArgumentError do
163
- Holidays.year_holidays([:ca_on], Date.civil(2025, 2, 29))
164
- end
165
- end
166
-
167
145
  def test_year_holidays_random_years
168
146
  # Should be 1 less holiday, as Family day didn't exist in Ontario in 1990
169
147
  holidays = Holidays.year_holidays([:ca_on], Date.civil(1990, 1, 1))
@@ -266,6 +244,6 @@ class HolidaysTests < Test::Unit::TestCase
266
244
 
267
245
  def test_load_all
268
246
  Holidays.load_all
269
- assert_equal 244, Holidays.available_regions.count
247
+ assert_equal 258, Holidays.available_regions.count
270
248
  end
271
249
  end
@@ -41,6 +41,16 @@ class HolidaysBetweenTests < Test::Unit::TestCase
41
41
  end
42
42
  end
43
43
 
44
+ def test_between_raises_error_if_end_date_is_before_start_date
45
+ assert_raise ArgumentError do
46
+ @subject.call(Date.civil(2019, 2, 1), Date.civil(2019, 1, 1), :us)
47
+ end
48
+
49
+ assert_raise ArgumentError do
50
+ @subject.call(Date.civil(2008,7,2), Date.civil(2000,7,2), :ca)
51
+ end
52
+ end
53
+
44
54
  def test_cached_holidays_are_returned_if_present
45
55
  start_date = Date.civil(2015, 1, 1)
46
56
  end_date = Date.civil(2015, 1, 31)
@@ -0,0 +1,29 @@
1
+ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
2
+
3
+ # See https://github.com/holidays/holidays/issues/344 for more info on why
4
+ # these tests exist.
5
+ class MultipleRegionsWithConflictsTests < Test::Unit::TestCase
6
+
7
+ def test_corpus_christi_returns_correctly_for_co_even_if_br_is_loaded_first
8
+ result = Holidays.on(Date.new(2014, 6, 19), :br)
9
+ assert_equal 1, result.count
10
+ assert_equal 'Corpus Christi', result.first[:name]
11
+
12
+ result = Holidays.on(Date.new(2014, 6, 23), :co)
13
+ assert_equal 1, result.count
14
+ assert_equal 'Corpus Christi', result.first[:name]
15
+ end
16
+
17
+ def test_custom_loaded_region_returns_correct_value_with_function_modifier_conflict_even_if_conflict_definition_is_loaded_first
18
+ Holidays.load_custom('test/data/test_multiple_regions_with_conflicts_region_1.yaml')
19
+ result = Holidays.on(Date.new(2019, 6, 20), :multiple_with_conflict_1)
20
+ assert_equal 1, result.count
21
+ assert_equal 'With Function Modifier', result.first[:name]
22
+
23
+ Holidays.load_custom('test/data/test_multiple_regions_with_conflicts_region_2.yaml')
24
+ result = Holidays.on(Date.new(2019, 6, 24), :multiple_with_conflict_2)
25
+ assert_equal 1, result.count
26
+ assert_equal 'With Function Modifier', result.first[:name]
27
+ end
28
+
29
+ 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: 7.1.0
4
+ version: 8.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dunae
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-02-03 00:00:00.000000000 Z
12
+ date: 2020-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.16'
20
+ version: '2'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.16'
27
+ version: '2'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -59,42 +59,42 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '3.2'
62
+ version: '3'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '3.2'
69
+ version: '3'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: mocha
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '1.7'
76
+ version: '1'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '1.7'
83
+ version: '1'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: pry
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '0.11'
90
+ version: '0.12'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '0.11'
97
+ version: '0.12'
98
98
  description: A collection of Ruby methods to deal with statutory and other holidays.
99
99
  You deserve a holiday!
100
100
  email:
@@ -155,15 +155,18 @@ files:
155
155
  - lib/generated_definitions/it.rb
156
156
  - lib/generated_definitions/jp.rb
157
157
  - lib/generated_definitions/kr.rb
158
+ - lib/generated_definitions/kz.rb
158
159
  - lib/generated_definitions/li.rb
159
160
  - lib/generated_definitions/lt.rb
160
161
  - lib/generated_definitions/lu.rb
162
+ - lib/generated_definitions/lv.rb
161
163
  - lib/generated_definitions/ma.rb
162
164
  - lib/generated_definitions/mt_en.rb
163
165
  - lib/generated_definitions/mt_mt.rb
164
166
  - lib/generated_definitions/mx.rb
165
167
  - lib/generated_definitions/my.rb
166
168
  - lib/generated_definitions/nerc.rb
169
+ - lib/generated_definitions/ng.rb
167
170
  - lib/generated_definitions/nl.rb
168
171
  - lib/generated_definitions/no.rb
169
172
  - lib/generated_definitions/northamerica.rb
@@ -242,6 +245,8 @@ files:
242
245
  - test/data/test_custom_year_range_holiday_defs.yaml
243
246
  - test/data/test_invalid_region.rb
244
247
  - test/data/test_multiple_custom_holiday_defs.yaml
248
+ - test/data/test_multiple_regions_with_conflicts_region_1.yaml
249
+ - test/data/test_multiple_regions_with_conflicts_region_2.yaml
245
250
  - test/data/test_region.rb
246
251
  - test/data/test_single_custom_holiday_defs.yaml
247
252
  - test/data/test_single_custom_holiday_with_custom_procs.yaml
@@ -281,15 +286,18 @@ files:
281
286
  - test/defs/test_defs_it.rb
282
287
  - test/defs/test_defs_jp.rb
283
288
  - test/defs/test_defs_kr.rb
289
+ - test/defs/test_defs_kz.rb
284
290
  - test/defs/test_defs_li.rb
285
291
  - test/defs/test_defs_lt.rb
286
292
  - test/defs/test_defs_lu.rb
293
+ - test/defs/test_defs_lv.rb
287
294
  - test/defs/test_defs_ma.rb
288
295
  - test/defs/test_defs_mt_en.rb
289
296
  - test/defs/test_defs_mt_mt.rb
290
297
  - test/defs/test_defs_mx.rb
291
298
  - test/defs/test_defs_my.rb
292
299
  - test/defs/test_defs_nerc.rb
300
+ - test/defs/test_defs_ng.rb
293
301
  - test/defs/test_defs_nl.rb
294
302
  - test/defs/test_defs_no.rb
295
303
  - test/defs/test_defs_northamerica.rb
@@ -364,6 +372,7 @@ files:
364
372
  - test/integration/test_holidays.rb
365
373
  - test/integration/test_holidays_between.rb
366
374
  - test/integration/test_multiple_regions.rb
375
+ - test/integration/test_multiple_regions_with_conflict.rb
367
376
  - test/integration/test_nonstandard_regions.rb
368
377
  - test/test_helper.rb
369
378
  homepage: https://github.com/holidays/holidays
@@ -376,17 +385,16 @@ require_paths:
376
385
  - lib
377
386
  required_ruby_version: !ruby/object:Gem::Requirement
378
387
  requirements:
379
- - - "~>"
388
+ - - ">="
380
389
  - !ruby/object:Gem::Version
381
- version: '2.2'
390
+ version: '2.4'
382
391
  required_rubygems_version: !ruby/object:Gem::Requirement
383
392
  requirements:
384
393
  - - ">="
385
394
  - !ruby/object:Gem::Version
386
395
  version: '0'
387
396
  requirements: []
388
- rubyforge_project:
389
- rubygems_version: 2.7.6
397
+ rubygems_version: 3.1.2
390
398
  signing_key:
391
399
  specification_version: 4
392
400
  summary: A collection of Ruby methods to deal with statutory and other holidays.
@@ -397,6 +405,8 @@ test_files:
397
405
  - test/data/test_custom_year_range_holiday_defs.yaml
398
406
  - test/data/test_invalid_region.rb
399
407
  - test/data/test_multiple_custom_holiday_defs.yaml
408
+ - test/data/test_multiple_regions_with_conflicts_region_1.yaml
409
+ - test/data/test_multiple_regions_with_conflicts_region_2.yaml
400
410
  - test/data/test_region.rb
401
411
  - test/data/test_single_custom_holiday_defs.yaml
402
412
  - test/data/test_single_custom_holiday_with_custom_procs.yaml
@@ -436,15 +446,18 @@ test_files:
436
446
  - test/defs/test_defs_it.rb
437
447
  - test/defs/test_defs_jp.rb
438
448
  - test/defs/test_defs_kr.rb
449
+ - test/defs/test_defs_kz.rb
439
450
  - test/defs/test_defs_li.rb
440
451
  - test/defs/test_defs_lt.rb
441
452
  - test/defs/test_defs_lu.rb
453
+ - test/defs/test_defs_lv.rb
442
454
  - test/defs/test_defs_ma.rb
443
455
  - test/defs/test_defs_mt_en.rb
444
456
  - test/defs/test_defs_mt_mt.rb
445
457
  - test/defs/test_defs_mx.rb
446
458
  - test/defs/test_defs_my.rb
447
459
  - test/defs/test_defs_nerc.rb
460
+ - test/defs/test_defs_ng.rb
448
461
  - test/defs/test_defs_nl.rb
449
462
  - test/defs/test_defs_no.rb
450
463
  - test/defs/test_defs_northamerica.rb
@@ -519,5 +532,6 @@ test_files:
519
532
  - test/integration/test_holidays.rb
520
533
  - test/integration/test_holidays_between.rb
521
534
  - test/integration/test_multiple_regions.rb
535
+ - test/integration/test_multiple_regions_with_conflict.rb
522
536
  - test/integration/test_nonstandard_regions.rb
523
537
  - test/test_helper.rb