date_holidays-reader 0.9.9 → 1.0.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 +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +16 -10
- data/date-holiday-reader.gemspec +2 -2
- data/lib/date_holidays/reader.rb +5 -5
- data/lib/date_holidays/reader/holiday.rb +1 -1
- data/lib/date_holidays/reader/locale.rb +1 -1
- data/lib/date_holidays/reader/version.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af0d30253f0f1c0503f7bf901ffcd199503857fd467d1c8d467c96120047c778
|
4
|
+
data.tar.gz: 3669adc9fe2150e046453f0ee25e2865416dd54ea200547310986eaaba9bedc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6ab7854171bf544138df558e4ae0d9cc46ccf2e799e34db34f222d172c4f8d9421c5320658ffcf50afe9336b23d1137cf9c5bd0dcbf77af4e4954835eb1f63f
|
7
|
+
data.tar.gz: d550784c39bb1aeb187392d388d91927fe40c8ad6b79248dc9e98693ba0348599e34e26a79aafeb9cf687a3cd251fc29a067988ddda0489ee736a393e10a6666
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/bluemarblepayroll/date_holidays-reader.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/date_holidays-reader)
|
4
4
|
|
5
|
-
This is a read
|
5
|
+
This is a read-only Ruby wrapper for the
|
6
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
7
|
|
8
8
|
## Usage
|
9
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
|
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 retrieve all holidays for this year in the United States:
|
11
11
|
|
12
12
|
```ruby
|
13
13
|
us = DateHolidays::Reader::Locale.new(country: :us)
|
@@ -59,11 +59,11 @@ DateHolidays::Reader::Locale.new(country: :us, state: :la).regions
|
|
59
59
|
|
60
60
|
### Holiday Object
|
61
61
|
|
62
|
-
`DateHolidays::Reader::Locale#holidays` returns a list
|
62
|
+
`DateHolidays::Reader::Locale#holidays` returns a list containing an instance of `DateHolidays::Reader::Holiday` objects which have the following fields:
|
63
63
|
|
64
64
|
* *date* - The start date of the holiday which is stored in a Ruby `Date` instance.
|
65
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
|
66
|
+
* *end_time* - The time in UTC when the holiday ends. Note that some holidays (for example certain religious holidays) may not start or end on midnight. Also, some holidays last more or less then 24 hours.
|
67
67
|
* *name* - A string representing the human readable name of the holiday. For example: "New Year's Day."
|
68
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
69
|
* *substitute* - A boolean value that, if true, means that it is a substitute for another holiday.
|
@@ -91,14 +91,14 @@ Or install it yourself as:
|
|
91
91
|
|
92
92
|
$ gem install date_holidays-reader
|
93
93
|
|
94
|
-
If you are
|
94
|
+
If you are running a Linux or Mac OS X machine running an [x86-64](https://en.wikipedia.org/wiki/X86-64) 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
95
|
|
96
96
|
## Configuration
|
97
97
|
|
98
|
-
This gem ships with pre-compiled wrapper programs for the date-holidays
|
98
|
+
This gem ships with pre-compiled wrapper programs for the date-holidays Node module for Mac OS X and Linux running on [x86-64](https://en.wikipedia.org/wiki/X86-64) 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
99
|
|
100
100
|
```ruby
|
101
|
-
DateHolidays::Reader::Config.node_path = '/path/to/your/version/of/node
|
101
|
+
DateHolidays::Reader::Config.node_path = '/path/to/your/version/of/node'
|
102
102
|
```
|
103
103
|
|
104
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.
|
@@ -107,11 +107,15 @@ Note that native Windows support would not be difficult to add. Pull requests ar
|
|
107
107
|
|
108
108
|
## Related Work
|
109
109
|
|
110
|
-
The [holidays](https://github.com/holidays/holidays) gem is very similar and is a pure Ruby
|
110
|
+
The [holidays](https://github.com/holidays/holidays) gem is very similar and is a pure Ruby implementation. This gem was created as the date-holidays node module has support for more countries. An advantage 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 retrieve 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
111
|
|
112
112
|
## Future Direction
|
113
113
|
|
114
|
-
The holiday definitions provided by the date-holidays Node module defined by a specific
|
114
|
+
The holiday definitions provided by the date-holidays Node module are defined by a specific grammar 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 work 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
|
+
## Gem Name
|
117
|
+
|
118
|
+
You may be wondering: "Why the underscore and dash in the name?" This is intentional to match the name of of the main Ruby module of `DateHolidays::Reader`. The Ruby convention is to use underscores to separate words and dashes for namespaces. Note that if another gem is created which is not just a Node module wrapper then the module will be just `DateHolidays` and the gem will be named date_holidays.
|
115
119
|
|
116
120
|
## Development
|
117
121
|
|
@@ -129,6 +133,8 @@ There is also a `Dockerfile` provided which can be used to verify the Linux bina
|
|
129
133
|
|
130
134
|
1. Update the version number in `version.rb` and add a new entry to `CHANGELOG.md`.
|
131
135
|
|
136
|
+
1. Commit and push the above changes.
|
137
|
+
|
132
138
|
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
139
|
|
134
140
|
### Updating the date-holidays Node Module Dependency
|
@@ -136,7 +142,7 @@ There is also a `Dockerfile` provided which can be used to verify the Linux bina
|
|
136
142
|
1. Update node modules:
|
137
143
|
|
138
144
|
```bash
|
139
|
-
|
145
|
+
yarn upgrade
|
140
146
|
```
|
141
147
|
|
142
148
|
Verify from the Yarn output that date-holidays was updated.
|
data/date-holiday-reader.gemspec
CHANGED
@@ -11,9 +11,9 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.authors = ['Ryan Gerry']
|
12
12
|
spec.email = ['rgerry@bluemarblepayroll.com']
|
13
13
|
|
14
|
-
spec.summary = 'A read
|
14
|
+
spec.summary = 'A read-only Ruby wrapper for the date-holidays Node module'
|
15
15
|
spec.description = <<~DESCRIPTION
|
16
|
-
This provides a read
|
16
|
+
This provides a read-only interace over the data provided by the
|
17
17
|
date-holidays Node module available at https://github.com/commenthol/date-holidays .'
|
18
18
|
DESCRIPTION
|
19
19
|
spec.homepage = 'http://www.github.com/bluemarblepayroll/date_holidays-reader/'
|
data/lib/date_holidays/reader.rb
CHANGED
@@ -12,11 +12,11 @@ require 'caution'
|
|
12
12
|
require 'json'
|
13
13
|
require 'os'
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
require_relative 'reader/config'
|
16
|
+
require_relative 'reader/holiday'
|
17
|
+
require_relative 'reader/js_bridge'
|
18
|
+
require_relative 'reader/locale'
|
19
|
+
require_relative 'reader/version'
|
20
20
|
|
21
21
|
module DateHolidays
|
22
22
|
# Defines the outermost module for the gem.
|
@@ -32,7 +32,7 @@ module DateHolidays
|
|
32
32
|
# initialization so I'd rather pass in everything as needed right away.
|
33
33
|
def initialize(date:, start_time:, end_time:, name:, type:, substitute: false, note: nil)
|
34
34
|
# rubocop:enable Metrics/ParameterLists
|
35
|
-
@date = date.
|
35
|
+
@date = date.respond_to?(:to_date) ? date.to_date : Date.strptime(date, '%Y-%m-%d')
|
36
36
|
@start_time = parse_time(start_time)
|
37
37
|
@end_time = parse_time(end_time)
|
38
38
|
@name = name
|
@@ -69,7 +69,7 @@ module DateHolidays
|
|
69
69
|
# Note that this could instead be .slice under Ruby >= 2.5 or with Rails:
|
70
70
|
clean_hash = raw.select { |key, _value| SUPPORTED_HOLIDAY_ATTRIBUTES.include?(key) }
|
71
71
|
|
72
|
-
# Node date-
|
72
|
+
# Node date-holidays uses start and end keys. The "end" key does not play well with Ruby.
|
73
73
|
# Also, the "_time" suffix adds clarity.
|
74
74
|
clean_hash[:start_time] = clean_hash.delete('start')
|
75
75
|
clean_hash[:end_time] = clean_hash.delete('end')
|
@@ -11,9 +11,9 @@ require_relative 'js_bridge'
|
|
11
11
|
|
12
12
|
module DateHolidays
|
13
13
|
module Reader
|
14
|
-
VERSION = '0.
|
14
|
+
VERSION = '1.0.0'
|
15
15
|
|
16
|
-
# Used to
|
16
|
+
# Used to retrieve futher version information such as the underlying node module version.
|
17
17
|
class Version
|
18
18
|
VERSION_PROGRAM_PATH = File.join(JsBridge::BIN_PATH, 'date-holidays-version.js').freeze
|
19
19
|
private_constant :VERSION_PROGRAM_PATH
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: date_holidays-reader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Gerry
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_hashable
|
@@ -179,7 +179,7 @@ dependencies:
|
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
description: |
|
182
|
-
This provides a read
|
182
|
+
This provides a read-only interace over the data provided by the
|
183
183
|
date-holidays Node module available at https://github.com/commenthol/date-holidays .'
|
184
184
|
email:
|
185
185
|
- rgerry@bluemarblepayroll.com
|
@@ -241,5 +241,5 @@ requirements: []
|
|
241
241
|
rubygems_version: 3.0.2
|
242
242
|
signing_key:
|
243
243
|
specification_version: 4
|
244
|
-
summary: A read
|
244
|
+
summary: A read-only Ruby wrapper for the date-holidays Node module
|
245
245
|
test_files: []
|