lita-onewheel-forecast-io 1.5.3 → 1.5.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5de999ecf7eab4972f6ffac59cfd84ebc75b9f2
|
4
|
+
data.tar.gz: 953b14b5cc7f6f555642fa4294d819d9f637684b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb666d69b07b7c87a2fcc4ed324d641f1833384326763ca532e50b68a18d272b0bd640bb0779bd89856f12cbb4ca72ac58ee771827189a9925330afe6eaae835
|
7
|
+
data.tar.gz: f6c27dd79b87aeb0cabf3743a263833d7c216d128949c7cd25ca79789f70ac4dd93842e9f73c504b3a17831dfb57c363aa7d093c82e6461ab3df40745b7aa286
|
@@ -520,5 +520,60 @@ module ForecastIo
|
|
520
520
|
output += "The high today will be #{get_temperature high_temp}."
|
521
521
|
end
|
522
522
|
end
|
523
|
+
|
524
|
+
def do_the_windows_data_thing(forecast)
|
525
|
+
time_to_close_the_windows = nil
|
526
|
+
time_to_open_the_windows = nil
|
527
|
+
window_close_temp = 0
|
528
|
+
high_temp = 0
|
529
|
+
last_temp = 0
|
530
|
+
|
531
|
+
forecast['hourly']['data'].each_with_index do |hour, index|
|
532
|
+
if hour['temperature'] > high_temp
|
533
|
+
high_temp = hour['temperature'].to_i
|
534
|
+
end
|
535
|
+
|
536
|
+
if !time_to_close_the_windows and hour['temperature'].to_i >= 71
|
537
|
+
if index == 0
|
538
|
+
time_to_close_the_windows = 'now'
|
539
|
+
else
|
540
|
+
time_to_close_the_windows = hour['time']
|
541
|
+
end
|
542
|
+
window_close_temp = hour['temperature']
|
543
|
+
end
|
544
|
+
|
545
|
+
if !time_to_open_the_windows and time_to_close_the_windows and hour['temperature'] < last_temp and hour['temperature'].to_i <= 75
|
546
|
+
time_to_open_the_windows = hour['time']
|
547
|
+
end
|
548
|
+
|
549
|
+
last_temp = hour['temperature']
|
550
|
+
break if index > 18
|
551
|
+
end
|
552
|
+
|
553
|
+
# Return some meta here and let the caller decide the text.
|
554
|
+
if time_to_close_the_windows.nil?
|
555
|
+
"Leave 'em open, no excess heat today(#{get_temperature high_temp})."
|
556
|
+
else
|
557
|
+
# Todo: base timezone on requested location.
|
558
|
+
timezone = TZInfo::Timezone.get('America/Los_Angeles')
|
559
|
+
if time_to_close_the_windows == 'now'
|
560
|
+
output = "Close the windows now! It is #{get_temperature window_close_temp}. "
|
561
|
+
else
|
562
|
+
time_at = Time.at(time_to_close_the_windows).to_datetime
|
563
|
+
local_time = timezone.utc_to_local(time_at)
|
564
|
+
output = "Close the windows at #{local_time.strftime('%k:%M')}, it will be #{get_temperature window_close_temp}. "
|
565
|
+
end
|
566
|
+
if time_to_open_the_windows
|
567
|
+
open_time = timezone.utc_to_local(Time.at(time_to_open_the_windows).to_datetime)
|
568
|
+
output += "Open them back up at #{open_time.strftime('%k:%M')}. "
|
569
|
+
end
|
570
|
+
output += "The high today will be #{get_temperature high_temp}."
|
571
|
+
datas = { 'timeToClose': local_time,
|
572
|
+
'timeToOpen': open_time,
|
573
|
+
'tempMax': high_temp,
|
574
|
+
'temp': window_close_temp
|
575
|
+
}
|
576
|
+
end
|
577
|
+
end
|
523
578
|
end
|
524
579
|
end
|
@@ -214,7 +214,7 @@ module ForecastIo
|
|
214
214
|
|
215
215
|
def handle_irc_today(response)
|
216
216
|
location = geo_lookup(response.user, response.match_data[1])
|
217
|
-
forecast = get_forecast_io_results(response.user, location)
|
217
|
+
forecast = get_forecast_io_results(response.user, location, Date.today.to_s + 'T00:00:00-0700')
|
218
218
|
yesterday_weather = get_forecast_io_results(response.user, location, Date.today.prev_day.to_s + 'T00:00:00-0700')
|
219
219
|
today_will_be = do_the_today_thing(forecast, yesterday_weather)
|
220
220
|
response.reply "Today will be #{today_will_be} yesterday."
|
@@ -226,5 +226,12 @@ module ForecastIo
|
|
226
226
|
windows_time = do_the_windows_thing(forecast)
|
227
227
|
response.reply "#{windows_time}"
|
228
228
|
end
|
229
|
+
|
230
|
+
def handle_http_windows(response)
|
231
|
+
location = geo_lookup(response.user, '97232')
|
232
|
+
forecast = get_forecast_io_results(response.user, location)
|
233
|
+
windows_data = do_the_windows_thing(forecast)
|
234
|
+
response.reply windows_data.to_json
|
235
|
+
end
|
229
236
|
end
|
230
237
|
end
|
@@ -75,7 +75,8 @@ module Lita
|
|
75
75
|
help: { '!tomorrow' => 'Give me tomorrow\'s forecast as it relates to today.'})
|
76
76
|
route(/^today/i, :handle_irc_today, command: true,
|
77
77
|
help: { '!today' => 'Give me today\'s forecast as it relates to yesterday.'})
|
78
|
-
route(/^Good morning./, :handle_irc_windows) # Easter egg alert. Thank you, zrobo and donpdonp.
|
78
|
+
# route(/^Good morning./, :handle_irc_windows) # Easter egg alert. Thank you, zrobo and donpdonp.
|
79
|
+
# Disabled for winter.
|
79
80
|
route(/^windows/i, :handle_irc_windows, command: true)
|
80
81
|
route(/^windows\s+(.+)/i, :handle_irc_windows, command: true,
|
81
82
|
help: { '!windows' => 'Tell me when to close my windows as it\'s warmer outside than in.'})
|
@@ -180,6 +181,7 @@ module Lita
|
|
180
181
|
route(/^dailybarometer\s+(.+)/i, :handle_irc_daily_pressure, command: true,
|
181
182
|
help: { '!dailybarometer [location]' => 'Alias for !dailypressure.'})
|
182
183
|
|
184
|
+
http.get '/windows', :handle_http_windows
|
183
185
|
end
|
184
186
|
|
185
187
|
Lita.register_handler(OnewheelForecastIo)
|
@@ -529,21 +529,21 @@ describe Lita::Handlers::OnewheelForecastIo, lita_handler: true do
|
|
529
529
|
expect(replies.last).to eq("Portland, OR, USA 48 hr rains |\u000302▁_▁\u000306▃▃▃\u000310▅\u000302▁_▁▁\u000306▃\u000302▁\u000310▃\u000306▃\u000310▅\u000306▃\u000302▁▁▁▁▁▁__________________________\u0003| max 28%")
|
530
530
|
end
|
531
531
|
|
532
|
-
it 'will return windows for good morning' do
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
end
|
537
|
-
|
538
|
-
it 'will return windows for good morning' do
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
end
|
543
|
-
|
532
|
+
# it 'will return windows for good morning' do
|
533
|
+
# mock_up 'windows'
|
534
|
+
# send_message 'Good morning.'
|
535
|
+
# expect(replies.last).to eq('Close the windows at 16:00, it will be 72°F. Open them back up at 17:00. The high today will be 72°F.')
|
536
|
+
# end
|
537
|
+
#
|
538
|
+
# it 'will return windows for good morning' do
|
539
|
+
# mock_up 'windows'
|
540
|
+
# send_message 'good morning!'
|
541
|
+
# expect(replies.last).to eq(nil)
|
542
|
+
# end
|
543
|
+
#
|
544
544
|
it 'will summarize !today in relation to yesterday' do
|
545
545
|
send_command 'today'
|
546
|
-
expect(replies.last).to eq('Today will be
|
546
|
+
expect(replies.last).to eq('Today will be about the same as yesterday.')
|
547
547
|
end
|
548
548
|
|
549
549
|
# it 'colors strings' do
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -235,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
235
|
version: '0'
|
236
236
|
requirements: []
|
237
237
|
rubyforge_project:
|
238
|
-
rubygems_version: 2.5.
|
238
|
+
rubygems_version: 2.5.2
|
239
239
|
signing_key:
|
240
240
|
specification_version: 4
|
241
241
|
summary: A text-based interactive query engine for http://forecast.io's api.
|