lita-onewheel-forecast-io 1.6.7 → 1.8.0

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
  SHA256:
3
- metadata.gz: d5a9230e0b42827da185a7d6223dccd836e1402ee10b4f97b5f10c02aa445d67
4
- data.tar.gz: 5b9d042e3e85125ac159192687a06e7e593e5cfa83c874b63cf8ef556cc8215f
3
+ metadata.gz: 27b3ba92a9a63fb6741defc9fa4f9bf9ef5c0660f215910b3346040fb930abcd
4
+ data.tar.gz: ed5d1300563a6a2dd7801325aaf26b307b5e05293b93986a4188d81504591466
5
5
  SHA512:
6
- metadata.gz: 7ab819dfaa20a8ec3bfe73c8c23c09e46ec0ffb9f0b54f48e81560334ebaaeb781669af0b8d8bd52c59a044734e66777e068b5332c46c2bdd8ad9696bc3a2be4
7
- data.tar.gz: fd5a6a32285049b803c005f43da49a7eb022cd3a24d753df0bb9409ed1df4496acc487a574b4a56a342b15e6cded04239b38e45be6d557f88eb37ee3923f451a
6
+ metadata.gz: 9aeb956474f7f6835b577c4534656c7678abcbfe2ab8e83adb7fe9ead172fb4b070a120619036cd09e6da0ac9744ad275a725db7b67ebb35abf4361e48e635db
7
+ data.tar.gz: 79fa111425384b543b32e3605cf28b13ee5be779b899684a9e64b6bba350121d12e87a5dae6fccb50a106909938a9c080b56efce0c73db8403822267dc4d31e7
@@ -139,7 +139,20 @@ module ForecastIo
139
139
  # }
140
140
  # end
141
141
 
142
- # End constants
143
-
142
+ def get_uvindex_colors
143
+ { 0..0 => :black,
144
+ 1..1 => :royal,
145
+ 2..2 => :brown,
146
+ 3..3 => :purple,
147
+ 4..4 => :green,
148
+ 5..5 => :lime,
149
+ 6..6 => :red,
150
+ 7..7 => :orange,
151
+ 8..8 => :yellow,
152
+ 9..9 => :aqua,
153
+ 10..10 => :pink,
154
+ 11..11 => :white
155
+ }
156
+ end
144
157
  end
145
158
  end
@@ -132,6 +132,11 @@ module ForecastIo
132
132
  "#{hours} hr temps: #{get_temperature temperature_data.first.round(1)} |#{str}| #{get_temperature temperature_data.last.round(1)} Range: #{get_temperature temperature_data.min.round(1)} - #{get_temperature temperature_data.max.round(1)}"
133
133
  end
134
134
 
135
+ def ansi_windchill_forecast(forecast, hours = 24)
136
+ str, temperature_data = do_the_windchill_temp_thing(forecast, ansi_chars, hours)
137
+ "#{hours} hr windchill temps: #{get_temperature temperature_data.first.round(1)} |#{str}| #{get_temperature temperature_data.last.round(1)} Range: #{get_temperature temperature_data.min.round(1)} - #{get_temperature temperature_data.max.round(1)}"
138
+ end
139
+
135
140
  def ascii_temp_forecast(forecast, hours = 24)
136
141
  str, temperature_data = do_the_temp_thing(forecast, ascii_chars, hours)
137
142
  "#{hours} hr temps: #{get_temperature temperature_data.first.round(1)} |#{str}| #{get_temperature temperature_data.last.round(1)} Range: #{get_temperature temperature_data.min.round(1)} - #{get_temperature temperature_data.max.round(1)}"
@@ -159,14 +164,43 @@ module ForecastIo
159
164
  return dot_str, temps
160
165
  end
161
166
 
