owmo 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/core_extensions/net/http_response/weather_response.rb +5 -1
- data/lib/owmo/version.rb +1 -1
- data/lib/owmo/weather.rb +8 -6
- 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: 125a82a8915262a016d7b78461f403abf325d76d177d97700e1be023ad3e22eb
|
4
|
+
data.tar.gz: 6d47d5e59c2d3b31322a478dc252a33cfdbc88139d86d641f29cc67861d9c88c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a574a3a6a6b8f81bb77da1a4e8f10809fe8f43012b214061c269c7c91c22768543357e280d18cc7ef72e0f2cce04f9af35ae3c70c3370f5364257cae4fdd79eb
|
7
|
+
data.tar.gz: 9a93faefecb90ae2147ef9d20b2fe1f280ba582fba580e8588d7bf6084ab2e9b400e9b0a2e162c0dfc5efac105860fa8b15e28850d26c4215c7d96c80db4640d
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'json'
|
4
|
+
require 'net/http'
|
4
5
|
|
5
6
|
module CoreExtensions
|
6
7
|
module Net
|
@@ -17,7 +18,8 @@ module CoreExtensions
|
|
17
18
|
# Returns the response code
|
18
19
|
def weather_code
|
19
20
|
parse_weather
|
20
|
-
|
21
|
+
|
22
|
+
return (weather['cod'] || '500').to_i if weather.is_a? Hash
|
21
23
|
|
22
24
|
200
|
23
25
|
end
|
@@ -59,3 +61,5 @@ module CoreExtensions
|
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
64
|
+
|
65
|
+
Net::HTTPResponse.include CoreExtensions::Net::HTTPResponse::WeatherResponse
|
data/lib/owmo/version.rb
CHANGED
data/lib/owmo/weather.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'core_extensions/net/http_response/weather_response'
|
4
|
+
|
5
|
+
require 'json'
|
3
6
|
require 'logger'
|
4
7
|
require 'net/http'
|
5
8
|
|
6
|
-
|
7
9
|
module OWMO
|
8
10
|
# rdoc
|
9
11
|
# A weather class for retrieving current and forecasted weather conditions.
|
@@ -18,7 +20,7 @@ module OWMO
|
|
18
20
|
# Weather response error to handle errors received from OpenWeatherMap.orgs API
|
19
21
|
class WeatherResponseError < StandardError
|
20
22
|
def initialize(response)
|
21
|
-
super("ERROR #{response
|
23
|
+
super("ERROR #{response.weather_code}: #{response.message}")
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
@@ -82,11 +84,11 @@ module OWMO
|
|
82
84
|
uri = format_uri(OWMO::URL, PATHS[path], query)
|
83
85
|
|
84
86
|
# Get the weather data
|
85
|
-
|
87
|
+
response = http_get(uri)
|
86
88
|
|
87
|
-
raise
|
89
|
+
raise(WeatherResponseError, response) if response.error?
|
88
90
|
|
89
|
-
weather
|
91
|
+
response.weather
|
90
92
|
end
|
91
93
|
|
92
94
|
private
|
@@ -121,7 +123,7 @@ module OWMO
|
|
121
123
|
http.request(Net::HTTP::Get.new(uri))
|
122
124
|
end
|
123
125
|
|
124
|
-
|
126
|
+
response
|
125
127
|
end
|
126
128
|
end
|
127
129
|
# :nocov:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: owmo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robb Randall
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|