lita-onewheel-forecast-io 1.5.2 → 1.5.3
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/lita/handlers/forecasts.rb +9 -11
- data/lib/lita/handlers/irc_handlers.rb +3 -2
- data/lib/lita/handlers/utils.rb +7 -12
- data/lita-onewheel-forecast-io.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be9b9715b8fce490e1ddb77a560c7b5637d67489
|
4
|
+
data.tar.gz: 90bee01f4c26a3bf41fbcb0080305393ca6f775c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03652e501d24848bf557277bf9917fa943419a148288b31a31df49b602a9cf567942e296b742f18e684a75a6cf3f750925e5a9b0fae4bd7e8943248d91b5c8cd
|
7
|
+
data.tar.gz: 8166bf7b03f938fb856671cbc056835ed689b74527db595938cdf1562a3c4a0417ee212d2a1849d192ec8d191cba8d639f8ae8775a1009b35a33a558378ebbb1
|
@@ -442,14 +442,20 @@ module ForecastIo
|
|
442
442
|
return forecast['currently']['nearestStormDistance'], forecast['currently']['nearestStormBearing']
|
443
443
|
end
|
444
444
|
|
445
|
+
def do_the_today_thing(forecast, yesterday)
|
446
|
+
puts "#{forecast['daily']['data'][0]['temperatureMax']} - #{yesterday['daily']['data'][0]['temperatureMax']}"
|
447
|
+
temp_diff = forecast['daily']['data'][0]['temperatureMax'] - forecast['daily']['data'][0]['temperatureMax']
|
448
|
+
get_daily_comparison_text(temp_diff)
|
449
|
+
end
|
450
|
+
|
445
451
|
def do_the_tomorrow_thing(forecast)
|
446
|
-
#
|
447
|
-
|
448
|
-
# Get tomorrow's rain chance
|
452
|
+
puts "#{forecast['daily']['data'][0]['temperatureMax']} - #{forecast['daily']['data'][1]['temperatureMax']}"
|
453
|
+
forecast['daily']['data'][0]['temperatureMax'] - forecast['daily']['data'][1]['temperatureMax']
|
449
454
|
temp_diff = forecast['daily']['data'][0]['temperatureMax'] - forecast['daily']['data'][1]['temperatureMax']
|
450
455
|
get_daily_comparison_text(temp_diff)
|
451
456
|
end
|
452
457
|
|
458
|
+
# If the temperature difference is positive,
|
453
459
|
def get_daily_comparison_text(temp_diff)
|
454
460
|
if temp_diff <= 1 and temp_diff >= -1
|
455
461
|
'about the same as'
|
@@ -464,14 +470,6 @@ module ForecastIo
|
|
464
470
|
end
|
465
471
|
end
|
466
472
|
|
467
|
-
def do_the_today_thing(forecast)
|
468
|
-
# Get today's high
|
469
|
-
# Get tomorrow's high
|
470
|
-
# Get tomorrow's rain chance
|
471
|
-
temp_diff = forecast['daily']['data'][1]['temperatureMax'] - forecast['daily']['data'][0]['temperatureMax']
|
472
|
-
get_daily_comparison_text(temp_diff)
|
473
|
-
end
|
474
|
-
|
475
473
|
# Check for the time of day when it will hit 72F.
|
476
474
|
def do_the_windows_thing(forecast)
|
477
475
|
time_to_close_the_windows = nil
|
@@ -215,8 +215,9 @@ module ForecastIo
|
|
215
215
|
def handle_irc_today(response)
|
216
216
|
location = geo_lookup(response.user, response.match_data[1])
|
217
217
|
forecast = get_forecast_io_results(response.user, location)
|
218
|
-
|
219
|
-
|
218
|
+
yesterday_weather = get_forecast_io_results(response.user, location, Date.today.prev_day.to_s + 'T00:00:00-0700')
|
219
|
+
today_will_be = do_the_today_thing(forecast, yesterday_weather)
|
220
|
+
response.reply "Today will be #{today_will_be} yesterday."
|
220
221
|
end
|
221
222
|
|
222
223
|
def handle_irc_windows(response)
|
data/lib/lita/handlers/utils.rb
CHANGED
@@ -138,24 +138,19 @@ module ForecastIo
|
|
138
138
|
end
|
139
139
|
|
140
140
|
|
141
|
-
|
141
|
+
# Time should be in the format specified here (subset of 8601)
|
142
|
+
# https://developer.forecast.io/docs/v2#time_call
|
143
|
+
def get_forecast_io_results(user, location, time = nil)
|
142
144
|
if ! config.api_uri or ! config.api_key
|
143
145
|
Lita.logger.error "Configuration missing! '#{config.api_uri}' '#{config.api_key}'"
|
144
146
|
raise StandardError.new('Configuration missing!')
|
145
147
|
end
|
146
148
|
uri = config.api_uri + config.api_key + '/' + "#{location.latitude},#{location.longitude}"
|
147
|
-
|
148
|
-
|
149
|
-
gimme_some_weather uri
|
150
|
-
end
|
151
|
-
|
152
|
-
def get_forecast_io_historical_results(user, location, time)
|
153
|
-
if ! config.api_uri or ! config.api_key
|
154
|
-
Lita.logger.error "Configuration missing! '#{config.api_uri}' '#{config.api_key}'"
|
155
|
-
raise StandardError.new('Configuration missing!')
|
149
|
+
if time
|
150
|
+
uri += ",#{time}"
|
156
151
|
end
|
157
|
-
|
158
|
-
Lita.logger.debug uri
|
152
|
+
|
153
|
+
Lita.logger.debug "Requesting forcast data from: #{uri}"
|
159
154
|
set_scale(user)
|
160
155
|
gimme_some_weather uri
|
161
156
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-forecast-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|