167
+ def do_the_windchill_temp_thing(forecast, chars, hours)
168
+ temps = []
169
+ wind = []
170
+ data = forecast['hourly']['data'].slice(0,hours - 1)
171
+ key = 'temperature'
172
+ wind_key = 'windSpeed'
173
+
174
+ data.each_with_index do |datum, index|
175
+ temps.push calculate_windchill(datum[key], datum[wind_key])
176
+ break if index == hours - 1 # We only want (hours) 24hrs of data.
177
+ end
178
+
179
+ differential = temps.max - temps.min
180
+
181
+ # Hmm. There's a better way.
182
+ dot_str = get_dot_str(chars, data, temps.min, differential, key)
183
+
184
+ if config.colors
185
+ dot_str = get_colored_string(data, key, dot_str, get_temp_range_colors)
186
+ end
187
+
188
+ return dot_str, temps
189
+ end
190
+
191
+ # Temp must be F.
192
+ def calculate_windchill(temp, wind)
193
+ 35.74 + (0.6215 * temp) - (35.75 * wind ** 0.16) + (0.4275 * temp * wind ** 0.16)
194
+ end
195
+
162
196
  def ansi_wind_direction_forecast(forecast)
163
- str, data = do_the_wind_direction_thing(forecast, ansi_wind_arrows)
164
- "48h wind direction #{get_speed data.first}|#{str}|#{get_speed data.last} Range: #{get_speed(data.min)} - #{get_speed(data.max)}"
197
+ str, wind_speed, wind_gust = do_the_wind_direction_thing(forecast, ansi_wind_arrows)
198
+ "48h wind direction #{get_speed wind_speed.first}|#{str}|#{get_speed wind_speed.last} Range: #{get_speed(wind_speed.min)} - #{get_speed(wind_speed.max)}, gusting to #{get_speed wind_gust.max}"
165
199
  end
166
200
 
167
201
  def ascii_wind_direction_forecast(forecast)
168
- str, data = do_the_wind_direction_thing(forecast, ascii_wind_arrows)
169
- "48h wind direction #{get_speed data.first}|#{str}|#{get_speed data.last} Range: #{get_speed(data.min)} - #{get_speed(data.max)}"
202
+ str, wind_speed, wind_gust = do_the_wind_direction_thing(forecast, ascii_wind_arrows)
203
+ "48h wind direction #{get_speed wind_speed.first}|#{str}|#{get_speed wind_speed.last} Range: #{get_speed(wind_speed.min)} - #{get_speed(wind_speed.max)}, gusting to #{get_speed wind_gust.max}"
170
204
  end
171
205
 
172
206
  def do_the_wind_direction_thing(forecast, wind_arrows, hours = 48)
@@ -174,11 +208,13 @@ module ForecastIo
174
208
  data = forecast['hourly']['data'].slice(0,hours - 1)
175
209
  str = ''
176
210
  data_points = []
211
+ gust_data = []
177
212
 
178
213
  data.each_with_index do |datum, index|
179
214
  wind_arrow_index = get_cardinal_direction_from_bearing(datum[key])
180
215
  str << wind_arrows[wind_arrow_index].to_s
181
216
  data_points.push datum['windSpeed']
217
+ gust_data.push datum['windGust']
182
218
  break if index == hours - 1 # We only want (hours) of data.
183
219
  end
184
220
 
@@ -186,7 +222,7 @@ module ForecastIo
186
222
  str = get_colored_string(data, 'windSpeed', str, get_wind_range_colors)
187
223
  end
188
224
 
189
- return str, data_points
225
+ return str, data_points, gust_data
190
226
  end
191
227
 
192
228
  def do_the_sun_thing(forecast, chars)
@@ -579,5 +615,21 @@ module ForecastIo
579
615
  }
580
616
  end
581
617
  end
618
+
619
+ def do_the_uvindex_thing(forecast)
620
+ uvs = []
621
+ forecast['hourly']['data'].each do |hour|
622
+ uvs.push hour['uvIndex']
623
+ end
624
+
625
+ data = forecast['hourly']['data']
626
+ str = get_dot_str(ansi_chars, data, uvs.min, uvs.max - uvs.min, key = 'uvIndex')
627
+
628
+ if config.colors
629
+ str = get_colored_string(data, 'uvIndex', str, get_uvindex_colors)
630
+ end
631
+
632
+ "#{uvs.first} |#{str}| #{uvs.last} max: #{uvs.max}"
633
+ end
582
634
  end
