lita-onewheel-forecast-io 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6306585bcd405d2a55a7d681a5a4b0eaa6bb1fd1
4
- data.tar.gz: 021fe05f724fdbe51e593630e41128cf05b47aab
3
+ metadata.gz: be9b9715b8fce490e1ddb77a560c7b5637d67489
4
+ data.tar.gz: 90bee01f4c26a3bf41fbcb0080305393ca6f775c
5
5
  SHA512:
6
- metadata.gz: 9d1405a61301b1ab37f853ae788daebc9fca980ef393b4fcb5b6db94c6b79e86d551049651a6b517ea49b5cc28e62f4831ae7f90ec5fa607d3d68d2954c65b6b
7
- data.tar.gz: dc1cd1b647dea6288c25f9af39297530d39cbe472add185547d823bfdc0d2bc59fa427009a628de112e02d058508ee20a2e5c36156c91f4856a5246a12792805
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
- # Get today's high
447
- # Get tomorrow's high
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
- toay_will_be = do_the_today_thing(forecast)
219
- response.reply "Today will be #{toay_will_be} yesterday."
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)
@@ -138,24 +138,19 @@ module ForecastIo
138
138
  end
139
139
 
140
140
 
141
- def get_forecast_io_results(user, location)
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
- Lita.logger.debug uri
148
- set_scale(user)
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
- uri = config.api_uri + config.api_key + '/' + "#{location.latitude},#{location.longitude},#{time}"
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-forecast-io'
3
- spec.version = '1.5.2'
3
+ spec.version = '1.5.3'
4
4
  spec.authors = ['Andrew Kreps']
5
5
  spec.email = ['andrew.kreps@gmail.com']
6
6
  spec.description = <<-EOS
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.2
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-08-30 00:00:00.000000000 Z
11
+ date: 2016-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita