us_bank_holidays 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -3
- data/README.md +2 -2
- data/lib/us_bank_holidays/holiday_year.rb +23 -17
- data/lib/us_bank_holidays/version.rb +1 -1
- data/spec/functional/holiday_year_spec.rb +87 -34
- data/spec/functional/month_spec.rb +1 -1
- data/spec/functional/us_bank_holidays_spec.rb +1 -1
- data/us_bank_holidays.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1f9ef1ece79b15a1e2431e7627d0bc36914e86fb0e76b39310551d4198c728d0
|
4
|
+
data.tar.gz: c27c824131609ffcb000915313d80778322f88ffbaef9ab52c8a8c0137db55fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd9bc1def99590c5e5b706f2e0ccdc60c3e346b7c8f6e0d8900dd34462ff1e28dc1a362f13f33e8a911d8d8111a8f02b44fcbb7b14ff254a764b5349174571fc
|
7
|
+
data.tar.gz: d8324975d14a8ca035620bb572dfce8ac159ab18edc5d3540a91553ad48815acbd561313768405da41abd03379df06c32a8f585dcb942e35adb21483de13cee5
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -9,6 +9,7 @@ module UsBankHolidays
|
|
9
9
|
:mlk_day,
|
10
10
|
:washingtons_birthday,
|
11
11
|
:memorial_day,
|
12
|
+
:juneteenth,
|
12
13
|
:independence_day,
|
13
14
|
:labor_day,
|
14
15
|
:columbus_day,
|
@@ -29,22 +30,24 @@ module UsBankHolidays
|
|
29
30
|
# be observed.
|
30
31
|
def bank_holidays
|
31
32
|
@bank_holidays ||= begin
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
33
|
+
holidays = [
|
34
|
+
new_years_day,
|
35
|
+
mlk_day,
|
36
|
+
washingtons_birthday,
|
37
|
+
memorial_day,
|
38
|
+
juneteenth,
|
39
|
+
independence_day,
|
40
|
+
labor_day,
|
41
|
+
columbus_day,
|
42
|
+
veterans_day,
|
43
|
+
thanksgiving,
|
44
|
+
christmas
|
45
|
+
].compact
|
46
|
+
if Date.new(year + 1, 1, 1).saturday?
|
47
|
+
holidays << Date.new(year, 12, 31)
|
48
|
+
end
|
49
|
+
holidays.freeze
|
50
|
+
end
|
48
51
|
end
|
49
52
|
|
50
53
|
{
|
@@ -96,7 +99,10 @@ module UsBankHolidays
|
|
96
99
|
# First of the year, rolls either forward or back.
|
97
100
|
@new_years_day = roll_nominal(Date.new(year, 1, 1))
|
98
101
|
|
99
|
-
#
|
102
|
+
# 19th of June
|
103
|
+
@juneteenth = (year > 2020 ? roll_nominal(Date.new(year, 6, 19)) : nil )
|
104
|
+
|
105
|
+
# 4th of July
|
100
106
|
@independence_day = roll_nominal(Date.new(year, 7, 4))
|
101
107
|
|
102
108
|
# November 11
|
@@ -1,51 +1,104 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe UsBankHolidays::HolidayYear do
|
3
|
+
RSpec.describe UsBankHolidays::HolidayYear do
|
4
4
|
|
5
5
|
context "should determine bank holidays" do
|
6
6
|
|
7
|
-
context "
|
8
|
-
|
9
|
-
|
7
|
+
context "Before 2021" do
|
8
|
+
|
9
|
+
context "Force Saturday date rolling" do
|
10
|
+
before :each do
|
11
|
+
allow(::UsBankHolidays).to receive(:saturday_holiday_date_rolling?).and_return(true)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should determine bank holidays' do
|
15
|
+
expect(UsBankHolidays::HolidayYear.new(2017).bank_holidays).to eq([
|
16
|
+
'2017-01-02', #New Year’s Day
|
17
|
+
'2017-01-16', #Birthday of Martin Luther King, Jr.
|
18
|
+
'2017-02-20', #Washington’s Birthday
|
19
|
+
'2017-05-29', #Memorial Day
|
20
|
+
'2017-07-04', #Independence Day
|
21
|
+
'2017-09-04', #Labor Day
|
22
|
+
'2017-10-09', #Columbus Day
|
23
|
+
'2017-11-10', #Veterans Day
|
24
|
+
'2017-11-23', #Thanksgiving Day
|
25
|
+
'2017-12-25' #Christmas Day
|
26
|
+
].map { |d| Date.parse(d) }
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
10
30
|
end
|
11
31
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
32
|
+
context "No Saturday date rolling" do
|
33
|
+
it 'should determine bank holidays' do
|
34
|
+
expect(UsBankHolidays::HolidayYear.new(2017).bank_holidays).to eq([
|
35
|
+
'2017-01-02', #New Year’s Day
|
36
|
+
'2017-01-16', #Birthday of Martin Luther King, Jr.
|
37
|
+
'2017-02-20', #Washington’s Birthday
|
38
|
+
'2017-05-29', #Memorial Day
|
39
|
+
'2017-07-04', #Independence Day
|
40
|
+
'2017-09-04', #Labor Day
|
41
|
+
'2017-10-09', #Columbus Day
|
42
|
+
'2017-11-11', #Veterans Day
|
43
|
+
'2017-11-23', #Thanksgiving Day
|
44
|
+
'2017-12-25' #Christmas Day
|
45
|
+
].map { |d| Date.parse(d) }
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
26
49
|
end
|
27
50
|
|
28
51
|
end
|
29
52
|
|
30
|
-
context "
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
53
|
+
context "2021 and later" do
|
54
|
+
|
55
|
+
context "Force Saturday date rolling" do
|
56
|
+
before :each do
|
57
|
+
allow(::UsBankHolidays).to receive(:saturday_holiday_date_rolling?).and_return(true)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should determine bank holidays' do
|
61
|
+
expect(UsBankHolidays::HolidayYear.new(2021).bank_holidays).to eq([
|
62
|
+
'2021-01-01', #New Year’s Day
|
63
|
+
'2021-01-18', #Birthday of Martin Luther King, Jr.
|
64
|
+
'2021-02-15', #Washington’s Birthday
|
65
|
+
'2021-05-31', #Memorial Day
|
66
|
+
'2021-06-18', #Juneteenth
|
67
|
+
'2021-07-05', #Independence Day
|
68
|
+
'2021-09-06', #Labor Day
|
69
|
+
'2021-10-11', #Columbus Day
|
70
|
+
'2021-11-11', #Veterans Day
|
71
|
+
'2021-11-25', #Thanksgiving Day
|
72
|
+
'2021-12-24', #Christmas Day
|
73
|
+
'2021-12-31' #New Year’s Day
|
74
|
+
].map { |d| Date.parse(d) }
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
45
78
|
end
|
46
79
|
|
47
|
-
|
80
|
+
context "No Saturday date rolling" do
|
81
|
+
it 'should determine bank holidays' do
|
82
|
+
expect(UsBankHolidays::HolidayYear.new(2021).bank_holidays).to eq([
|
83
|
+
'2021-01-01', #New Year’s Day
|
84
|
+
'2021-01-18', #Birthday of Martin Luther King, Jr.
|
85
|
+
'2021-02-15', #Washington’s Birthday
|
86
|
+
'2021-05-31', #Memorial Day
|
87
|
+
'2021-06-19', #Juneteenth
|
88
|
+
'2021-07-05', #Independence Day
|
89
|
+
'2021-09-06', #Labor Day
|
90
|
+
'2021-10-11', #Columbus Day
|
91
|
+
'2021-11-11', #Veterans Day
|
92
|
+
'2021-11-25', #Thanksgiving Day
|
93
|
+
'2021-12-25', #Christmas Day
|
94
|
+
'2021-12-31' #New Year’s Day
|
95
|
+
].map { |d| Date.parse(d) }
|
96
|
+
)
|
97
|
+
end
|
48
98
|
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
49
102
|
|
50
103
|
end
|
51
104
|
|
data/us_bank_holidays.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler'
|
21
|
+
spec.add_development_dependency 'bundler'
|
22
22
|
spec.add_development_dependency 'rake'
|
23
23
|
spec.add_development_dependency 'rspec'
|
24
24
|
spec.add_development_dependency 'simplecov'
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: us_bank_holidays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arthur Shagall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.7.8
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Patches Date to add methods to make dealing with US bank holidays simpler.
|