gannet 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +20 -0
- data/README.md +38 -0
- data/gannet.gemspec +24 -0
- data/lib/gannet.rb +18 -0
- data/lib/gannet/configuration.rb +10 -0
- data/lib/gannet/version.rb +3 -0
- data/lib/gannet/web_services/forecast_zip_code.rb +9 -0
- data/spec/gannet/web_services/forecast_zip_code_spec.rb +53 -0
- data/spec/spec_helper.rb +14 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a3eca4434ca9beeac5cd3ae2e986a64d4990e98d5b15163e915e99dcd565ec94
|
4
|
+
data.tar.gz: 242172efd7f5c462de4d7992e0cf0245aea81a8753309ffd94acd0c3b0882e0c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b5ce39b3649a74c3b9d88c36fbb0ae07699267d358ab42a7d683dfc73ab50061e23d9d7975595e914eab5f181b03aeaf1876fa52dfda5e0b381f6192300de067
|
7
|
+
data.tar.gz: 87f92f54b27f1d030638565ca0f94c63cabcd25ace01817d96b62b7ad72ba819082978c202462dfc10d63b8aa0cefa882c2bf7f4da416610ce84fe113a7741f1
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2020 John Akers
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Gannet
|
2
|
+
|
3
|
+
A RubyGem wrapp for [AirNow's API](https://docs.airnowapi.org/)
|
4
|
+
|
5
|
+
### Installation
|
6
|
+
|
7
|
+
```rb
|
8
|
+
gem install gannet
|
9
|
+
```
|
10
|
+
|
11
|
+
or in your Gemfile...
|
12
|
+
|
13
|
+
```rb
|
14
|
+
gem 'gannet'
|
15
|
+
```
|
16
|
+
|
17
|
+
### Configuration
|
18
|
+
|
19
|
+
You will need to set your AirNow `api_key` before making requests. You can get one [here](https://docs.airnowapi.org/account/request).
|
20
|
+
|
21
|
+
```rb
|
22
|
+
Gannet.configure do |c|
|
23
|
+
c.api_key = 'YOUR_API_KEY'
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
### Usage / Examples (TODO)
|
28
|
+
|
29
|
+
Once configured, you have access to the below methods. They correspond to the available endpoints, listed on AirNow's API.
|
30
|
+
|
31
|
+
```rb
|
32
|
+
query = { zipCode: 94118 }
|
33
|
+
Gannet::WebServices.forecast_zip_code(query)
|
34
|
+
|
35
|
+
# ... In Progress
|
36
|
+
```
|
37
|
+
|
38
|
+
Full documentation on what can be in `query` can be found in AirNow's API documentation [here](https://docs.airnowapi.org/)
|
data/gannet.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
$LOAD_PATH.push(File.expand_path('../lib', __FILE__))
|
2
|
+
|
3
|
+
require 'gannet/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'gannet'
|
7
|
+
s.version = Gannet::VERSION
|
8
|
+
s.authors = ['John Akers']
|
9
|
+
s.homepage = 'https://github.com/johnakers/gannet'
|
10
|
+
s.summary = 'Wrapper for AirNow'
|
11
|
+
s.description = 'RubyGem for AirNow, in order to get air quality information'
|
12
|
+
s.licenses = ['MIT']
|
13
|
+
s.require_paths = ['lib']
|
14
|
+
|
15
|
+
#
|
16
|
+
s.add_dependency('httparty', '~> 0.18.1')
|
17
|
+
|
18
|
+
#
|
19
|
+
s.add_development_dependency('rspec', '~> 3.9.0')
|
20
|
+
s.add_development_dependency('pry', '~> 0.13.1')
|
21
|
+
|
22
|
+
# files
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
end
|
data/lib/gannet.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# gems
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
# files
|
5
|
+
require 'gannet/version'
|
6
|
+
require 'gannet/configuration'
|
7
|
+
require 'gannet/web_services/forecast_zip_code'
|
8
|
+
|
9
|
+
module Gannet
|
10
|
+
class << self
|
11
|
+
attr_accessor :configuration
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
self.configuration ||= Configuration.new
|
16
|
+
yield(configuration)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Gannet::WebServices do
|
4
|
+
describe '.forecast_zip_code' do
|
5
|
+
let(:query) do
|
6
|
+
{
|
7
|
+
format: 'application/json',
|
8
|
+
zipCode: 94118
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:forecast_zip_code_response) do
|
13
|
+
double(
|
14
|
+
code: 200,
|
15
|
+
parsed_response: [
|
16
|
+
{
|
17
|
+
'DateIssue' => '2020-10-10 ',
|
18
|
+
'DateForecast' => '2020-10-11 ',
|
19
|
+
'ReportingArea' => 'San Francisco',
|
20
|
+
'StateCode' => 'CA',
|
21
|
+
'Latitude' => 37.75,
|
22
|
+
'Longitude' => -122.43,
|
23
|
+
'ParameterName' => 'PM2.5',
|
24
|
+
'AQI' => 89,
|
25
|
+
'Category' => {
|
26
|
+
'Number' => 2,
|
27
|
+
'Name' => 'Moderate'
|
28
|
+
},
|
29
|
+
'ActionDay' => false
|
30
|
+
}
|
31
|
+
]
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
before do
|
36
|
+
allow(HTTParty).to receive(:get).
|
37
|
+
and_return(forecast_zip_code_response)
|
38
|
+
|
39
|
+
Gannet.configure { |c| c.api_key = 'mock_api_key' }
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns the current forecaset by zip code' do
|
43
|
+
expect(HTTParty).to receive(:get).
|
44
|
+
with(
|
45
|
+
"#{Gannet.configuration.url}/aq/forecast/zipCode",
|
46
|
+
query: query.merge(API_KEY: Gannet.configuration.api_key)
|
47
|
+
).
|
48
|
+
and_return(forecast_zip_code_response)
|
49
|
+
|
50
|
+
Gannet::WebServices.forecast_zip_code(query)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'gannet'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.expect_with :rspec do |expectations|
|
6
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
7
|
+
end
|
8
|
+
|
9
|
+
config.mock_with :rspec do |mocks|
|
10
|
+
mocks.verify_partial_doubles = true
|
11
|
+
end
|
12
|
+
|
13
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gannet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Akers
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-10-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.18.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.18.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.9.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.9.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.13.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.13.1
|
55
|
+
description: RubyGem for AirNow, in order to get air quality information
|
56
|
+
email:
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- ".gitignore"
|
62
|
+
- ".rspec"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- gannet.gemspec
|
67
|
+
- lib/gannet.rb
|
68
|
+
- lib/gannet/configuration.rb
|
69
|
+
- lib/gannet/version.rb
|
70
|
+
- lib/gannet/web_services/forecast_zip_code.rb
|
71
|
+
- spec/gannet/web_services/forecast_zip_code_spec.rb
|
72
|
+
- spec/spec_helper.rb
|
73
|
+
homepage: https://github.com/johnakers/gannet
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubygems_version: 3.0.3
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Wrapper for AirNow
|
96
|
+
test_files: []
|