lita-onewheel-forecast-io 1.3.7 → 1.3.8
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 +20 -2
- data/lita-onewheel-forecast-io.gemspec +1 -1
- data/spec/lita/handlers/forecast_io_spec.rb +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: 35a5283b84b36ad962b9a0537486ff0b1056c1d6
|
4
|
+
data.tar.gz: 6ca1e7906fa126062041d0dbb5375f0f9bff64b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99f07dc8324c928428c9228ceb3a4ccdeaf2259565f53c93377559a835aecb82cef7c89ebc0ee5607ab1d7ffeef70bf14c917554ac03582bb81a924b4612eb7b
|
7
|
+
data.tar.gz: a204cbfb03fbc8e22d87f097eea9f85112090275f40cd87e19bc227105d0fb9877194b08c221ed0e399fe0025b1a67ccb9b9304d2f24bc61872782ee48adbb93
|
@@ -463,26 +463,44 @@ module ForecastIo
|
|
463
463
|
# Check for the time of day when it will hit 72F.
|
464
464
|
def do_the_windows_thing(forecast)
|
465
465
|
time_to_close_the_windows = nil
|
466
|
+
time_to_open_the_windows = nil
|
467
|
+
window_close_temp = 0
|
468
|
+
high_temp = 0
|
469
|
+
|
466
470
|
forecast['hourly']['data'].each_with_index do |hour, index|
|
467
471
|
tm = Time.at(hour['time']).to_datetime.strftime('%k:%M')
|
468
472
|
puts "#{hour['time']} - #{tm} - #{hour['temperature']}"
|
473
|
+
|
474
|
+
if hour['temperature'].to_i > high_temp
|
475
|
+
high_temp = hour['temperature'].to_i
|
476
|
+
end
|
477
|
+
|
469
478
|
if hour['temperature'].to_i >= 71
|
470
479
|
puts "Setting close time to #{hour['time']}"
|
471
480
|
time_to_close_the_windows = hour['time']
|
481
|
+
window_close_temp = hour['temperature']
|
472
482
|
break
|
473
483
|
end
|
484
|
+
if time_to_close_the_windows and hour['temperature'].to_i < 71
|
485
|
+
time_to_open_the_windows = hour['time']
|
486
|
+
end
|
474
487
|
break if index > 12
|
475
488
|
end
|
476
489
|
|
477
490
|
# Return some meta here and let the caller decide the text.
|
478
491
|
if time_to_close_the_windows.nil?
|
479
|
-
"Leave 'em open, no excess heat today."
|
492
|
+
"Leave 'em open, no excess heat today(#{high_temp}°F)."
|
480
493
|
else
|
481
494
|
timezone = TZInfo::Timezone.get('America/Los_Angeles')
|
482
495
|
time_at = Time.at(time_to_close_the_windows).to_datetime
|
483
496
|
local_time = timezone.utc_to_local(time_at)
|
484
497
|
|
485
|
-
"Close the windows at #{local_time.strftime('%k:%M')}."
|
498
|
+
output = "Close the windows at #{local_time.strftime('%k:%M')}, it will be #{window_close_temp}°F. "
|
499
|
+
if time_to_open_the_windows
|
500
|
+
open_time = timezone.utc_to_local(Time.at(time_to_close_the_windows).to_datetime)
|
501
|
+
output += "Open them back up at #{open_time.strftime('%k:%M')}. "
|
502
|
+
end
|
503
|
+
output += "The high today will be #{high_temp}°F."
|
486
504
|
end
|
487
505
|
end
|
488
506
|
end
|
@@ -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.')
|
516
|
+
expect(replies.last).to eq('Close the windows at 16:00, it will be 72°F. The high today will be 72°F.')
|
517
517
|
end
|
518
518
|
|
519
519
|
# 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.3.
|
4
|
+
version: 1.3.8
|
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-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|