lita-onewheel-forecast-io 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/forecasts.rb +1 -2
- data/lib/lita/handlers/irc_handlers.rb +7 -0
- data/lib/lita/handlers/onewheel_forecast_io.rb +5 -3
- data/lib/lita/handlers/utils.rb +12 -1
- data/lita-onewheel-forecast-io.gemspec +1 -1
- data/spec/lita/handlers/forecast_io_spec.rb +6 -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: 975690706b5d9aa3c3e1018579b6ba7a422ef1b4
|
4
|
+
data.tar.gz: b20a7284dcd11c6aa6559fa5f3edac4bbbc49c07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9517b97db282f46efacf9b04b4b062183fba4f3e464689a571388b46133fcf0c34e4df66539e0c6ad4d3d39ae9af663a34a95cb156d81e2260e30c9bec06498
|
7
|
+
data.tar.gz: c6e8ae02c532a094f79f7747927d8668e232f34539fa3c9b5f7e7ee4cfa8be93b2296dee6c7314ab16c8f21e92a8ef1c66a306eb94f87bb3876498982f1a8b0a
|
@@ -474,10 +474,9 @@ module ForecastIo
|
|
474
474
|
high_temp = hour['temperature'].to_i
|
475
475
|
end
|
476
476
|
|
477
|
-
if hour['temperature'].to_i >= 71
|
477
|
+
if !time_to_close_the_windows and hour['temperature'].to_i >= 71
|
478
478
|
time_to_close_the_windows = hour['time']
|
479
479
|
window_close_temp = hour['temperature']
|
480
|
-
break
|
481
480
|
end
|
482
481
|
if time_to_close_the_windows and hour['temperature'].to_i < 71
|
483
482
|
time_to_open_the_windows = hour['time']
|
@@ -212,6 +212,13 @@ module ForecastIo
|
|
212
212
|
response.reply "Tomorrow will be #{tomorrow_will_be} today."
|
213
213
|
end
|
214
214
|
|
215
|
+
def handle_irc_today(response)
|
216
|
+
location = geo_lookup(response.user, response.match_data[1])
|
217
|
+
forecast = get_forecast_io_results(response.user, location)
|
218
|
+
tomorrow_will_be = do_the_tomorrow_thing(forecast)
|
219
|
+
response.reply "Tomorrow will be #{tomorrow_will_be} today."
|
220
|
+
end
|
221
|
+
|
215
222
|
def handle_irc_windows(response)
|
216
223
|
location = geo_lookup(response.user, response.match_data[1])
|
217
224
|
forecast = get_forecast_io_results(response.user, location)
|
@@ -70,10 +70,12 @@ module Lita
|
|
70
70
|
route(/^neareststorm\s*$/i, :handle_irc_neareststorm, command: true)
|
71
71
|
route(/^neareststorm\s+(.+)$/i, :handle_irc_neareststorm, command: true,
|
72
72
|
help: { '!neareststorm [location]' => 'Nearest storm distance for [location].'})
|
73
|
-
route(/^tomorrow/i, :handle_irc_tomorrow,
|
73
|
+
route(/^tomorrow/i, :handle_irc_tomorrow, command: true,
|
74
74
|
help: { '!tomorrow' => 'Give me tomorrow\'s forecast as it relates to today.'})
|
75
|
-
route(/^
|
76
|
-
|
75
|
+
route(/^today/i, :handle_irc_today, command: true,
|
76
|
+
help: { '!today' => 'Give me today\'s forecast as it relates to yesterday.'})
|
77
|
+
route(/^windows/i, :handle_irc_windows, command: true)
|
78
|
+
route(/^windows\s+(.+)/i, :handle_irc_windows, command: true,
|
77
79
|
help: { '!windows' => 'Tell me when to close my windows as it\'s warmer outside than in.'})
|
78
80
|
|
79
81
|
# State Commands
|
data/lib/lita/handlers/utils.rb
CHANGED
@@ -162,7 +162,18 @@ module ForecastIo
|
|
162
162
|
uri = config.api_uri + config.api_key + '/' + "#{location.latitude},#{location.longitude}"
|
163
163
|
Lita.logger.debug uri
|
164
164
|
set_scale(user)
|
165
|
-
|
165
|
+
gimme_some_weather uri
|
166
|
+
end
|
167
|
+
|
168
|
+
def get_forecast_io_historical_results(user, location, time)
|
169
|
+
if ! config.api_uri or ! config.api_key
|
170
|
+
Lita.logger.error "Configuration missing! '#{config.api_uri}' '#{config.api_key}'"
|
171
|
+
raise StandardError.new('Configuration missing!')
|
172
|
+
end
|
173
|
+
uri = config.api_uri + config.api_key + '/' + "#{location.latitude},#{location.longitude},#{time}"
|
174
|
+
Lita.logger.debug uri
|
175
|
+
set_scale(user)
|
176
|
+
gimme_some_weather uri
|
166
177
|
end
|
167
178
|
|
168
179
|
def handle_geo_lookup(response)
|
@@ -513,7 +513,7 @@ describe Lita::Handlers::OnewheelForecastIo, lita_handler: true do
|
|
513
513
|
it '!windows' do
|
514
514
|
mock_up 'windows'
|
515
515
|
send_command 'windows'
|
516
|
-
expect(replies.last).to eq('Close the windows at 16:00, it will be 72°F. The high today will be 72°F.')
|
516
|
+
expect(replies.last).to eq('Close the windows at 16:00, it will be 72°F. Open them back up at 16:00. The high today will be 72°F.')
|
517
517
|
end
|
518
518
|
|
519
519
|
it 'will not say a 28.000000000000004% chance of rain' do
|
@@ -522,6 +522,11 @@ describe Lita::Handlers::OnewheelForecastIo, lita_handler: true do
|
|
522
522
|
expect(replies.last).to eq("Portland, OR 48 hr rains |\u000302▁_▁\u000306▃▃▃\u000310▅\u000302▁_▁▁\u000306▃\u000302▁\u000310▃\u000306▃\u000310▅\u000306▃\u000302▁▁▁▁▁▁__________________________\u0003| max 28%")
|
523
523
|
end
|
524
524
|
|
525
|
+
# it 'will summarize !today in relation to yesterday' do
|
526
|
+
# send_command 'today'
|
527
|
+
# expect(replies.last).to eq('Today will be whatever')
|
528
|
+
# end
|
529
|
+
|
525
530
|
# it 'colors strings' do
|
526
531
|
# cstr = Lita::Handlers::ForecastIo.get_colored_string([{:key => 1}], :key, 'x', {1 => :blue})
|
527
532
|
# expect(cstr).to equal('x')
|
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.4.
|
4
|
+
version: 1.4.1
|
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-07-
|
11
|
+
date: 2016-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|