583
635
  end
@@ -45,6 +45,12 @@ module ForecastIo
45
45
  response.reply location.location_name + ' ' + ansi_temp_forecast(forecast)
46
46
  end
47
47
 
48
+ def handle_irc_ansiwindchill(response)
49
+ location = geo_lookup(response.user, response.match_data[1])
50
+ forecast = get_forecast_io_results(response.user, location)
51
+ response.reply location.location_name + ' ' + ansi_windchill_forecast(forecast)
52
+ end
53
+
48
54
  def handle_irc_ieeetemp(response)
49
55
  @scale = 'k'
50
56
  location = geo_lookup(response.user, response.match_data[1])
@@ -235,5 +241,13 @@ module ForecastIo
235
241
  windows_data = do_the_windows_data_thing(forecast)
236
242
  response.write windows_data.to_json
237
243
  end
244
+
245
+ def handle_irc_uvindex(response)
246
+ location = geo_lookup(response.user, response.match_data[1])
247
+ forecast = get_forecast_io_results(response.user, location)
248
+ str = do_the_uvindex_thing(forecast)
249
+ response.reply "UV Index for #{location.location_name} #{str} [48h forecast]"
250
+ end
251
+
238
252
  end
239
253
  end
@@ -82,6 +82,15 @@ module Lita
82
82
  route(/^windows\s+(.+)/i, :handle_irc_windows, command: true,
83
83
  help: { '!windows' => 'Tell me when to close my windows as it\'s warmer outside than in.'})
84
84
 
85
+ # SUN
86
+ route(/^uv$/i, :handle_irc_uvindex, command: true)
87
+ route(/^uv\s+(.+)$/i, :handle_irc_uvindex, command: true)
88
+ route(/^uvindex$/i, :handle_irc_uvindex, command: true)
89
+ route(/^uvindex\s+(.*)$/i, :handle_irc_uvindex, command: true)
90
+ route(/^ansiuvindex\s*(.*)$/i, :handle_irc_uvindex, command: true)
91
+ route(/^ansiuv\s*(.*)$/i, :handle_irc_uvindex, command: true,
92
+ help: { '!ansiuv' => 'Display the UV index forecast.' })
93
+
85
94
  # State Commands
86
95
  route(/^set scale (c|f|k)/i, :handle_irc_set_scale, command: true,
87
96
  help: { '!set scale [c|f|k]' => 'Set the scale to your chosen degrees.'})
@@ -148,6 +157,9 @@ module Lita
148
157
  route(/^ansiwind\s*$/i, :handle_irc_ansiwind, command: true)
149
158
  route(/^ansiwind\s+(.+)/i, :handle_irc_ansiwind, command: true,
150
159
  help: { '!ansiwind [location]' => '24h wind speed/direction report for [location].'})
160
+ route(/^ansiwindchill\s*$/i, :handle_irc_ansiwindchill, command: true)
161
+ route(/^ansiwindchill\s+(.+)/i, :handle_irc_ansiwindchill, command: true,
162
+ help: { '!ansiwindchill [location]' => '24h windchill temp report for [location].'})
151
163
  route(/^asciiwind\s*$/i, :handle_irc_ascii_wind, command: true)
152
164
  route(/^asciiwind\s+(.+)/i, :handle_irc_ascii_wind, command: true,
153
165
  help: { '!asciiwind [location]' => '24h wind speed/direction report for [location], ascii style.'})
@@ -1,7 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-forecast-io'
3
- spec.version = '1.6.7
4
- '
3
+ spec.version = '1.8.0'
5
4
  spec.authors = ['Andrew Kreps']
6
5
  spec.email = ['andrew.kreps@gmail.com']
7
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.6.7
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-26 00:00:00.000000000 Z
11
+ date: 2019-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  - !ruby/object:Gem::Version
235
235
  version: '0'
236
236
  requirements: []
237
- rubygems_version: 3.0.3
237
+ rubygems_version: 3.0.1
238
238
  signing_key:
239
239
  specification_version: 4
240
240
  summary: A text-based interactive query engine for http://forecast.io's api.