google_holiday_calendar 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +20 -12
- data/CHANGELOG.md +7 -1
- data/Gemfile +10 -0
- data/README.md +38 -15
- data/bin/google_holiday_calendar +11 -10
- data/google_holiday_calendar.gemspec +10 -7
- data/lib/google_holiday_calendar/version.rb +1 -1
- metadata +12 -41
- data/.env.example +0 -1
- data/spec/google_holiday_calendar/calendar_spec.rb +0 -83
- data/spec/google_holiday_calendar_spec.rb +0 -5
- data/spec/spec_helper.rb +0 -34
- data/spec/support/examples/holidays_in_japan_at_jan.rb +0 -5
- data/spec/support/examples/holidays_in_usa_at_jan.rb +0 -5
- data/spec/support/utils/util.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 764fa492993fdd1763ac844ceeac04a964a8a96bdbb6addae6c33210b9281024
|
4
|
+
data.tar.gz: 4921a3ae3e3919365b4273f04212bff3737f7a7ee6de15d78649ad553e6b9fa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b489fc20d5857294632273d37cb68206f30d0f2f3e5fbacb7a462e51ec03265867fd08e241f8dd48a08fbf835779490bf0786cedd919bdfb3575e03eabca9551
|
7
|
+
data.tar.gz: 19a709f3abf4bff30748fecac5142a6deed6e02e3f8ed81fe9c362bd38a925a502014af5861d9bc35ea82365878294f28611dcbe8c4f9a7eff98ae087f199cd2
|
data/.travis.yml
CHANGED
@@ -1,24 +1,32 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.0
|
4
|
-
- 2.1
|
5
|
-
- 2.2
|
6
|
-
-
|
7
|
-
|
8
|
-
-
|
3
|
+
- 2.0
|
4
|
+
- 2.1
|
5
|
+
- 2.2
|
6
|
+
- 2.3
|
7
|
+
- 2.4
|
8
|
+
- 2.5
|
9
|
+
- 2.6
|
10
|
+
- ruby-head
|
11
|
+
cache: bundler
|
12
|
+
before_install:
|
13
|
+
- travis_retry gem update --system || travis_retry gem update --system 2.7.8
|
14
|
+
- travis_retry gem install bundler --no-document || travis_retry gem install bundler --no-document -v 1.17.3
|
9
15
|
script:
|
10
|
-
- bundle exec rspec
|
16
|
+
- bundle exec rspec
|
11
17
|
branches:
|
12
18
|
only:
|
13
19
|
- master
|
14
|
-
env:
|
15
|
-
global:
|
16
|
-
secure: "PUaG7vOmYf3MhO6KJR7kaOeDk+MiP31JCMI6m47z7y+4SGBj0+pxdYK9CY50McGkjjNajXC6RoNJiaVwlQduLS7mM8WKusGKgtnr/APHtZqbVy+KSXdXLvVD/GPaGxb+W7/SlTj5lLAe75hFj48hMWH2g7qDERmbEksEMqXM8CE="
|
17
20
|
notifications:
|
18
21
|
email: false
|
19
22
|
slack:
|
20
23
|
secure: LFMFNHkB88zWrcjwRstw7Ri+pKVndjkz11H8r73GbrJOL76Lt4llVsraYLRrCnx859kRZul4SjbUIlYsRl28Wv2IJmIhvDnK9n5gX4nSbEfjrZGsaMOmJhY8MxazM4757TFEY6ugzwRD3hzWKEK6bIY6nRu5KAFaZhPjDbSaEpA=
|
21
24
|
matrix:
|
22
25
|
allow_failures:
|
23
|
-
|
24
|
-
|
26
|
+
- rvm: ruby-head
|
27
|
+
include:
|
28
|
+
- rvm: 2.6
|
29
|
+
env: RUBYOPT="--jit"
|
30
|
+
- rvm: ruby-head
|
31
|
+
env: RUBYOPT="--jit"
|
32
|
+
sudo: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## master
|
2
|
-
[full changelog](http://github.com/sue445/google_holiday_calendar/compare/v0.1.
|
2
|
+
[full changelog](http://github.com/sue445/google_holiday_calendar/compare/v0.1.1...master)
|
3
|
+
|
4
|
+
## v0.1.1
|
5
|
+
[full changelog](http://github.com/sue445/google_holiday_calendar/compare/v0.1.0...v0.1.1)
|
6
|
+
|
7
|
+
* Pass `GOOGLE_API_KEY` to `google_holiday_calendar`
|
8
|
+
* https://github.com/sue445/google_holiday_calendar/pull/20
|
3
9
|
|
4
10
|
## v0.1.0
|
5
11
|
[full changelog](http://github.com/sue445/google_holiday_calendar/compare/v0.0.2...v0.1.0)
|
data/Gemfile
CHANGED
@@ -2,3 +2,13 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in google_holiday_calendar.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.2.2")
|
7
|
+
gem "activesupport", "< 5.0.0"
|
8
|
+
end
|
9
|
+
|
10
|
+
if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.1.0")
|
11
|
+
group :test do
|
12
|
+
gem "public_suffix", "< 3.0.0"
|
13
|
+
end
|
14
|
+
end
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/google_holiday_calendar.png)](http://badge.fury.io/rb/google_holiday_calendar)
|
4
4
|
[![Build Status](https://travis-ci.org/sue445/google_holiday_calendar.png?branch=master)](https://travis-ci.org/sue445/google_holiday_calendar)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/sue445/google_holiday_calendar/badge.png)](https://coveralls.io/r/sue445/google_holiday_calendar)
|
6
|
-
[![Dependency Status](https://gemnasium.com/sue445/google_holiday_calendar.png)](https://gemnasium.com/sue445/google_holiday_calendar)
|
7
6
|
[![Code Climate](https://codeclimate.com/github/sue445/google_holiday_calendar.png)](https://codeclimate.com/github/sue445/google_holiday_calendar)
|
8
7
|
|
9
8
|
Get holidays via Google Calendar.
|
@@ -25,17 +24,49 @@ Or install it yourself as:
|
|
25
24
|
|
26
25
|
$ gem install google_holiday_calendar
|
27
26
|
|
27
|
+
## Getting API key
|
28
|
+
### 1. Create GCP project
|
29
|
+
https://console.cloud.google.com/projectcreate
|
30
|
+
|
31
|
+
![create-project](img/create-project.png)
|
32
|
+
|
33
|
+
### 2. Go to credentials
|
34
|
+
![dashboard](img/dashboard.png)
|
35
|
+
|
36
|
+
### 3. Create credential with API key
|
37
|
+
![create-credential](img/create-credential.png)
|
38
|
+
|
39
|
+
### 4. Enable restrictions (Optional)
|
40
|
+
Click RESTRICT KEY
|
41
|
+
|
42
|
+
![api-key-created](img/api-key-created.png)
|
43
|
+
|
44
|
+
e.g. "IP addresses" in Application restrictions
|
45
|
+
|
46
|
+
![application-restrictions](img/application-restrictions.png)
|
47
|
+
|
48
|
+
### 5. Enable calendar API
|
49
|
+
Go to Library
|
50
|
+
|
51
|
+
![dashboard-library](img/dashboard-library.png)
|
52
|
+
|
53
|
+
Search with "Calendar" and enable "Google Calendar API".
|
54
|
+
|
55
|
+
![search-apis](img/search-apis.png)
|
56
|
+
|
57
|
+
![enable-google-calendar-api](img/enable-google-calendar-api.png)
|
58
|
+
|
28
59
|
## Usage (via ruby)
|
29
60
|
|
30
61
|
```ruby
|
31
62
|
require "google_holiday_calendar"
|
32
63
|
|
33
|
-
usa_calendar = GoogleHolidayCalendar::Calendar.new(country: "usa", lang: "en")
|
64
|
+
usa_calendar = GoogleHolidayCalendar::Calendar.new(country: "usa", lang: "en", api_key: "YOUR_API_KEY")
|
34
65
|
|
35
66
|
usa_calendar.holidays(start_date: "2014-01-01", end_date: "2014-03-01", limit: 5)
|
36
67
|
# => {Wed, 01 Jan 2014=>"New Year's Day", Mon, 20 Jan 2014=>"Martin Luther King Day", Fri, 14 Feb 2014=>"Valentine's Day", Mon, 17 Feb 2014=>"Presidents' Day (Washington's Birthday)"}
|
37
68
|
|
38
|
-
japan_calendar = GoogleHolidayCalendar::Calendar.new(country: "japanese", lang: "ja")
|
69
|
+
japan_calendar = GoogleHolidayCalendar::Calendar.new(country: "japanese", lang: "ja", api_key: "YOUR_API_KEY")
|
39
70
|
|
40
71
|
japan_calendar.holidays(start_date: "2014-01-01", end_date: "2014-03-01", limit: 5)
|
41
72
|
# => {Wed, 01 Jan 2014=>"元日", Thu, 02 Jan 2014=>"銀行休業日", Fri, 03 Jan 2014=>"銀行休業日", Mon, 13 Jan 2014=>"成人の日", Tue, 11 Feb 2014=>"建国記念の日"}
|
@@ -54,13 +85,13 @@ japan_calendar.holiday?("2014-02-01")
|
|
54
85
|
$ date +"%Y-%m-%d"
|
55
86
|
2014-02-24
|
56
87
|
|
57
|
-
$ google_holiday_calendar
|
88
|
+
$ GOOGLE_API_KEY=xxxx google_holiday_calendar
|
58
89
|
2014-03-09: Daylight Saving Time starts
|
59
90
|
```
|
60
91
|
|
61
92
|
```sh
|
62
93
|
# get holidays (2014/01/01 - 2014/07/01)
|
63
|
-
$ google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01
|
94
|
+
$ GOOGLE_API_KEY=xxxx google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01
|
64
95
|
2014-01-01: New Year's Day
|
65
96
|
2014-01-20: Martin Luther King Day
|
66
97
|
2014-02-14: Valentine's Day
|
@@ -75,7 +106,7 @@ $ google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01
|
|
75
106
|
|
76
107
|
```sh
|
77
108
|
# get holidays (with limit)
|
78
|
-
$ google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01 --limit=3
|
109
|
+
$ GOOGLE_API_KEY=xxxx google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01 --limit=3
|
79
110
|
2014-02-14: Valentine's Day
|
80
111
|
2014-02-17: Presidents' Day (Washington's Birthday)
|
81
112
|
2014-04-13: Thomas Jefferson's Birthday
|
@@ -83,7 +114,7 @@ $ google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01 --limit=
|
|
83
114
|
|
84
115
|
```sh
|
85
116
|
# get holidays (specify country and language)
|
86
|
-
$ google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01 --country=japanese --lang=ja
|
117
|
+
$ GOOGLE_API_KEY=xxxx google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01 --country=japanese --lang=ja
|
87
118
|
2014-01-01: 元日
|
88
119
|
2014-01-02: 銀行休業日
|
89
120
|
2014-01-03: 銀行休業日
|
@@ -99,14 +130,6 @@ $ google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01 --countr
|
|
99
130
|
## More reference
|
100
131
|
http://rubydoc.info/github/sue445/google_holiday_calendar
|
101
132
|
|
102
|
-
## Testing
|
103
|
-
get api key on [API Console](https://code.google.com/apis/console/) and enable Google Calendar API
|
104
|
-
|
105
|
-
```bash
|
106
|
-
cp .env.example .env
|
107
|
-
vi .env
|
108
|
-
```
|
109
|
-
|
110
133
|
## Contributing
|
111
134
|
|
112
135
|
1. Fork it ( http://github.com/sue445/google_holiday_calendar/fork )
|
data/bin/google_holiday_calendar
CHANGED
@@ -4,11 +4,11 @@ require 'google_holiday_calendar'
|
|
4
4
|
require 'optparse'
|
5
5
|
|
6
6
|
options = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
start_date: nil,
|
8
|
+
end_date: nil,
|
9
|
+
limit: 10,
|
10
|
+
country: "usa",
|
11
|
+
lang: "en",
|
12
12
|
}
|
13
13
|
|
14
14
|
opt = OptionParser.new
|
@@ -20,12 +20,13 @@ opt.on('--lang[=LANG]' , 'default: en') {|v| options[:lang
|
|
20
20
|
opt.parse!(ARGV)
|
21
21
|
|
22
22
|
GoogleHolidayCalendar::Calendar.new(
|
23
|
-
|
24
|
-
|
23
|
+
country: options[:country],
|
24
|
+
lang: options[:lang],
|
25
|
+
api_key: ENV["GOOGLE_API_KEY"],
|
25
26
|
).holidays(
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
start_date: options[:start_date],
|
28
|
+
end_date: options[:end_date],
|
29
|
+
limit: options[:limit],
|
29
30
|
).each do |date, title|
|
30
31
|
puts "#{date}: #{title}"
|
31
32
|
end
|
@@ -15,7 +15,11 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.required_ruby_version = '>= 2.0.0'
|
17
17
|
|
18
|
-
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|img)/}) }
|
22
|
+
end
|
19
23
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
24
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
25
|
spec.require_paths = ["lib"]
|
@@ -23,13 +27,12 @@ Gem::Specification.new do |spec|
|
|
23
27
|
spec.add_dependency "activesupport", ">= 4.0.0"
|
24
28
|
|
25
29
|
spec.add_development_dependency "bundler", ">= 1.5"
|
30
|
+
spec.add_development_dependency "coveralls"
|
31
|
+
spec.add_development_dependency "delorean"
|
26
32
|
spec.add_development_dependency "rake"
|
27
|
-
spec.add_development_dependency "rspec"
|
28
|
-
spec.add_development_dependency "rspec-its"
|
33
|
+
spec.add_development_dependency "rspec"
|
29
34
|
spec.add_development_dependency "rspec-collection_matchers"
|
30
|
-
spec.add_development_dependency "
|
35
|
+
spec.add_development_dependency "rspec-its"
|
36
|
+
spec.add_development_dependency "webmock"
|
31
37
|
spec.add_development_dependency "yard"
|
32
|
-
spec.add_development_dependency "memoist"
|
33
|
-
spec.add_development_dependency "coveralls"
|
34
|
-
spec.add_development_dependency "dotenv"
|
35
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_holiday_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: coveralls
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,21 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 3.1.0
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 3.1.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec-its
|
56
|
+
name: delorean
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - ">="
|
@@ -81,7 +67,7 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: rake
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - ">="
|
@@ -95,7 +81,7 @@ dependencies:
|
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
84
|
+
name: rspec
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - ">="
|
@@ -109,7 +95,7 @@ dependencies:
|
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
98
|
+
name: rspec-collection_matchers
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - ">="
|
@@ -123,7 +109,7 @@ dependencies:
|
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
112
|
+
name: rspec-its
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
115
|
- - ">="
|
@@ -137,7 +123,7 @@ dependencies:
|
|
137
123
|
- !ruby/object:Gem::Version
|
138
124
|
version: '0'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
126
|
+
name: webmock
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
129
|
- - ">="
|
@@ -151,7 +137,7 @@ dependencies:
|
|
151
137
|
- !ruby/object:Gem::Version
|
152
138
|
version: '0'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
140
|
+
name: yard
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
143
|
- - ">="
|
@@ -173,7 +159,6 @@ extensions: []
|
|
173
159
|
extra_rdoc_files: []
|
174
160
|
files:
|
175
161
|
- ".coveralls.yml"
|
176
|
-
- ".env.example"
|
177
162
|
- ".gitignore"
|
178
163
|
- ".rspec"
|
179
164
|
- ".travis.yml"
|
@@ -188,12 +173,6 @@ files:
|
|
188
173
|
- lib/google_holiday_calendar.rb
|
189
174
|
- lib/google_holiday_calendar/calendar.rb
|
190
175
|
- lib/google_holiday_calendar/version.rb
|
191
|
-
- spec/google_holiday_calendar/calendar_spec.rb
|
192
|
-
- spec/google_holiday_calendar_spec.rb
|
193
|
-
- spec/spec_helper.rb
|
194
|
-
- spec/support/examples/holidays_in_japan_at_jan.rb
|
195
|
-
- spec/support/examples/holidays_in_usa_at_jan.rb
|
196
|
-
- spec/support/utils/util.rb
|
197
176
|
homepage: https://github.com/sue445/google_holiday_calendar
|
198
177
|
licenses:
|
199
178
|
- MIT
|
@@ -213,16 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
192
|
- !ruby/object:Gem::Version
|
214
193
|
version: '0'
|
215
194
|
requirements: []
|
216
|
-
|
217
|
-
rubygems_version: 2.2.2
|
195
|
+
rubygems_version: 3.0.3
|
218
196
|
signing_key:
|
219
197
|
specification_version: 4
|
220
198
|
summary: Get holidays via Google Calendar.
|
221
|
-
test_files:
|
222
|
-
- spec/google_holiday_calendar/calendar_spec.rb
|
223
|
-
- spec/google_holiday_calendar_spec.rb
|
224
|
-
- spec/spec_helper.rb
|
225
|
-
- spec/support/examples/holidays_in_japan_at_jan.rb
|
226
|
-
- spec/support/examples/holidays_in_usa_at_jan.rb
|
227
|
-
- spec/support/utils/util.rb
|
228
|
-
has_rdoc:
|
199
|
+
test_files: []
|
data/.env.example
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
GOOGLE_API_KEY=
|
@@ -1,83 +0,0 @@
|
|
1
|
-
describe GoogleHolidayCalendar::Calendar do
|
2
|
-
describe "#holidays" do
|
3
|
-
subject{ calendar.holidays(start_date: start_date, end_date: end_date, limit: limit) }
|
4
|
-
|
5
|
-
let(:limit) { 10 }
|
6
|
-
let(:start_date){ "2014-01-01" }
|
7
|
-
let(:end_date) { "2014-01-31" }
|
8
|
-
|
9
|
-
context "Without country and lang" do
|
10
|
-
let(:calendar){ GoogleHolidayCalendar::Calendar.new(api_key: ENV["GOOGLE_API_KEY"]) }
|
11
|
-
|
12
|
-
its(:count){ should > 0 }
|
13
|
-
end
|
14
|
-
|
15
|
-
context "With country and lang" do
|
16
|
-
let(:calendar){ GoogleHolidayCalendar::Calendar.new(country: country, lang: lang, api_key: ENV["GOOGLE_API_KEY"]) }
|
17
|
-
|
18
|
-
context "When holidays in Japan" do
|
19
|
-
let(:country) { "japanese" }
|
20
|
-
let(:lang) { "ja" }
|
21
|
-
|
22
|
-
context "When args are YYYY-MM-DD" do
|
23
|
-
let(:start_date){ "2014-01-01" }
|
24
|
-
let(:end_date) { "2014-01-31" }
|
25
|
-
|
26
|
-
it_behaves_like :holidays_in_japan_at_jan
|
27
|
-
end
|
28
|
-
|
29
|
-
context "When args are instance" do
|
30
|
-
let(:start_date){ date("2014-01-01") }
|
31
|
-
let(:end_date) { date("2014-01-31") }
|
32
|
-
|
33
|
-
it_behaves_like :holidays_in_japan_at_jan
|
34
|
-
end
|
35
|
-
|
36
|
-
context "Without start_date and end_date" do
|
37
|
-
let(:start_date){ nil }
|
38
|
-
let(:end_date) { nil }
|
39
|
-
|
40
|
-
before do
|
41
|
-
time_travel_to "2014-01-01"
|
42
|
-
end
|
43
|
-
|
44
|
-
it_behaves_like :holidays_in_japan_at_jan
|
45
|
-
end
|
46
|
-
|
47
|
-
context "When not found holidays" do
|
48
|
-
let(:start_date){ "2014-06-01" }
|
49
|
-
let(:end_date) { "2014-07-01" }
|
50
|
-
|
51
|
-
it{ should == {}}
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "When holidays in America" do
|
56
|
-
let(:country) { "usa" }
|
57
|
-
let(:lang) { "en" }
|
58
|
-
|
59
|
-
it_behaves_like :holidays_in_usa_at_jan
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "#holiday?" do
|
65
|
-
subject{ calendar.holiday?(date) }
|
66
|
-
|
67
|
-
let(:calendar){ GoogleHolidayCalendar::Calendar.new(country: country, lang: lang, api_key: ENV["GOOGLE_API_KEY"]) }
|
68
|
-
let(:country) { "japanese" }
|
69
|
-
let(:lang) { "ja" }
|
70
|
-
|
71
|
-
context "arg is holiday" do
|
72
|
-
let(:date){ Date.parse("2014-01-01") }
|
73
|
-
|
74
|
-
it{ should be true }
|
75
|
-
end
|
76
|
-
|
77
|
-
context "arg is not holiday" do
|
78
|
-
let(:date){ Date.parse("2014-02-01") }
|
79
|
-
|
80
|
-
it{ should be false }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
if ENV["COVERAGE"]
|
2
|
-
require 'coveralls'
|
3
|
-
Coveralls.wear!
|
4
|
-
end
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
7
|
-
require 'google_holiday_calendar'
|
8
|
-
|
9
|
-
require 'rspec'
|
10
|
-
require 'rspec/its'
|
11
|
-
require 'rspec/collection_matchers'
|
12
|
-
require 'delorean'
|
13
|
-
require 'memoist'
|
14
|
-
require 'dotenv'
|
15
|
-
Dotenv.load
|
16
|
-
|
17
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
18
|
-
# in spec/support/ and its subdirectories.
|
19
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
20
|
-
|
21
|
-
RSpec.configure do |config|
|
22
|
-
config.include Delorean
|
23
|
-
|
24
|
-
config.after(:each) do
|
25
|
-
back_to_the_present
|
26
|
-
end
|
27
|
-
|
28
|
-
config.before(:suite) do
|
29
|
-
class GoogleHolidayCalendar::Calendar
|
30
|
-
extend Memoist
|
31
|
-
memoize :fetch
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/spec/support/utils/util.rb
DELETED