weatheruby 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/LICENSE.md +25 -0
- data/bin/weatheruby +1 -8
- data/lib/weather/actions.rb +123 -194
- data/lib/weather/planner.rb +0 -3
- data/lib/weatheruby.rb +18 -20
- metadata +3 -3
- data/lib/weather/exceptions.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 026ed072be84b5a96eb75c83db822615c325cd08
|
4
|
+
data.tar.gz: 5e4f4279b2b2504db4c55967ac5dcbe94efadcaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d0a962683862297071511012d7f8ecffb74aabdf47b84d8797241986aaa84d04ae9f2f0ef0d421397efcd7b90c740115fe6c8a65d4a268ae7baf11be43b96ed
|
7
|
+
data.tar.gz: 2c6f8f5202a725bf698c0eb02bff7ccf71bb94cd77088cc53131773d6f9b413f77d2ad2303630987483e9c2460b50595b9041ad661ed0bc258f99ce9a680a9c6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
## Version 0
|
3
|
+
### Version 0.6.0
|
4
|
+
* Error handling is much more generic now, with a single WeatherError which gets its message from the Weather
|
5
|
+
Underground API. With this is also the removal of the `verbose` option. Lastly, no method will return an error
|
6
|
+
silently, but actually `fail` with the WeatherError.
|
7
|
+
* `language_key` is now an attribute accessor.
|
8
|
+
|
3
9
|
### Version 0.5.3
|
4
10
|
* Update to HTTPClient 2.8
|
5
11
|
* Use pessimistic version requirements, and actually add version requirements for Rainbow and StringUtility.
|
data/LICENSE.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright © 2016 Eli Foster
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
6
|
+
obtaining a copy of this software and associated documentation
|
7
|
+
files (the “Software”), to deal in the Software without
|
8
|
+
restriction, including without limitation the rights to use,
|
9
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the
|
11
|
+
Software is furnished to do so, subject to the following
|
12
|
+
conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
19
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
23
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
24
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
|
data/bin/weatheruby
CHANGED
@@ -16,7 +16,6 @@ require_relative '../lib/weatheruby'
|
|
16
16
|
|
17
17
|
@args = {
|
18
18
|
help: false,
|
19
|
-
verbose: false,
|
20
19
|
token: nil,
|
21
20
|
location: nil,
|
22
21
|
language: 'EN'
|
@@ -24,7 +23,6 @@ require_relative '../lib/weatheruby'
|
|
24
23
|
|
25
24
|
usage = 'Usage: weatheruby [t] token [-l] [-j] languagecode [-v] [-h]'
|
26
25
|
help = "-h, --help Show helpful information about Weatheruby usage\n" \
|
27
|
-
"-v, --verbose Output verbose errors\n" \
|
28
26
|
"-t, --token The token to log in as\n" \
|
29
27
|
"-l, --location The location to get weather data for\n" \
|
30
28
|
'-j, --language The language code to use'
|
@@ -34,7 +32,6 @@ ARGV.each do |arg|
|
|
34
32
|
when '-t', '--token' then @args[:token] = ARGV.at(ARGV.index(arg) + 1)
|
35
33
|
when '-h', '--help' then @args[:help] = true
|
36
34
|
when '-l', '--location' then @args[:location] = ARGV.at(ARGV.index(arg) + 1)
|
37
|
-
when '-v', '--verbose' then @args[:verbose] = true
|
38
35
|
when '-j', '--language' then @args[:language] = ARGV.at(ARGV.index(arg) + 1)
|
39
36
|
end
|
40
37
|
end
|
@@ -55,11 +52,7 @@ if @args[:token].nil? || @args[:location].nil?
|
|
55
52
|
exit
|
56
53
|
end
|
57
54
|
|
58
|
-
client = Weatheruby.new(@args[:token],
|
59
|
-
@args[:language],
|
60
|
-
true,
|
61
|
-
true,
|
62
|
-
@args[:verbose])
|
55
|
+
client = Weatheruby.new(@args[:token], @args[:language], true, true)
|
63
56
|
|
64
57
|
conditions = client.conditions(@args[:location])
|
65
58
|
moon = client.moon_phase(@args[:location])
|
data/lib/weather/actions.rb
CHANGED
@@ -7,28 +7,20 @@ module Weather
|
|
7
7
|
# information for a different alert.
|
8
8
|
def alerts(location)
|
9
9
|
response = get('alerts', location)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
count += 1
|
22
|
-
end
|
23
|
-
|
24
|
-
ret
|
25
|
-
else
|
26
|
-
if @verbose_errors
|
27
|
-
return response['response']['error']['description']
|
28
|
-
else
|
29
|
-
return response['response']['error']['type']
|
30
|
-
end
|
10
|
+
ret = []
|
11
|
+
count = 0
|
12
|
+
response['alerts'].each do |a|
|
13
|
+
ret[count] = {
|
14
|
+
type: a['type'],
|
15
|
+
description: a['description'],
|
16
|
+
date: a['date'],
|
17
|
+
expires: a['expires'],
|
18
|
+
message: a['message']
|
19
|
+
}
|
20
|
+
count += 1
|
31
21
|
end
|
22
|
+
|
23
|
+
ret
|
32
24
|
end
|
33
25
|
|
34
26
|
# Gets the current moon phase of the location.
|
@@ -36,22 +28,13 @@ module Weather
|
|
36
28
|
# @return [Hash/String] A hash of two integers for the moon phase
|
37
29
|
# information. The age key in the hash contains the moon's age in days,
|
38
30
|
# and the illumination key contains the percentage of how illuminated it
|
39
|
-
# is.
|
31
|
+
# is.
|
40
32
|
def moon_phase(location)
|
41
33
|
response = get('astronomy', location)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
ret
|
48
|
-
else
|
49
|
-
if @verbose_errors
|
50
|
-
return response['response']['error']['description']
|
51
|
-
else
|
52
|
-
return response['response']['error']['type']
|
53
|
-
end
|
54
|
-
end
|
34
|
+
{
|
35
|
+
age: response['moon_phase']['ageOfMoon'].to_i,
|
36
|
+
illumination: response['moon_phase']['percentIlluminated'].to_i
|
37
|
+
}
|
55
38
|
end
|
56
39
|
|
57
40
|
# Gets weather conditions for the location.
|
@@ -59,43 +42,35 @@ module Weather
|
|
59
42
|
# @return [Hash] A hash containing strings of relevant weather information.
|
60
43
|
def conditions(location)
|
61
44
|
response = get('conditions', location)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
ret
|
92
|
-
else
|
93
|
-
if @verbose_errors
|
94
|
-
return response['response']['error']['description']
|
95
|
-
else
|
96
|
-
return response['response']['error']['type']
|
97
|
-
end
|
98
|
-
end
|
45
|
+
current_observation = response['current_observation']
|
46
|
+
display_location = current_observation['display_location']
|
47
|
+
|
48
|
+
ret = {
|
49
|
+
full_name: display_location['full'],
|
50
|
+
city_name: display_location['city'],
|
51
|
+
state_abbreviation: display_location['state'],
|
52
|
+
state_name: display_location['state_name'],
|
53
|
+
country: display_location['country'],
|
54
|
+
zip_code: display_location['zip'].to_i,
|
55
|
+
updated: current_observation['observation_time'],
|
56
|
+
weather: current_observation['weather'],
|
57
|
+
formatted_temperature: current_observation['temperature_string'],
|
58
|
+
temperature_f: current_observation['temp_f'],
|
59
|
+
temperature_c: current_observation['temp_c'],
|
60
|
+
humidity: current_observation['relative_humidity'],
|
61
|
+
formatted_wind: current_observation['wind_string'],
|
62
|
+
wind_direction: current_observation['wind_dir'],
|
63
|
+
wind_degrees: current_observation['wind_degrees'],
|
64
|
+
wind_speed: current_observation['wind_mph'],
|
65
|
+
wind_gust_speed: current_observation['wind_gust_mph'].to_i,
|
66
|
+
formatted_feelslike: current_observation['feelslike_string'],
|
67
|
+
feelslike_f: current_observation['feelslike_f'].to_i,
|
68
|
+
feelslike_c: current_observation['feelslike_c'].to_i
|
69
|
+
}
|
70
|
+
|
71
|
+
ret[:humidity] = ret[:humidity].sub('%', '').to_i
|
72
|
+
|
73
|
+
ret
|
99
74
|
end
|
100
75
|
|
101
76
|
# Gets the record low for the location.
|
@@ -103,24 +78,13 @@ module Weather
|
|
103
78
|
# @return [Hash] A hash containing a few integers of data.
|
104
79
|
def record_low(location)
|
105
80
|
response = get('almanac', location)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
record_low_c: response['almanac']['temp_low']['record']['C'].to_i
|
114
|
-
}
|
115
|
-
|
116
|
-
ret
|
117
|
-
else
|
118
|
-
if @verbose_errors
|
119
|
-
return response['response']['error']['description']
|
120
|
-
else
|
121
|
-
return response['response']['error']['type']
|
122
|
-
end
|
123
|
-
end
|
81
|
+
{
|
82
|
+
average_low_f: response['almanac']['temp_low']['normal']['F'].to_i,
|
83
|
+
average_low_c: response['almanac']['temp_low']['normal']['C'].to_i,
|
84
|
+
record_year: response['almanac']['temp_low']['recordyear'].to_i,
|
85
|
+
record_low_f: response['almanac']['temp_low']['record']['F'].to_i,
|
86
|
+
record_low_c: response['almanac']['temp_low']['record']['C'].to_i
|
87
|
+
}
|
124
88
|
end
|
125
89
|
|
126
90
|
# Gets the record high for the location.
|
@@ -128,24 +92,13 @@ module Weather
|
|
128
92
|
# @return [Hash] A hash containing a few integers of data.
|
129
93
|
def record_high(location)
|
130
94
|
response = get('almanac', location)
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
record_high_c: response['almanac']['temp_high']['record']['C'].to_i
|
139
|
-
}
|
140
|
-
|
141
|
-
ret
|
142
|
-
else
|
143
|
-
if @verbose_errors
|
144
|
-
return response['response']['error']['description']
|
145
|
-
else
|
146
|
-
return response['response']['error']['type']
|
147
|
-
end
|
148
|
-
end
|
95
|
+
{
|
96
|
+
average_high_f: response['almanac']['temp_high']['normal']['F'].to_i,
|
97
|
+
average_high_c: response['almanac']['temp_high']['normal']['C'].to_i,
|
98
|
+
record_year: response['almanac']['temp_high']['recordyear'].to_i,
|
99
|
+
record_high_f: response['almanac']['temp_high']['record']['F'].to_i,
|
100
|
+
record_high_c: response['almanac']['temp_high']['record']['C'].to_i
|
101
|
+
}
|
149
102
|
end
|
150
103
|
|
151
104
|
# Gets data for currently-happening hurricanes around the world.
|
@@ -154,31 +107,23 @@ module Weather
|
|
154
107
|
def hurricane_data
|
155
108
|
response = get('currenthurricane', 'view')
|
156
109
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
}
|
172
|
-
end
|
173
|
-
|
174
|
-
ret
|
175
|
-
else
|
176
|
-
if @verbose_errors
|
177
|
-
return response['response']['error']['description']
|
178
|
-
else
|
179
|
-
return response['response']['error']['type']
|
180
|
-
end
|
110
|
+
ret = {}
|
111
|
+
response['currenthurricane'].each do |h|
|
112
|
+
ret[h['stormInfo']['stormName_Nice']] = {
|
113
|
+
name: h['stormInfo']['stormName'],
|
114
|
+
number: h['stormInfo']['stormNumber'],
|
115
|
+
category: h['Current']['Category'],
|
116
|
+
time: h['Current']['Time']['pretty'],
|
117
|
+
wind_speed_mph: h['Current']['WindSpeed']['Mph'],
|
118
|
+
wind_speed_kts: h['Current']['WindSpeed']['Kts'],
|
119
|
+
wind_speed_kph: h['Current']['WindSpeed']['Kph'],
|
120
|
+
gust_speed_mph: h['Current']['WindGust']['Mph'],
|
121
|
+
gust_speed_kts: h['Current']['WindGust']['Kts'],
|
122
|
+
gust_speed_kph: h['Current']['WindGust']['Kph']
|
123
|
+
}
|
181
124
|
end
|
125
|
+
|
126
|
+
ret
|
182
127
|
end
|
183
128
|
|
184
129
|
# Gets the basic forecast information for the location. Only gets data
|
@@ -228,76 +173,60 @@ module Weather
|
|
228
173
|
|
229
174
|
# Parses the simple forecast information.
|
230
175
|
def parse_simple_forecast(response)
|
231
|
-
|
232
|
-
ret = {}
|
176
|
+
ret = {}
|
233
177
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
end
|
241
|
-
|
242
|
-
ret
|
243
|
-
else
|
244
|
-
if @verbose_errors
|
245
|
-
return response['response']['error']['description']
|
246
|
-
else
|
247
|
-
return response['response']['error']['type']
|
248
|
-
end
|
178
|
+
response['forecast']['txt_forecast']['forecastday'].each do |f|
|
179
|
+
ret[f['period']] = {
|
180
|
+
weekday_name: f['title'],
|
181
|
+
text: f['fcttext'],
|
182
|
+
text_metric: f['fcttext_metric']
|
183
|
+
}
|
249
184
|
end
|
185
|
+
|
186
|
+
ret
|
250
187
|
end
|
251
188
|
|
252
189
|
# Parses the complex forecast information.
|
253
190
|
def parse_complex_forecast(response)
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
max_temp: f['maxwind']['degrees']
|
289
|
-
}
|
191
|
+
ret = {}
|
192
|
+
|
193
|
+
response['forecast']['simpleforecast']['forecastday'].each do |f|
|
194
|
+
ret[f['period'] - 1] = {
|
195
|
+
high_f: f['high']['fahrenheit'].to_i,
|
196
|
+
high_c: f['high']['celsius'].to_i,
|
197
|
+
low_f: f['low']['fahrenheit'].to_i,
|
198
|
+
low_c: f['low']['celsius'].to_i,
|
199
|
+
conditions: f['conditions'].to_i,
|
200
|
+
snow: {
|
201
|
+
snow_total_in: f['snow_allday']['in'],
|
202
|
+
snow_total_cm: f['snow_allday']['cm'],
|
203
|
+
snow_night_in: f['snow_night']['in'],
|
204
|
+
snow_night_cm: f['snow_night']['cm'],
|
205
|
+
snow_day_in: f['snow_day']['in'],
|
206
|
+
snow_day_cm: f['snow_day']['cm']
|
207
|
+
},
|
208
|
+
quantative_precipitation: {
|
209
|
+
qpf_total_in: f['qpf_allday']['in'],
|
210
|
+
qpf_total_cm: f['qpf_allday']['cm'],
|
211
|
+
qpf_night_in: f['qpf_night']['in'],
|
212
|
+
qpf_night_cm: f['qpf_night']['cm'],
|
213
|
+
qpf_day_in: f['qpf_day']['in'],
|
214
|
+
qpf_day_cm: f['qpf_day']['cm']
|
215
|
+
},
|
216
|
+
wind: {
|
217
|
+
average_mph: f['avewind']['mph'],
|
218
|
+
average_kph: f['avewind']['kph'],
|
219
|
+
average_dir: f['avewind']['dir'],
|
220
|
+
average_temp: f['avewind']['degrees'],
|
221
|
+
max_mph: f['maxwind']['mph'],
|
222
|
+
max_kph: f['maxwind']['kph'],
|
223
|
+
max_dir: f['maxwind']['dir'],
|
224
|
+
max_temp: f['maxwind']['degrees']
|
290
225
|
}
|
291
|
-
|
292
|
-
|
293
|
-
ret
|
294
|
-
else
|
295
|
-
if @verbose_errors
|
296
|
-
return response['response']['error']['description']
|
297
|
-
else
|
298
|
-
return response['response']['error']['type']
|
299
|
-
end
|
226
|
+
}
|
300
227
|
end
|
228
|
+
|
229
|
+
ret
|
301
230
|
end
|
302
231
|
end
|
303
232
|
end
|
data/lib/weather/planner.rb
CHANGED
@@ -183,8 +183,6 @@ module Weather
|
|
183
183
|
# metric and imperial systems.
|
184
184
|
def get_temperatures(start_date, end_date, location)
|
185
185
|
response = get_planner_response(start_date, end_date, location)
|
186
|
-
return response['response']['error'] unless
|
187
|
-
response['response']['error'].nil?
|
188
186
|
highs = response['trip']['temp_high']
|
189
187
|
lows = response['trip']['temp_low']
|
190
188
|
|
@@ -242,7 +240,6 @@ module Weather
|
|
242
240
|
# @return [Fixnum] The chance of the subject happening.
|
243
241
|
def get_chance_of(subject, start_date, end_date, location)
|
244
242
|
response = get_planner_response(start_date, end_date, location)
|
245
|
-
return unless response['response']['error'].nil?
|
246
243
|
|
247
244
|
response['trip']['chance_of'][subject]['percentage'].to_i
|
248
245
|
end
|
data/lib/weatheruby.rb
CHANGED
@@ -2,38 +2,36 @@ require 'httpclient'
|
|
2
2
|
require 'json'
|
3
3
|
require_relative 'weather/actions'
|
4
4
|
require_relative 'weather/planner'
|
5
|
-
require_relative 'weather/exceptions'
|
6
5
|
|
7
6
|
class Weatheruby
|
7
|
+
class WeatherError < StandardError; end
|
8
|
+
|
8
9
|
include Weather::Actions
|
9
10
|
include Weather::Planner
|
10
11
|
|
12
|
+
attr_accessor :language_key
|
13
|
+
|
11
14
|
# Creates a new instance of Weatheruby.
|
12
|
-
# @param api_key [String] Your personal API key obtained on sign up for
|
13
|
-
# Weather Underground.
|
15
|
+
# @param api_key [String] Your personal API key obtained on sign up for Weather Underground.
|
14
16
|
# @param language [String] The language code you would like to use.
|
15
|
-
# @param use_pws [Boolean] Whether to use the Personal Weather Station
|
16
|
-
# feature.
|
17
|
+
# @param use_pws [Boolean] Whether to use the Personal Weather Station feature.
|
17
18
|
# @param use_bestfct [Boolean] Whether to use BestForecast.
|
18
|
-
|
19
|
-
def initialize(api_key, language = 'EN', use_pws = true, use_bestfct = true,
|
20
|
-
verbose_errors = false)
|
19
|
+
def initialize(api_key, language = 'EN', use_pws = true, use_bestfct = true)
|
21
20
|
@api_key = api_key
|
22
21
|
@language_key = language.upcase
|
23
22
|
@use_pws = use_pws ? 1 : 0
|
24
23
|
@use_bestfct = use_bestfct ? 1 : 0
|
25
|
-
@verbose_errors = verbose_errors
|
26
24
|
|
27
25
|
@client = HTTPClient.new
|
28
26
|
end
|
29
27
|
|
30
|
-
# Performs a generic HTTP GET request. This method should generally not be
|
31
|
-
#
|
32
|
-
# action/feature.
|
28
|
+
# Performs a generic HTTP GET request. This method should generally not be used by a standard user, unless there is
|
29
|
+
# not a method for a particular action/feature.
|
33
30
|
# @param feature [String] The "feature" parameter defined by Wunderground.
|
34
31
|
# @param location [String] The location of the query.
|
35
32
|
# @param autoparse [Boolean] Whether to automatically parse the response.
|
36
|
-
# @return [
|
33
|
+
# @return [Hash/HTTPMessage] Parsed JSON if autoparse is true, or raw response if not.
|
34
|
+
# @raise WeatherError if anything goes wrong with the API, or it returns too many results for us to handle.
|
37
35
|
def get(feature, location, autoparse = true)
|
38
36
|
url = "http://api.wunderground.com/api/#{@api_key}/#{feature}/lang:" \
|
39
37
|
"#{@language_key}/pws:#{@use_pws}/bestfct:#{@use_bestfct}/q/" \
|
@@ -42,14 +40,14 @@ class Weatheruby
|
|
42
40
|
uri = URI.parse(url)
|
43
41
|
res = @client.get(uri)
|
44
42
|
json = JSON.parse(res.body)
|
45
|
-
|
46
|
-
fail
|
43
|
+
if json['response'].key?('error')
|
44
|
+
fail(WeatherError, json['response']['error']['type'] + ': ' + json['response']['error']['description'].capitalize)
|
47
45
|
end
|
48
|
-
|
49
|
-
|
50
|
-
return json
|
51
|
-
else
|
52
|
-
return res
|
46
|
+
if json['response'].key?('results')
|
47
|
+
fail(WeatherError, 'toomanyresults: Too many results were returned. Try narrowing your search.')
|
53
48
|
end
|
49
|
+
|
50
|
+
|
51
|
+
autoparse ? json : res
|
54
52
|
end
|
55
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weatheruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Foster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -60,9 +60,9 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- CHANGELOG.md
|
63
|
+
- LICENSE.md
|
63
64
|
- bin/weatheruby
|
64
65
|
- lib/weather/actions.rb
|
65
|
-
- lib/weather/exceptions.rb
|
66
66
|
- lib/weather/planner.rb
|
67
67
|
- lib/weatheruby.rb
|
68
68
|
homepage: https://github.com/elifoster/weatheruby
|