holidays_from_google_calendar 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +16 -1
- data/README.md +75 -3
- data/holidays_from_google_calendar.gemspec +0 -1
- data/lib/holidays_from_google_calendar/client.rb +3 -1
- data/lib/holidays_from_google_calendar/version.rb +1 -1
- metadata +3 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d580e1150fd1410a754c1704caf0a2bd8961b45c4e19eb14298fd8a0fd754de1
|
4
|
+
data.tar.gz: 0d924ba7e83d1b72db38e2ac1eb210edaa941511098eafd5a7bcb661917204a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5c0261d1d967e2178e52de58b8b3031eb5d8a7740b9044e9136ce0b21b20d46d244244d96b75a5ccc330b6cce8999ead598547afd9420bd4a64b00002440e57
|
7
|
+
data.tar.gz: bcdf1eafebd441cb953430e2d286a42b411a213aef1f4035188869cf10eefafd8fc67b1899a2b733d07f490cb2e496a8caf64a8cd767a0702367efbcb8421f2f
|
data/.travis.yml
CHANGED
@@ -1,6 +1,21 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- CC_TEST_REPORTER_ID=a5c4305696a06c12d5071d9c5bbda7d604be0495ad47c6199389f633fcbdaf86
|
1
4
|
language: ruby
|
2
5
|
rvm:
|
3
6
|
- 2.0
|
4
7
|
- 2.1
|
5
8
|
- 2.2
|
6
|
-
|
9
|
+
- 2.3
|
10
|
+
- 2.4
|
11
|
+
- 2.5
|
12
|
+
before_install:
|
13
|
+
- gem update --system --no-document
|
14
|
+
before_script:
|
15
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
16
|
+
- chmod +x ./cc-test-reporter
|
17
|
+
- ./cc-test-reporter before-build
|
18
|
+
after_script:
|
19
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
20
|
+
notifications:
|
21
|
+
email: false
|
data/README.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
|
-
# HolidaysFromGoogleCalendar
|
2
|
-
|
1
|
+
# HolidaysFromGoogleCalendar
|
2
|
+
|
3
|
+
[](https://travis-ci.org/necojackarc/holidays_from_google_calendar)
|
4
|
+
[](https://codeclimate.com/github/necojackarc/holidays_from_google_calendar)
|
5
|
+
[](https://codeclimate.com/github/necojackarc/holidays_from_google_calendar/coverage)
|
6
|
+
|
7
|
+
HolidaysFromGoogleCalendar can retrieve national holidays from Google Calendar with very simple interface.
|
8
|
+
|
9
|
+
The results is going to be cached and you can preload holidays with your favorite range at initialization if you want.
|
10
|
+
These features help you to reduce access times to Google Calendar API.
|
11
|
+
|
12
|
+
I am sure that you only need to access the API a very few times if you preload holidays with proper range.
|
13
|
+
|
14
|
+
Using Google Calendar, available nations are same as Google Calendar.
|
15
|
+
|
16
|
+
Note that you can only retrieve holidays which Google Calendar has.
|
17
|
+
Google Calendar appears not to have all holidays, so you cannot retrieve very old ones and far future's.
|
18
|
+
|
19
|
+
## Features
|
20
|
+
### Main
|
21
|
+
* List holidays of a particular nation in a particular year
|
22
|
+
* List holidays of a particular nation in a particular month
|
23
|
+
* Check a date whether it is a holiday or not in a particular nation
|
24
|
+
|
25
|
+
### Others
|
26
|
+
* Cacheing results using LRU algorithm
|
27
|
+
* Preload holidays at initialization
|
3
28
|
|
4
29
|
## Installation
|
5
30
|
Add this line to your application's Gemfile:
|
@@ -21,7 +46,54 @@ $ gem install holidays_from_google_calendar
|
|
21
46
|
```
|
22
47
|
|
23
48
|
## Usage
|
49
|
+
### Configuration
|
50
|
+
All parameters you can pass are below:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
usa_holidays = HolidaysFromGoogleCalendar::Holidays.new do |config|
|
54
|
+
config.credential = {
|
55
|
+
api_key: "YOUR OWN GOOGLE API KEY"
|
56
|
+
}
|
57
|
+
|
58
|
+
config.calendar = {
|
59
|
+
nation: "usa",
|
60
|
+
language: "en"
|
61
|
+
}
|
24
62
|
|
63
|
+
config.cache = {
|
64
|
+
enable: true,
|
65
|
+
max_size: 1000 # DEFAULT_CACHE_SIZE is 1000
|
66
|
+
}
|
67
|
+
|
68
|
+
config.preload = {
|
69
|
+
enable: true, # Require cache enabled
|
70
|
+
date_range: 1.year # Retrive holidays from "this day last year" to "this day next year"
|
71
|
+
}
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
Default parameters of `cache` and `preload` are same as above.
|
76
|
+
|
77
|
+
### List holidays of a particular nation in a particular year
|
78
|
+
Returns a array of holidays in a particular year.
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
usa_holidays.in_year(Date.current)
|
82
|
+
```
|
83
|
+
|
84
|
+
### List holidays of a particular nation in a particular month
|
85
|
+
Returns a array of holidays in a particular month.
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
usa_holidays.in_month(Date.current)
|
89
|
+
```
|
90
|
+
|
91
|
+
### Check a date whether it is a holiday or not in a particular nation
|
92
|
+
Returns `true` when the day is holiday, Saturday or Sunday.
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
usa_holidays.holiday?(Date.current)
|
96
|
+
```
|
25
97
|
|
26
98
|
### Sample code
|
27
99
|
```ruby
|
@@ -69,7 +141,7 @@ usa_holidays.in_month(Date.parse("3rd March 2016")) # Retrieve holidays of March
|
|
69
141
|
usa_holidays.holiday?(Date.parse("Oct 31 2016")) # Halloween
|
70
142
|
=> true
|
71
143
|
|
72
|
-
usa_holidays.holiday?(Date.parse("April 16th 2016")) #
|
144
|
+
usa_holidays.holiday?(Date.parse("April 16th 2016")) # Saturday
|
73
145
|
=> true
|
74
146
|
|
75
147
|
usa_holidays.holiday?(Date.parse("April 17th 2016")) # Sunday
|
@@ -50,9 +50,11 @@ module HolidaysFromGoogleCalendar
|
|
50
50
|
|
51
51
|
def pack_response_in_object(response, date_min, date_max)
|
52
52
|
response.items.reduce([]) do |array, item|
|
53
|
+
date = item.start.date
|
54
|
+
|
53
55
|
holiday = Holiday.new(
|
54
56
|
name: item.summary,
|
55
|
-
date: Date.parse(
|
57
|
+
date: date.is_a?(Date) ? date : Date.parse(date)
|
56
58
|
)
|
57
59
|
|
58
60
|
if date_min <= holiday.date && holiday.date <= date_max
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: holidays_from_google_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- necojackarc
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-api-client
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: codeclimate-test-reporter
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
125
|
description: Retriving national holidays from Google Calendar.
|
140
126
|
email:
|
141
127
|
- necojackarc@gmail.com
|
@@ -181,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
167
|
- !ruby/object:Gem::Version
|
182
168
|
version: '0'
|
183
169
|
requirements: []
|
184
|
-
|
185
|
-
rubygems_version: 2.4.5.1
|
170
|
+
rubygems_version: 3.0.3
|
186
171
|
signing_key:
|
187
172
|
specification_version: 4
|
188
173
|
summary: Holidays from Google Calendar.
|