date_holidays-reader 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.nvmrc +1 -0
- data/.rspec +3 -0
- data/.rubocop.yml +27 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Dockerfile +19 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +105 -0
- data/Guardfile +44 -0
- data/LICENSE +17 -0
- data/README.md +176 -0
- data/Rakefile +18 -0
- data/bin/add-copyright-header.pl +16 -0
- data/bin/console +21 -0
- data/bin/date-holidays-version.js +21 -0
- data/bin/holidays-to-json.js +70 -0
- data/bin/setup +17 -0
- data/date-holiday-reader.gemspec +49 -0
- data/lib/date_holidays/reader.rb +26 -0
- data/lib/date_holidays/reader/config.rb +54 -0
- data/lib/date_holidays/reader/holiday.rb +78 -0
- data/lib/date_holidays/reader/js_bridge.rb +75 -0
- data/lib/date_holidays/reader/locale.rb +109 -0
- data/lib/date_holidays/reader/version.rb +67 -0
- data/package.json +12 -0
- data/yarn.lock +1686 -0
- metadata +245 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 68183e8a07810a5f19bd53c39badfa6beb0b542db295e9b60ad161912110bf28
|
4
|
+
data.tar.gz: 537732b57dc72b37ff4393278d12852cf62a81d08f7fe56eae1da3b9612488e2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ae53cfbd8700c0a935e0e97f5eb1c59b014eacb36613f4e720d9946a00f9fa90edb3d13367f11323694ba0e7a3e9cb0bb5d941591c2a3fc674372c4aa0c7f029
|
7
|
+
data.tar.gz: 428ba957ae64044460201fdf21cee1a378dfcf2e8a144d4b850ac0f4360198f482ef4de4068f2a17a441444b8d93cf30c93972760cc8627f9813a067cbed6282
|
data/.gitignore
ADDED
data/.nvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
v10.14.2
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
Exclude:
|
5
|
+
- 'bin/**/*'
|
6
|
+
- Gemfile
|
7
|
+
- 'vendor/**/*'
|
8
|
+
DisplayCopNames: true
|
9
|
+
TargetRubyVersion: 2.3
|
10
|
+
|
11
|
+
Metrics/BlockLength:
|
12
|
+
Enabled: true
|
13
|
+
Exclude:
|
14
|
+
# The outer describe blocks throw this off for Rspec tests so disable.
|
15
|
+
- spec/**/*_spec.rb
|
16
|
+
|
17
|
+
Metrics/LineLength:
|
18
|
+
Max: 100
|
19
|
+
|
20
|
+
Style/TrailingCommaInArguments:
|
21
|
+
EnforcedStyleForMultiline: comma
|
22
|
+
|
23
|
+
Style/TrailingCommaInArrayLiteral:
|
24
|
+
EnforcedStyleForMultiline: comma
|
25
|
+
|
26
|
+
Style/TrailingCommaInHashLiteral:
|
27
|
+
EnforcedStyleForMultiline: comma
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.8
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at oss@bluemarblepayroll.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Dockerfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Build with:
|
2
|
+
# docker build -t date_holidays-reader .
|
3
|
+
FROM ruby:2.3.8
|
4
|
+
|
5
|
+
# throw errors if Gemfile has been modified since Gemfile.lock
|
6
|
+
RUN bundle config --global frozen 1
|
7
|
+
|
8
|
+
WORKDIR /usr/src/app
|
9
|
+
|
10
|
+
COPY Gemfile Gemfile.lock date-holiday-reader.gemspec ./
|
11
|
+
COPY lib ./lib
|
12
|
+
COPY node_bin ./node_bin
|
13
|
+
|
14
|
+
RUN find .
|
15
|
+
|
16
|
+
RUN bundle install
|
17
|
+
|
18
|
+
# Run tests with:
|
19
|
+
# docker run -it --mount src="$(pwd)",target=/usr/src/app/mount,type=bind date_holidays-reader sh -c 'cd mount && rspec'
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
date_holidays-reader (0.9.9)
|
5
|
+
acts_as_hashable (~> 1)
|
6
|
+
caution
|
7
|
+
os (~> 1)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
acts_as_hashable (1.0.5)
|
13
|
+
ast (2.4.0)
|
14
|
+
byebug (10.0.2)
|
15
|
+
caution (0.1.0)
|
16
|
+
coderay (1.1.2)
|
17
|
+
diff-lcs (1.3)
|
18
|
+
ffi (1.10.0)
|
19
|
+
formatador (0.2.5)
|
20
|
+
guard (2.15.0)
|
21
|
+
formatador (>= 0.2.4)
|
22
|
+
listen (>= 2.7, < 4.0)
|
23
|
+
lumberjack (>= 1.0.12, < 2.0)
|
24
|
+
nenv (~> 0.1)
|
25
|
+
notiffany (~> 0.0)
|
26
|
+
pry (>= 0.9.12)
|
27
|
+
shellany (~> 0.0)
|
28
|
+
thor (>= 0.18.1)
|
29
|
+
guard-compat (1.2.1)
|
30
|
+
guard-rspec (4.7.3)
|
31
|
+
guard (~> 2.1)
|
32
|
+
guard-compat (~> 1.1)
|
33
|
+
rspec (>= 2.99.0, < 4.0)
|
34
|
+
jaro_winkler (1.5.2)
|
35
|
+
listen (3.1.5)
|
36
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
37
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
38
|
+
ruby_dep (~> 1.2)
|
39
|
+
lumberjack (1.0.13)
|
40
|
+
method_source (0.9.2)
|
41
|
+
nenv (0.3.0)
|
42
|
+
notiffany (0.1.1)
|
43
|
+
nenv (~> 0.1)
|
44
|
+
shellany (~> 0.0)
|
45
|
+
os (1.0.0)
|
46
|
+
parallel (1.13.0)
|
47
|
+
parser (2.6.0.0)
|
48
|
+
ast (~> 2.4.0)
|
49
|
+
powerpack (0.1.2)
|
50
|
+
pry (0.12.2)
|
51
|
+
coderay (~> 1.1.0)
|
52
|
+
method_source (~> 0.9.0)
|
53
|
+
pry-byebug (3.6.0)
|
54
|
+
byebug (~> 10.0)
|
55
|
+
pry (~> 0.10)
|
56
|
+
rainbow (3.0.0)
|
57
|
+
rake (10.5.0)
|
58
|
+
rb-fsevent (0.10.3)
|
59
|
+
rb-inotify (0.10.0)
|
60
|
+
ffi (~> 1.0)
|
61
|
+
rspec (3.8.0)
|
62
|
+
rspec-core (~> 3.8.0)
|
63
|
+
rspec-expectations (~> 3.8.0)
|
64
|
+
rspec-mocks (~> 3.8.0)
|
65
|
+
rspec-core (3.8.0)
|
66
|
+
rspec-support (~> 3.8.0)
|
67
|
+
rspec-expectations (3.8.2)
|
68
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
+
rspec-support (~> 3.8.0)
|
70
|
+
rspec-mocks (3.8.0)
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
72
|
+
rspec-support (~> 3.8.0)
|
73
|
+
rspec-support (3.8.0)
|
74
|
+
rubocop (0.63.1)
|
75
|
+
jaro_winkler (~> 1.5.1)
|
76
|
+
parallel (~> 1.10)
|
77
|
+
parser (>= 2.5, != 2.5.1.1)
|
78
|
+
powerpack (~> 0.1)
|
79
|
+
rainbow (>= 2.2.2, < 4.0)
|
80
|
+
ruby-progressbar (~> 1.7)
|
81
|
+
unicode-display_width (~> 1.4.0)
|
82
|
+
ruby-progressbar (1.10.0)
|
83
|
+
ruby_dep (1.5.0)
|
84
|
+
shellany (0.0.1)
|
85
|
+
terminal-notifier-guard (1.7.0)
|
86
|
+
thor (0.20.3)
|
87
|
+
unicode-display_width (1.4.1)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
ruby
|
91
|
+
|
92
|
+
DEPENDENCIES
|
93
|
+
bundler (~> 1.17)
|
94
|
+
date_holidays-reader!
|
95
|
+
guard
|
96
|
+
guard-rspec
|
97
|
+
pry
|
98
|
+
pry-byebug
|
99
|
+
rake (~> 10.0)
|
100
|
+
rspec (~> 3.0)
|
101
|
+
rubocop
|
102
|
+
terminal-notifier-guard
|
103
|
+
|
104
|
+
BUNDLED WITH
|
105
|
+
1.17.3
|
data/Guardfile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A sample Guardfile
|
4
|
+
# More info at https://github.com/guard/guard#readme
|
5
|
+
|
6
|
+
## Uncomment and set this to only include directories you want to watch
|
7
|
+
# directories %w(app lib config test spec features) \
|
8
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
9
|
+
|
10
|
+
## Note: if you are using the `directories` clause above and you are not
|
11
|
+
## watching the project directory ('.'), then you will want to move
|
12
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
13
|
+
#
|
14
|
+
# $ mkdir config
|
15
|
+
# $ mv Guardfile config/
|
16
|
+
# $ ln -s config/Guardfile .
|
17
|
+
#
|
18
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
19
|
+
|
20
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
21
|
+
# rspec may be run, below are examples of the most common uses.
|
22
|
+
# * bundler: 'bundle exec rspec'
|
23
|
+
# * bundler binstubs: 'bin/rspec'
|
24
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
25
|
+
# installed the spring binstubs per the docs)
|
26
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
27
|
+
# * 'just' rspec: 'rspec'
|
28
|
+
|
29
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
30
|
+
require 'guard/rspec/dsl'
|
31
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
32
|
+
|
33
|
+
# Feel free to open issues for suggestions and improvements
|
34
|
+
|
35
|
+
# RSpec files
|
36
|
+
rspec = dsl.rspec
|
37
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
38
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
39
|
+
watch(rspec.spec_files)
|
40
|
+
|
41
|
+
# Ruby files
|
42
|
+
ruby = dsl.ruby
|
43
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
44
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Copyright 2019 Blue Marble Payroll, LLC
|
2
|
+
|
3
|
+
The source code of this project is provided under the MIT license:
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
10
|
+
|
11
|
+
---
|
12
|
+
|
13
|
+
Holiday definitions:
|
14
|
+
|
15
|
+
Some of holiday data contained in pre-compiled date-holidays Node module wrapper programs which ship with the packaged version of the gem and the holiday data provided by the date-holidays module itself are licensed under Creative Commons Attribution-ShareAlike 3.0 <http://creativecommons.org/licenses/by-sa/3.0/>. This is because some of the data relies on Wikipedia articles.
|
16
|
+
|
17
|
+
The attributions can be found in the license file for the date-holidays Node module: https://raw.githubusercontent.com/commenthol/date-holidays/master/LICENSE .
|
data/README.md
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
# DateHolidays::Reader
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/bluemarblepayroll/date_holidays-reader.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/date_holidays-reader)
|
4
|
+
|
5
|
+
This is a read only Ruby wrapper for the
|
6
|
+
[date-holidays](https://github.com/commenthol/date-holidays) Node module. Note that Node does not have to be installed on many machines in order to use this gem. See the configuration section for more details.
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
Holiday information is available for many different locales. The first step is to create a locale object which represents a country or part of a country. For example, to retreive all holidays for this year in the United States:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
us = DateHolidays::Reader::Locale.new(country: :us)
|
14
|
+
us.holidays(Date.today.year) # returns a list of US holidays for the current year
|
15
|
+
```
|
16
|
+
|
17
|
+
Locales can be refined to just one state or even a region within a state:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
louisiana = DateHolidays::Reader::Locale.new(country: :us, state: :la)
|
21
|
+
louisiana.holidays(Date.today.year) # returns US and Louisiana holidays
|
22
|
+
|
23
|
+
new_orleans = DateHolidays::Reader::Locale.new(country: :us, state: :la, region: :no)
|
24
|
+
new_orleans.holidays(Date.today.year) # includes Mardi Gras plus all state country holidays
|
25
|
+
```
|
26
|
+
|
27
|
+
### Languages
|
28
|
+
|
29
|
+
Some countries support more than one language:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
mx = DateHolidays::Reader::Locale.new(country: :mx)
|
33
|
+
mx.languages # ["en", "es"]
|
34
|
+
mx.holidays(Date.year)
|
35
|
+
mx.holidays(Date.today.year).first.name # "New Year's Day"
|
36
|
+
mx.holidays(Date.today.year, language: :es).first.name # "Año Nuevo"
|
37
|
+
```
|
38
|
+
|
39
|
+
### Meta Data
|
40
|
+
|
41
|
+
Country, state, and region codes are defined in the [ISO 3166-2 standard](https://en.wikipedia.org/wiki/ISO_3166-2). These examples pass in the codes using Ruby symbols. However, it is also valid to specify them as Ruby strings. The supported codes can also be retrived using the following meta-data methods:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
# Returns a hash of all supported countries keyed by two letter ISO 3166-2 code
|
45
|
+
# and values of the country name:
|
46
|
+
DateHolidays::Reader::Config.countries
|
47
|
+
# {"AD"=>"Andorra", "AE"=>"دولة الإمارات العربية المتحدة", ... }
|
48
|
+
|
49
|
+
# Returns a hash of all supported states keyed by two letter ISO 3166-2 code
|
50
|
+
# and values of the state name:
|
51
|
+
DateHolidays::Reader::Locale.new(country: :us).states
|
52
|
+
# {"AL"=>"Alabama", "AK"=>"Alaska", "AZ"=>"Arizona", ... }
|
53
|
+
|
54
|
+
# Returns a hash of all supported regions keyed by two letter ISO 3166-2 code
|
55
|
+
# and values of the region name:
|
56
|
+
DateHolidays::Reader::Locale.new(country: :us, state: :la).regions
|
57
|
+
# {"NO"=>"New Orleans"}
|
58
|
+
```
|
59
|
+
|
60
|
+
### Holiday Object
|
61
|
+
|
62
|
+
`DateHolidays::Reader::Locale#holidays` returns a list contining an instance of `DateHolidays::Reader::Holiday` objects which have the following fields:
|
63
|
+
|
64
|
+
* *date* - The start date of the holiday which is stored in a Ruby `Date` instance.
|
65
|
+
* *start_time* - The start time of the holiday in UTC represented as a `Time` instance. Note that these times represent when the holiday starts *in this locale*. For example, US New Year's day in 2019 has a time of '2019-01-01 05:00:00 UTC' as Washington DC is five hours behind UTC.
|
66
|
+
* *end_time* - The time in UTC when the holiday ends. Note that some holidays (for example certian religious holidays) may not start or end on midnight. Also, some holidays last more or less then 24 hours.
|
67
|
+
* *name* - A string representing the human readable name of the holiday. For example: "New Year's Day."
|
68
|
+
* *type* - A symbol which describes the status of the holiday. See the [date-holidays documentation](https://github.com/commenthol/date-holidays#types-of-holidays) for a full explanation.
|
69
|
+
* *substitute* - A boolean value that, if true, means that it is a substitute for another holiday.
|
70
|
+
* *note* - An optional human readable note represented as a `String` or `nil`.
|
71
|
+
|
72
|
+
Note that this is a wrapper for the JavaScript Holiday object described [here](https://github.com/commenthol/date-holidays#types-of-holidays).
|
73
|
+
|
74
|
+
### API Comparison
|
75
|
+
|
76
|
+
The API provided by this gem is somewhat different than the [API provided by the date-holidays node module](https://github.com/commenthol/date-holidays-parser/blob/master/docs/Holidays.md). This is intentional in order to make the Ruby API more object-oriented. The biggest change is that the JavaScript API does not have a locale class.
|
77
|
+
|
78
|
+
## Installation
|
79
|
+
|
80
|
+
Add this line to your application's Gemfile:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
gem 'date_holidays-reader'
|
84
|
+
```
|
85
|
+
|
86
|
+
And then execute:
|
87
|
+
|
88
|
+
$ bundle
|
89
|
+
|
90
|
+
Or install it yourself as:
|
91
|
+
|
92
|
+
$ gem install date_holidays-reader
|
93
|
+
|
94
|
+
If you are runnning a Linux or Mac OS X machine running a 64 x86 compatible processor then everything should work at this point. If you are running a different OS, different processor, or would like to use Node directly then continue to the configuration section.
|
95
|
+
|
96
|
+
## Configuration
|
97
|
+
|
98
|
+
This gem ships with pre-compiled wrapper programs for the date-holidays node module for Mac OS X and Linux running on 64 bit x86 processors. If you are running on those architectures then no configuration is needed as one those binaries will be used by default. If the gem detects that you are running on a different architecture then it will attempt to use the version of Node.js in your path. In this case, you will need to install the [date-holidays Node module](https://github.com/commenthol/date-holidays) before using this gem. It is also possible to explicitly tell the gem where your Node.js binary is located:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
DateHolidays::Reader::Config.node_path = '/path/to/your/version/of/node`
|
102
|
+
```
|
103
|
+
|
104
|
+
Note that setting `node_path` will also force the gem to use Node instead of the provided binaries when running on a supported OS and processor combination.
|
105
|
+
|
106
|
+
Note that native Windows support would not be difficult to add. Pull requests are welcome!
|
107
|
+
|
108
|
+
## Related Work
|
109
|
+
|
110
|
+
The [holidays](https://github.com/holidays/holidays) gem is very similar and is a pure Ruby implimentaiton. This gem was created as the date-holidays node module has support for more countries. An advantages of the holidays gem over this gem is that holidays is faster as it does not have to fork a Node.js process in order to retreive data. Also, the holidays gem has support for some niche data such as [US Federal Reserve Banks](https://github.com/holidays/definitions/blob/master/federalreservebanks.yaml), the [New York Stock Exchange](https://github.com/holidays/definitions/blob/master/nyse.yaml), and others. Use the right tool for your needs.
|
111
|
+
|
112
|
+
## Future Direction
|
113
|
+
|
114
|
+
The holiday definitions provided by the date-holidays Node module defined by a specific grammer housed in YAML files. The next logical step would be to build a pure Ruby parser for this grammar. Time is the only limit here. If this works is done, it would be in a separate gem as it would not have to be a read only interface; it would be trivial to support user defined holiday definitions like the Node module.
|
115
|
+
|
116
|
+
## Development
|
117
|
+
|
118
|
+
Since this gem wraps a Node module, a Node.js installation is required. See the `.nvmrc` file for a recommended Node version. [Yarn](https://yarnpkg.com/lang/en/docs/install/) is also required to install requisite Node modules.
|
119
|
+
|
120
|
+
After checking out the repo and installing Node and Yarn, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
121
|
+
|
122
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
123
|
+
|
124
|
+
Note that `rake clobber` can be used to removed the pre-compiled Node wrappers.
|
125
|
+
|
126
|
+
There is also a `Dockerfile` provided which can be used to verify the Linux binaries.
|
127
|
+
|
128
|
+
### Releasing
|
129
|
+
|
130
|
+
1. Update the version number in `version.rb` and add a new entry to `CHANGELOG.md`.
|
131
|
+
|
132
|
+
1. Then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
133
|
+
|
134
|
+
### Updating the date-holidays Node Module Dependency
|
135
|
+
|
136
|
+
1. Update node modules:
|
137
|
+
|
138
|
+
```bash
|
139
|
+
$ yarn upgrade
|
140
|
+
```
|
141
|
+
|
142
|
+
Verify from the Yarn output that date-holidays was updated.
|
143
|
+
|
144
|
+
2. Recompile the node-bin binaries:
|
145
|
+
|
146
|
+
```bash
|
147
|
+
bundle exec rake node_compile
|
148
|
+
```
|
149
|
+
|
150
|
+
3. Update the node module version in `spec/date_holidays/reader/version_spec.rb`.
|
151
|
+
|
152
|
+
4. Verify by running the tests and check in yarn.lock.
|
153
|
+
|
154
|
+
## Contributing
|
155
|
+
|
156
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bluemarblepayroll/date_holidays-reader. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
157
|
+
|
158
|
+
Before submitting a pull requests, please do the following:
|
159
|
+
|
160
|
+
1. Update the README.md if changing or adding to the API.
|
161
|
+
2. Add to or update unit tests.
|
162
|
+
3. Ensure that all tests are passing.
|
163
|
+
4. Ensure that rubocop does not find any issues.
|
164
|
+
|
165
|
+
## Code of Conduct
|
166
|
+
|
167
|
+
Everyone interacting in the DateHolidays::Reader project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bluemarblepayroll/date_holidays-reader/blob/master/CODE_OF_CONDUCT.md).
|
168
|
+
|
169
|
+
## License
|
170
|
+
|
171
|
+
This project is MIT and [Creative Commons Attribution-ShareAlike 3.0](http://creativecommons.org/licenses/by-sa/3.0/)
|
172
|
+
Licensed. See the LICENSE file for more information.
|
173
|
+
|
174
|
+
## TODO
|
175
|
+
|
176
|
+
* Holiday type filtering should be handled by Node.
|