holidays 3.1.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/definitions/dk.yaml +2 -0
- data/definitions/fedex.yaml +1 -1
- data/definitions/jp.yaml +4 -1
- data/definitions/ups.yaml +1 -1
- data/lib/generated_definitions/dk.rb +2 -2
- data/lib/generated_definitions/europe.rb +2 -2
- data/lib/generated_definitions/jp.rb +2 -3
- data/lib/generated_definitions/scandinavia.rb +2 -2
- data/lib/holidays/definition/context/generator.rb +14 -0
- data/lib/holidays/use_case/context/between.rb +23 -2
- data/lib/holidays/version.rb +1 -1
- data/test/data/test_custom_year_range_holiday_defs.yaml +28 -0
- data/test/holidays/definition/context/test_generator.rb +52 -0
- data/test/test_custom_year_range_holidays.rb +43 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 371634066d0abbf2aa11ace0e06461808a38a69a
|
4
|
+
data.tar.gz: 2abd58ba908382b7b3c2a265c41d7a48652332ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03b8ea83d6100f4308ac35dbc01c0eeaefa75dc6263457457fa12e6cd6bf5a3000aedc570bc841d0c4357abffad09e796cd622957dcd5256ae92630f8ebdef0f
|
7
|
+
data.tar.gz: d893607cb825d6f73c020bad7dff40dec30f032fa0e4c6ab9d6524d3e7b9bafd8111f0c397410ab5676e01b0395434db0b12b7f8a1413f6d1b2d45f58e4ba90f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Ruby Holidays Gem CHANGELOG
|
2
2
|
|
3
|
+
## 3.2.0
|
4
|
+
|
5
|
+
* add 'valid year' functionality to definitions - https://github.com/holidays/holidays/issues/33 - (thanks to https://github.com/ttwo32)
|
6
|
+
* Fix 'day after thanksgiving' namespace bug during definition generation (thanks to https://github.com/ttwo32)
|
7
|
+
* fix Danish holidays 'palmesondag and 1/5 (danish fightday)' to set to informal (thanks to https://github.com/bjensen)
|
8
|
+
|
3
9
|
## 3.1.2
|
4
10
|
|
5
11
|
* Do not require Date monkeypatching in definitions to use mday calculations (thanks to https://github.com/CloCkWeRX)
|
data/README.md
CHANGED
data/definitions/dk.yaml
CHANGED
@@ -15,6 +15,7 @@ months:
|
|
15
15
|
- name: Palmesøndag
|
16
16
|
regions: [dk]
|
17
17
|
function: easter(year)-7
|
18
|
+
type: informal
|
18
19
|
- name: Skærtorsdag
|
19
20
|
regions: [dk]
|
20
21
|
function: easter(year)-3
|
@@ -60,6 +61,7 @@ months:
|
|
60
61
|
- name: Arbejdernes kampdag
|
61
62
|
regions: [dk]
|
62
63
|
mday: 1
|
64
|
+
type: informal
|
63
65
|
- name: Danmarks befrielse
|
64
66
|
regions: [dk]
|
65
67
|
mday: 5
|
data/definitions/fedex.yaml
CHANGED
@@ -45,7 +45,7 @@ months:
|
|
45
45
|
methods:
|
46
46
|
day_after_thanksgiving: |
|
47
47
|
def self.day_after_thanksgiving(year)
|
48
|
-
|
48
|
+
Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 11, 4, 4) + 1
|
49
49
|
end
|
50
50
|
tests: |
|
51
51
|
{Date.civil(2015,1,1) => 'New Year\'s Day',
|
data/definitions/jp.yaml
CHANGED
@@ -76,9 +76,13 @@ months:
|
|
76
76
|
8:
|
77
77
|
- name: 山の日
|
78
78
|
regions: [jp]
|
79
|
+
year_ranges:
|
80
|
+
- after: 2016
|
79
81
|
function: jp_mountain_holiday(year)
|
80
82
|
- name: 振替休日
|
81
83
|
regions: [jp]
|
84
|
+
year_ranges:
|
85
|
+
- after: 2016
|
82
86
|
function: jp_substitute_holiday(Holidays.jp_mountain_holiday(year))
|
83
87
|
9:
|
84
88
|
- name: 敬老の日
|
@@ -176,7 +180,6 @@ methods:
|
|
176
180
|
end
|
177
181
|
jp_mountain_holiday: |
|
178
182
|
def self.jp_mountain_holiday(year)
|
179
|
-
return nil if year < 2016
|
180
183
|
Date.civil(year, 8, 11)
|
181
184
|
end
|
182
185
|
jp_substitute_holiday: |
|
data/definitions/ups.yaml
CHANGED
@@ -45,7 +45,7 @@ months:
|
|
45
45
|
methods:
|
46
46
|
day_after_thanksgiving: |
|
47
47
|
def self.day_after_thanksgiving(year)
|
48
|
-
|
48
|
+
Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 11, 4, 4) + 1
|
49
49
|
end
|
50
50
|
tests: |
|
51
51
|
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
@@ -19,7 +19,7 @@ module Holidays
|
|
19
19
|
def self.holidays_by_month
|
20
20
|
{
|
21
21
|
0 => [{:function => lambda { |year| Holidays.easter(year)-49 }, :function_id => "easter(year)-49", :type => :informal, :name => "Fastelavn", :regions => [:dk]},
|
22
|
-
{:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Palmesøndag", :regions => [:dk]},
|
22
|
+
{:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :type => :informal, :name => "Palmesøndag", :regions => [:dk]},
|
23
23
|
{:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skærtorsdag", :regions => [:dk]},
|
24
24
|
{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:dk]},
|
25
25
|
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskedag", :regions => [:dk]},
|
@@ -32,7 +32,7 @@ module Holidays
|
|
32
32
|
4 => [{:mday => 1, :type => :informal, :name => "1. april", :regions => [:dk]},
|
33
33
|
{:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]},
|
34
34
|
{:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]}],
|
35
|
-
5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]},
|
35
|
+
5 => [{:mday => 1, :type => :informal, :name => "Arbejdernes kampdag", :regions => [:dk]},
|
36
36
|
{:mday => 5, :type => :informal, :name => "Danmarks befrielse", :regions => [:dk]}],
|
37
37
|
6 => [{:mday => 5, :type => :informal, :name => "Grundlovsdag", :regions => [:dk]},
|
38
38
|
{:mday => 15, :type => :informal, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]},
|
@@ -36,7 +36,7 @@ module Holidays
|
|
36
36
|
{:function => lambda { |year| Holidays.ch_ge_jeune_genevois(year) }, :function_id => "ch_ge_jeune_genevois(year)", :name => "Jeûne genevois", :regions => [:ch_ge]},
|
37
37
|
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Velikonoční pondělí", :regions => [:cz]},
|
38
38
|
{:function => lambda { |year| Holidays.easter(year)-49 }, :function_id => "easter(year)-49", :type => :informal, :name => "Fastelavn", :regions => [:dk]},
|
39
|
-
{:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Palmesøndag", :regions => [:dk]},
|
39
|
+
{:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :type => :informal, :name => "Palmesøndag", :regions => [:dk]},
|
40
40
|
{:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skærtorsdag", :regions => [:dk]},
|
41
41
|
{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:dk]},
|
42
42
|
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskedag", :regions => [:dk]},
|
@@ -190,7 +190,7 @@ module Holidays
|
|
190
190
|
{:mday => 1, :name => "Tag der Arbeit", :regions => [:ch_zh, :ch_bs, :ch_bl, :ch_sh, :ch_ag, :ch_tg, :ch_ti, :ch_ne, :ch_ju]},
|
191
191
|
{:mday => 1, :name => "Svátek práce", :regions => [:cz]},
|
192
192
|
{:mday => 8, :name => "Den vítězství", :regions => [:cz]},
|
193
|
-
{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]},
|
193
|
+
{:mday => 1, :type => :informal, :name => "Arbejdernes kampdag", :regions => [:dk]},
|
194
194
|
{:mday => 5, :type => :informal, :name => "Danmarks befrielse", :regions => [:dk]},
|
195
195
|
{:mday => 1, :name => "Tag der Arbeit", :regions => [:de]},
|
196
196
|
{:mday => 1, :name => "Πρωτομαγιά", :regions => [:el]},
|
@@ -35,8 +35,8 @@ module Holidays
|
|
35
35
|
{:function => lambda { |year| Holidays.jp_substitute_holiday(year, 5, 5) }, :function_id => "jp_substitute_holiday(year, 5, 5)", :name => "振替休日", :regions => [:jp]}],
|
36
36
|
7 => [{:wday => 1, :week => 3, :name => "海の日", :regions => [:jp]},
|
37
37
|
{:function => lambda { |year| Holidays.jp_substitute_holiday(year, 7, Holidays.calculate_day_of_month(year, 7, 3, 1)) }, :function_id => "jp_substitute_holiday(year, 7, Holidays.calculate_day_of_month(year, 7, 3, 1))", :name => "振替休日", :regions => [:jp]}],
|
38
|
-
8 => [{:function => lambda { |year| Holidays.jp_mountain_holiday(year) }, :function_id => "jp_mountain_holiday(year)", :name => "山の日", :regions => [:jp]},
|
39
|
-
{:function => lambda { |year| Holidays.jp_substitute_holiday(Holidays.jp_mountain_holiday(year)) }, :function_id => "jp_substitute_holiday(Holidays.jp_mountain_holiday(year))", :name => "振替休日", :regions => [:jp]}],
|
38
|
+
8 => [{:function => lambda { |year| Holidays.jp_mountain_holiday(year) }, :function_id => "jp_mountain_holiday(year)", :year_ranges => [{:after => 2016}],:name => "山の日", :regions => [:jp]},
|
39
|
+
{:function => lambda { |year| Holidays.jp_substitute_holiday(Holidays.jp_mountain_holiday(year)) }, :function_id => "jp_substitute_holiday(Holidays.jp_mountain_holiday(year))", :year_ranges => [{:after => 2016}],:name => "振替休日", :regions => [:jp]}],
|
40
40
|
9 => [{:wday => 1, :week => 3, :name => "敬老の日", :regions => [:jp]},
|
41
41
|
{:function => lambda { |year| Holidays.jp_substitute_holiday(year, 9, Holidays.calculate_day_of_month(year, 9, 3, 1)) }, :function_id => "jp_substitute_holiday(year, 9, Holidays.calculate_day_of_month(year, 9, 3, 1))", :name => "振替休日", :regions => [:jp]},
|
42
42
|
{:function => lambda { |year| Holidays.jp_citizons_holiday(year) }, :function_id => "jp_citizons_holiday(year)", :name => "国民の休日", :regions => [:jp]},
|
@@ -106,7 +106,6 @@ end
|
|
106
106
|
|
107
107
|
|
108
108
|
def self.jp_mountain_holiday(year)
|
109
|
-
return nil if year < 2016
|
110
109
|
Date.civil(year, 8, 11)
|
111
110
|
end
|
112
111
|
|
@@ -19,7 +19,7 @@ module Holidays
|
|
19
19
|
def self.holidays_by_month
|
20
20
|
{
|
21
21
|
0 => [{:function => lambda { |year| Holidays.easter(year)-49 }, :function_id => "easter(year)-49", :type => :informal, :name => "Fastelavn", :regions => [:dk]},
|
22
|
-
{:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Palmesøndag", :regions => [:dk]},
|
22
|
+
{:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :type => :informal, :name => "Palmesøndag", :regions => [:dk]},
|
23
23
|
{:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skærtorsdag", :regions => [:dk]},
|
24
24
|
{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:dk]},
|
25
25
|
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskedag", :regions => [:dk]},
|
@@ -74,7 +74,7 @@ module Holidays
|
|
74
74
|
{:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]},
|
75
75
|
{:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]},
|
76
76
|
{:function => lambda { |year| Holidays.is_sumardagurinn_fyrsti(year) }, :function_id => "is_sumardagurinn_fyrsti(year)", :name => "Sumardagurinn fyrsti", :regions => [:is]}],
|
77
|
-
5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]},
|
77
|
+
5 => [{:mday => 1, :type => :informal, :name => "Arbejdernes kampdag", :regions => [:dk]},
|
78
78
|
{:mday => 5, :type => :informal, :name => "Danmarks befrielse", :regions => [:dk]},
|
79
79
|
{:mday => 1, :name => "Verkalýðsdagurinn", :regions => [:is]},
|
80
80
|
{:mday => 13, :name => "Mæðradagurinn", :regions => [:is]},
|
@@ -130,6 +130,20 @@ module Holidays
|
|
130
130
|
string << ":wday => #{rule[:wday]}, :week => #{rule[:week]}, "
|
131
131
|
end
|
132
132
|
|
133
|
+
if rule[:year_ranges] && rule[:year_ranges].kind_of?(Array)
|
134
|
+
year_string = " :year_ranges => ["
|
135
|
+
len = rule[:year_ranges].length
|
136
|
+
rule[:year_ranges].each_with_index do |year,index|
|
137
|
+
year_string << "{:#{year.keys.first} => #{year.values.first}}"
|
138
|
+
if len == index + 1
|
139
|
+
year_string << "],"
|
140
|
+
else
|
141
|
+
year_string << ","
|
142
|
+
end
|
143
|
+
end
|
144
|
+
string << year_string
|
145
|
+
end
|
146
|
+
|
133
147
|
if rule[:observed]
|
134
148
|
string << ":observed => lambda { |date| Holidays.#{rule[:observed]}(date) }, "
|
135
149
|
string << ":observed_id => \"#{rule[:observed].to_s}\", "
|
@@ -16,17 +16,38 @@ module Holidays
|
|
16
16
|
dates_driver.each do |year, months|
|
17
17
|
months.each do |month|
|
18
18
|
next unless hbm = holidays_by_month_repo.find_by_month(month)
|
19
|
-
|
20
19
|
hbm.each do |h|
|
21
20
|
next unless in_region?(regions, h[:regions])
|
22
21
|
|
23
22
|
# Skip informal holidays unless they have been requested
|
24
23
|
next if h[:type] == :informal and not informal
|
25
24
|
|
25
|
+
# range check feature.
|
26
|
+
if h[:year_ranges]
|
27
|
+
valid_range_year = false
|
28
|
+
h[:year_ranges].each do |year_range|
|
29
|
+
next unless year_range.is_a?(Hash) && year_range.length == 1
|
30
|
+
next unless year_range.select{
|
31
|
+
|operator,year|[:before,"before",:after,"after",:limited,"limited",:between,"between"].include?(operator)}.count > 0
|
32
|
+
case year_range.keys.first
|
33
|
+
when :before,"before"
|
34
|
+
valid_range_year = true if year <= year_range[year_range.keys.first]
|
35
|
+
when :after,"after"
|
36
|
+
valid_range_year = true if year >= year_range[year_range.keys.first]
|
37
|
+
when :limited,"limited"
|
38
|
+
valid_range_year = true if year_range[year_range.keys.first].include?(year)
|
39
|
+
when :between,"between"
|
40
|
+
year_range[year_range.keys.first] = Range.new(*year_range[year_range.keys.first].split("..").map(&:to_i)) if year_range[year_range.keys.first].is_a?(String)
|
41
|
+
valid_range_year = true if year_range[year_range.keys.first].cover?(year)
|
42
|
+
end
|
43
|
+
break if valid_range_year
|
44
|
+
end
|
45
|
+
next unless valid_range_year
|
46
|
+
end
|
47
|
+
|
26
48
|
if h[:function]
|
27
49
|
# Holiday definition requires a calculation
|
28
50
|
result = call_proc(h[:function], year)
|
29
|
-
|
30
51
|
# Procs may return either Date or an integer representing mday
|
31
52
|
if result.kind_of?(Date)
|
32
53
|
month = result.month
|
data/lib/holidays/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
months:
|
2
|
+
6:
|
3
|
+
- name: after_year
|
4
|
+
regions: [custom_year_range_file]
|
5
|
+
mday: 1
|
6
|
+
year_ranges:
|
7
|
+
- after: 2016
|
8
|
+
- name: before_year
|
9
|
+
regions: [custom_year_range_file]
|
10
|
+
mday: 2
|
11
|
+
year_ranges:
|
12
|
+
- before: 2017
|
13
|
+
- name: between_year
|
14
|
+
regions: [custom_year_range_file]
|
15
|
+
mday: 3
|
16
|
+
year_ranges:
|
17
|
+
- between: 2016..2018
|
18
|
+
- name: limited_year
|
19
|
+
regions: [custom_year_range_file]
|
20
|
+
mday: 4
|
21
|
+
year_ranges:
|
22
|
+
- limited: [2016,2018,2019]
|
23
|
+
- name: multiple_conditions
|
24
|
+
regions: [custom_year_range_file]
|
25
|
+
mday: 5
|
26
|
+
year_ranges:
|
27
|
+
- before: 2015
|
28
|
+
- after: 2017
|
@@ -81,4 +81,56 @@ class GeneratorTests < Test::Unit::TestCase
|
|
81
81
|
|
82
82
|
assert_equal expected_test_src, test_src
|
83
83
|
end
|
84
|
+
|
85
|
+
def test_parse_definitions_files_correctly_parse_year_range_by_month
|
86
|
+
files = ['test/data/test_custom_year_range_holiday_defs.yaml']
|
87
|
+
regions, rules_by_month, custom_methods, tests = @generator.parse_definition_files(files)
|
88
|
+
|
89
|
+
expected_rules_by_month = {
|
90
|
+
6 => [
|
91
|
+
{
|
92
|
+
:name => "after_year",
|
93
|
+
:regions => [:custom_year_range_file],
|
94
|
+
:mday => 1,
|
95
|
+
:year_ranges => [{"after" => 2016}]
|
96
|
+
},
|
97
|
+
{
|
98
|
+
:name => "before_year",
|
99
|
+
:regions => [:custom_year_range_file],
|
100
|
+
:mday => 2,
|
101
|
+
:year_ranges => [{"before" => 2017}]
|
102
|
+
},
|
103
|
+
{
|
104
|
+
:name => "between_year",
|
105
|
+
:regions => [:custom_year_range_file],
|
106
|
+
:mday => 3,
|
107
|
+
:year_ranges => [{"between" => "2016..2018"}]
|
108
|
+
},
|
109
|
+
{
|
110
|
+
:name => "limited_year",
|
111
|
+
:regions => [:custom_year_range_file],
|
112
|
+
:mday => 4,
|
113
|
+
:year_ranges => [{"limited" => [2016,2018,2019]}]
|
114
|
+
},
|
115
|
+
{
|
116
|
+
:name => "multiple_conditions",
|
117
|
+
:regions => [:custom_year_range_file],
|
118
|
+
:mday => 5,
|
119
|
+
:year_ranges => [{"before" => 2015}, {"after" => 2017}]
|
120
|
+
}
|
121
|
+
]
|
122
|
+
}
|
123
|
+
|
124
|
+
assert_equal expected_rules_by_month, rules_by_month
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_generate_definition_source_correctly_genrate_yearrange_test_src
|
128
|
+
files = ['test/data/test_custom_year_range_holiday_defs.yaml']
|
129
|
+
regions, rules_by_month, custom_methods, tests = @generator.parse_definition_files(files)
|
130
|
+
module_src, test_src = @generator.generate_definition_source("test", files, regions, rules_by_month, custom_methods, tests)
|
131
|
+
expected_module_src = "# encoding: utf-8\nmodule Holidays\n # This file is generated by the Ruby Holidays gem.\n #\n # Definitions loaded: test/data/test_custom_year_range_holiday_defs.yaml\n #\n # To use the definitions in this file, load it right after you load the\n # Holiday gem:\n #\n # require 'holidays'\n # require 'generated_definitions/test'\n #\n # All the definitions are available at https://github.com/alexdunae/holidays\n module TEST # :nodoc:\n def self.defined_regions\n [:custom_year_range_file]\n end\n\n def self.holidays_by_month\n {\n 6 => [{:mday => 1, :year_ranges => [{:after => 2016}],:name => \"after_year\", :regions => [:custom_year_range_file]},\n {:mday => 2, :year_ranges => [{:before => 2017}],:name => \"before_year\", :regions => [:custom_year_range_file]},\n {:mday => 3, :year_ranges => [{:between => 2016..2018}],:name => \"between_year\", :regions => [:custom_year_range_file]},\n {:mday => 4, :year_ranges => [{:limited => [2016, 2018, 2019]}],:name => \"limited_year\", :regions => [:custom_year_range_file]},\n {:mday => 5, :year_ranges => [{:before => 2015},{:after => 2017}],:name => \"multiple_conditions\", :regions => [:custom_year_range_file]}]\n }\n end\n end\n\n\nend\n\nHolidays.merge_defs(Holidays::TEST.defined_regions, Holidays::TEST.holidays_by_month)\n"
|
132
|
+
|
133
|
+
assert_equal expected_module_src, module_src
|
134
|
+
end
|
135
|
+
|
84
136
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__)) + '/test_helper'
|
2
|
+
|
3
|
+
class CustomYearRangeHolidaysTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_after_year_feature
|
6
|
+
Holidays.load_custom('test/data/test_custom_year_range_holiday_defs.yaml')
|
7
|
+
assert_equal [], Holidays.on(Date.civil(2015,6,1), :custom_year_range_file)
|
8
|
+
assert_not_equal [], Holidays.on(Date.civil(2016,6,1), :custom_year_range_file)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_before_year_feature
|
12
|
+
Holidays.load_custom('test/data/test_custom_year_range_holiday_defs.yaml')
|
13
|
+
assert_not_equal [], Holidays.on(Date.civil(2017,6,2), :custom_year_range_file)
|
14
|
+
assert_equal [], Holidays.on(Date.civil(2018,6,2), :custom_year_range_file)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_between_year_feature
|
18
|
+
Holidays.load_custom('test/data/test_custom_year_range_holiday_defs.yaml')
|
19
|
+
assert_equal [], Holidays.on(Date.civil(2015,6,3), :custom_year_range_file)
|
20
|
+
assert_not_equal [], Holidays.on(Date.civil(2016,6,3), :custom_year_range_file)
|
21
|
+
assert_not_equal [], Holidays.on(Date.civil(2017,6,3), :custom_year_range_file)
|
22
|
+
assert_not_equal [], Holidays.on(Date.civil(2018,6,3), :custom_year_range_file)
|
23
|
+
assert_equal [], Holidays.on(Date.civil(2019,6,3), :custom_year_range_file)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_limited_year_feature
|
27
|
+
Holidays.load_custom('test/data/test_custom_year_range_holiday_defs.yaml')
|
28
|
+
assert_equal [], Holidays.on(Date.civil(2015,6,4), :custom_year_range_file)
|
29
|
+
assert_not_equal [], Holidays.on(Date.civil(2016,6,4), :custom_year_range_file)
|
30
|
+
assert_equal [], Holidays.on(Date.civil(2017,6,4), :custom_year_range_file)
|
31
|
+
assert_not_equal [], Holidays.on(Date.civil(2018,6,4), :custom_year_range_file)
|
32
|
+
assert_not_equal [], Holidays.on(Date.civil(2019,6,4), :custom_year_range_file)
|
33
|
+
assert_equal [], Holidays.on(Date.civil(2020,6,4), :custom_year_range_file)
|
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
|
+
|
43
|
+
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: 3.
|
4
|
+
version: 3.2.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: 2016-
|
12
|
+
date: 2016-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- lib/holidays/use_case_factory.rb
|
229
229
|
- lib/holidays/version.rb
|
230
230
|
- test/data/test_custom_govt_holiday_defs.yaml
|
231
|
+
- test/data/test_custom_year_range_holiday_defs.yaml
|
231
232
|
- test/data/test_multiple_custom_holiday_defs.yaml
|
232
233
|
- test/data/test_single_custom_holiday_defs.yaml
|
233
234
|
- test/defs/test_defs_ar.rb
|
@@ -304,6 +305,7 @@ files:
|
|
304
305
|
- test/holidays/use_case/context/test_dates_driver_builder.rb
|
305
306
|
- test/test_all_regions.rb
|
306
307
|
- test/test_custom_holidays.rb
|
308
|
+
- test/test_custom_year_range_holidays.rb
|
307
309
|
- test/test_helper.rb
|
308
310
|
- test/test_holidays.rb
|
309
311
|
- test/test_holidays_between.rb
|
@@ -335,6 +337,7 @@ specification_version: 4
|
|
335
337
|
summary: A collection of Ruby methods to deal with statutory and other holidays.
|
336
338
|
test_files:
|
337
339
|
- test/data/test_custom_govt_holiday_defs.yaml
|
340
|
+
- test/data/test_custom_year_range_holiday_defs.yaml
|
338
341
|
- test/data/test_multiple_custom_holiday_defs.yaml
|
339
342
|
- test/data/test_single_custom_holiday_defs.yaml
|
340
343
|
- test/defs/test_defs_ar.rb
|
@@ -411,6 +414,7 @@ test_files:
|
|
411
414
|
- test/holidays/use_case/context/test_dates_driver_builder.rb
|
412
415
|
- test/test_all_regions.rb
|
413
416
|
- test/test_custom_holidays.rb
|
417
|
+
- test/test_custom_year_range_holidays.rb
|
414
418
|
- test/test_helper.rb
|
415
419
|
- test/test_holidays.rb
|
416
420
|
- test/test_holidays_between.rb
|