openweather2 0.1.3 → 0.1.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/lib/openweather2/client.rb +0 -26
- data/lib/openweather2/version.rb +1 -1
- data/lib/openweather2/weather.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ef3f8e41cba45a0f32e7fef1b9e04ff26a62468
|
4
|
+
data.tar.gz: 2c347a76100236c5ebce073b72545ad3bdc8c0d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74725fc9f20473e27ac3e28b0a24cf75a946f37f8c8495aed506995cad72a66727c1d93a74bb9d4dcbfd8a60e3ed2b3d0f63d71a2e412eb2410446fa9e503dbd
|
7
|
+
data.tar.gz: a1d01c89957949d6b7850df12cc23da2aae4c66429a07dd4c8e064f85dd51f81dc36159136a0483e5c9c1bc00bbbdf183eeaaf3ec77f053584545428e6f35f4b
|
data/lib/openweather2/client.rb
CHANGED
@@ -59,31 +59,5 @@ module Openweather2
|
|
59
59
|
def default_params
|
60
60
|
{:APPID => Openweather2.configuration.apikey }
|
61
61
|
end
|
62
|
-
|
63
|
-
def do_request(req)
|
64
|
-
configure_required!
|
65
|
-
|
66
|
-
endpoint_uri = URI(Openweather2.configuration.endpoint)
|
67
|
-
|
68
|
-
|
69
|
-
http_params = [
|
70
|
-
endpoint_uri.hostname,
|
71
|
-
endpoint_uri.port,
|
72
|
-
use_ssl: uri.scheme == 'https'
|
73
|
-
]
|
74
|
-
|
75
|
-
res = Net::HTTP.start(*http_params) do |http|
|
76
|
-
http.request(req)
|
77
|
-
end
|
78
|
-
|
79
|
-
case res
|
80
|
-
when Net::HTTPSuccess
|
81
|
-
JSON.parse(res.body)
|
82
|
-
when Net::HTTPUnprocessableEntity
|
83
|
-
raise UnprocessableError, "Bad URI param!"
|
84
|
-
else
|
85
|
-
raise UnknownResponse, "Something was wrong!"
|
86
|
-
end
|
87
|
-
end
|
88
62
|
|
89
63
|
end
|
data/lib/openweather2/version.rb
CHANGED
data/lib/openweather2/weather.rb
CHANGED
@@ -6,8 +6,8 @@ module Openweather2
|
|
6
6
|
|
7
7
|
def initialize(json)
|
8
8
|
@city = json['name']
|
9
|
-
@longitude = json['coord']['lon']
|
10
|
-
@latitude = json['coord']['lat']
|
9
|
+
@longitude = json['coord'] && json['coord']['lon']
|
10
|
+
@latitude = json['coord'] && json['coord']['lat']
|
11
11
|
@temperature = Openweather2::Temperature.new(json['main']['temp'])
|
12
12
|
@pressure = json['main']['pressure']
|
13
13
|
@humidity = json['main']['humidity']
|