petrel 0.0.3 → 0.0.4
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 +4 -4
- data/.gitignore +3 -0
- data/lib/petrel.rb +8 -1
- data/lib/petrel/configuration.rb +5 -14
- data/lib/petrel/forecast.rb +2 -2
- data/lib/petrel/one_call.rb +2 -2
- data/lib/petrel/version.rb +1 -1
- data/lib/petrel/weather.rb +2 -2
- data/spec/petrel/configuration_spec.rb +2 -2
- data/spec/petrel/forecast_spec.rb +2 -2
- data/spec/petrel/one_call_spec.rb +2 -2
- data/spec/petrel/weather_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dcfff848127b27b0951d1ec174335cb7bf6c844144626a90dda4743a3d68e28
|
4
|
+
data.tar.gz: f92fcd4b380e8d0b30f43c7c70ce9a178e5138ef2c63a234330ca92b903f2b30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6aa3163c2b94c7c61a608b52605793282ee0f2c9acf1ee763098d6cf50f14765f940672046fa7515a5d3ed014dd6d634317b20169b26b3c5c0ca549178e37f
|
7
|
+
data.tar.gz: bb9c6996110ef2838ff2ebb83f4a12d1dd7a66e70e9d6771760370ea143e425d6d1fe32f07078868dd1faa44534072cef13ba7cddd080a0605b89c07f321c9e8
|
data/.gitignore
CHANGED
data/lib/petrel.rb
CHANGED
data/lib/petrel/configuration.rb
CHANGED
@@ -1,19 +1,10 @@
|
|
1
1
|
module Petrel
|
2
|
-
|
3
|
-
|
2
|
+
class Configuration
|
3
|
+
attr_reader :url
|
4
|
+
attr_accessor :api_key
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
def api_key
|
8
|
-
@api_key
|
9
|
-
end
|
10
|
-
|
11
|
-
def url
|
12
|
-
BASE_URL
|
13
|
-
end
|
14
|
-
|
15
|
-
def configure
|
16
|
-
yield self
|
6
|
+
def initialize
|
7
|
+
@url = 'https://api.openweathermap.org/data/2.5'
|
17
8
|
end
|
18
9
|
end
|
19
10
|
end
|
data/lib/petrel/forecast.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Petrel
|
2
2
|
def self.forecast(params)
|
3
|
-
weather_url = "#{url}/forecast"
|
4
|
-
query = params.merge(appid: api_key)
|
3
|
+
weather_url = "#{configuration.url}/forecast"
|
4
|
+
query = params.merge(appid: configuration.api_key)
|
5
5
|
HTTParty.get(weather_url, query: query)
|
6
6
|
end
|
7
7
|
end
|
data/lib/petrel/one_call.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Petrel
|
2
2
|
def self.one_call(params)
|
3
|
-
one_call_url = "#{url}/onecall"
|
4
|
-
query = params.merge(appid: api_key)
|
3
|
+
one_call_url = "#{configuration.url}/onecall"
|
4
|
+
query = params.merge(appid: configuration.api_key)
|
5
5
|
HTTParty.get(one_call_url, query: query)
|
6
6
|
end
|
7
7
|
end
|
data/lib/petrel/version.rb
CHANGED
data/lib/petrel/weather.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Petrel
|
2
2
|
def self.weather(params)
|
3
|
-
weather_url = "#{url}/weather"
|
4
|
-
query = params.merge(appid: api_key)
|
3
|
+
weather_url = "#{configuration.url}/weather"
|
4
|
+
query = params.merge(appid: configuration.api_key)
|
5
5
|
HTTParty.get(weather_url, query: query)
|
6
6
|
end
|
7
7
|
end
|
@@ -9,8 +9,8 @@ RSpec.describe Petrel::Configuration do
|
|
9
9
|
c.api_key = api_key
|
10
10
|
end
|
11
11
|
|
12
|
-
expect(Petrel.api_key).to eq(api_key)
|
13
|
-
expect(Petrel.url).to eq(
|
12
|
+
expect(Petrel.configuration.api_key).to eq(api_key)
|
13
|
+
expect(Petrel.configuration.url).to eq(
|
14
14
|
'https://api.openweathermap.org/data/2.5'
|
15
15
|
)
|
16
16
|
end
|
@@ -82,10 +82,10 @@ RSpec.describe Petrel do
|
|
82
82
|
|
83
83
|
it 'returns the current weather' do
|
84
84
|
expect(HTTParty).to receive(:get).
|
85
|
-
with("#{Petrel.url}/forecast", query: {
|
85
|
+
with("#{Petrel.configuration.url}/forecast", query: {
|
86
86
|
lat: 37,
|
87
87
|
lon: -122,
|
88
|
-
appid: Petrel.api_key
|
88
|
+
appid: Petrel.configuration.api_key
|
89
89
|
}).
|
90
90
|
and_return(forecast_response)
|
91
91
|
|
@@ -114,10 +114,10 @@ RSpec.describe Petrel do
|
|
114
114
|
|
115
115
|
it 'returns the current weather' do
|
116
116
|
expect(HTTParty).to receive(:get).
|
117
|
-
with("#{Petrel.url}/onecall", query: {
|
117
|
+
with("#{Petrel.configuration.url}/onecall", query: {
|
118
118
|
lat: 37,
|
119
119
|
lon: -122,
|
120
|
-
appid: Petrel.api_key
|
120
|
+
appid: Petrel.configuration.api_key
|
121
121
|
}).
|
122
122
|
and_return(one_call_response)
|
123
123
|
|
data/spec/petrel/weather_spec.rb
CHANGED
@@ -68,9 +68,9 @@ RSpec.describe Petrel do
|
|
68
68
|
|
69
69
|
it 'returns the current weather' do
|
70
70
|
expect(HTTParty).to receive(:get).
|
71
|
-
with("#{Petrel.url}/weather", query: {
|
71
|
+
with("#{Petrel.configuration.url}/weather", query: {
|
72
72
|
q: 'San Francisco',
|
73
|
-
appid: Petrel.api_key
|
73
|
+
appid: Petrel.configuration.api_key
|
74
74
|
}).
|
75
75
|
and_return(weather_response)
|
76
76
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: petrel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Akers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|