holidays_from_google_calendar 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 59d4d036317d5ad1ff9807433d1a475b4643add2
4
- data.tar.gz: 896ce2010c7329bd3efb95524a9b50f5129734f2
2
+ SHA256:
3
+ metadata.gz: d580e1150fd1410a754c1704caf0a2bd8961b45c4e19eb14298fd8a0fd754de1
4
+ data.tar.gz: 0d924ba7e83d1b72db38e2ac1eb210edaa941511098eafd5a7bcb661917204a1
5
5
  SHA512:
6
- metadata.gz: b54fe874772619a7ec877990aecd1a9d2d34002b38ad6c6299f800f51656fc849adc3ed6952ad6cc4094ae81cad8898a162cb7c7b0a74649f83e6a4c03579394
7
- data.tar.gz: 496bfa2f3fb07d89940ebd86aa1305f57c64258cd1d0e71c787e8f2354b9ff3d0ba0267e934bea5549518dd911fe82c449ee783315aed325fc37e982f0782eff
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
- before_install: gem install bundler -v 1.10.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 [![Build Status](https://travis-ci.org/necojackarc/holidays_from_google_calendar.svg?branch=master)](https://travis-ci.org/necojackarc/holidays_from_google_calendar) [![Code Climate](https://codeclimate.com/github/necojackarc/holidays_from_google_calendar/badges/gpa.svg)](https://codeclimate.com/github/necojackarc/holidays_from_google_calendar) [![Test Coverage](https://codeclimate.com/github/necojackarc/holidays_from_google_calendar/badges/coverage.svg)](https://codeclimate.com/github/necojackarc/holidays_from_google_calendar/coverage)
2
- Under construction.
1
+ # HolidaysFromGoogleCalendar
2
+
3
+ [![Build Status](https://travis-ci.org/necojackarc/holidays_from_google_calendar.svg?branch=master)](https://travis-ci.org/necojackarc/holidays_from_google_calendar)
4
+ [![Code Climate](https://codeclimate.com/github/necojackarc/holidays_from_google_calendar/badges/gpa.svg)](https://codeclimate.com/github/necojackarc/holidays_from_google_calendar)
5
+ [![Test Coverage](https://codeclimate.com/github/necojackarc/holidays_from_google_calendar/badges/coverage.svg)](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")) # Satruday
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
@@ -28,5 +28,4 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "rspec"
29
29
  spec.add_development_dependency "rspec-its"
30
30
  spec.add_development_dependency "simplecov"
31
- spec.add_development_dependency "codeclimate-test-reporter"
32
31
  end
@@ -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(item.start.date)
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
@@ -1,3 +1,3 @@
1
1
  module HolidaysFromGoogleCalendar
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
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.6
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: 2016-02-07 00:00:00.000000000 Z
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
- rubyforge_project:
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.