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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a30a046932013b55ad3e68cb4d151e87914a35f9a676c0ccb938c1172f39179
4
- data.tar.gz: a39da5eb10f2fb60071d86df29a2ad5244db89517f3aef30fa1533213d58b246
3
+ metadata.gz: 1dcfff848127b27b0951d1ec174335cb7bf6c844144626a90dda4743a3d68e28
4
+ data.tar.gz: f92fcd4b380e8d0b30f43c7c70ce9a178e5138ef2c63a234330ca92b903f2b30
5
5
  SHA512:
6
- metadata.gz: a65a11f888866345f0bea1abcaa461536ca134fd49b6275f4bfac53e7f0a2607254efe42a9be3e93074f3867c93c7b53794ca5436d9e00590df375701109ec3e
7
- data.tar.gz: f49d3d9950b6727e79dd947b1f9ab93c8e24446a7cef4f38922d5d825082260028e817d66ab4dcc43e35da877eb4c41c4f663cec67770caa2c442fdf68372f64
6
+ metadata.gz: 5b6aa3163c2b94c7c61a608b52605793282ee0f2c9acf1ee763098d6cf50f14765f940672046fa7515a5d3ed014dd6d634317b20169b26b3c5c0ca549178e37f
7
+ data.tar.gz: bb9c6996110ef2838ff2ebb83f4a12d1dd7a66e70e9d6771760370ea143e425d6d1fe32f07078868dd1faa44534072cef13ba7cddd080a0605b89c07f321c9e8
data/.gitignore CHANGED
@@ -4,3 +4,6 @@
4
4
  # Don't checkin Gemfile.lock
5
5
  # See: http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
6
6
  Gemfile.lock
7
+
8
+ # Ignore any created gems
9
+ petrel-*
@@ -9,5 +9,12 @@ require 'petrel/weather'
9
9
  require 'httparty'
10
10
 
11
11
  module Petrel
12
- extend Configuration
12
+ class << self
13
+ attr_accessor :configuration
14
+ end
15
+
16
+ def self.configure
17
+ self.configuration ||= Configuration.new
18
+ yield(configuration)
19
+ end
13
20
  end
@@ -1,19 +1,10 @@
1
1
  module Petrel
2
- module Configuration
3
- BASE_URL = 'https://api.openweathermap.org/data/2.5'
2
+ class Configuration
3
+ attr_reader :url
4
+ attr_accessor :api_key
4
5
 
5
- attr_writer :api_key
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
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Petrel
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -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
 
@@ -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.3
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-06 00:00:00.000000000 Z
11
+ date: 2020-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty