lita-onewheel-forecast-io 0.0.1 → 0.0.2

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: 4a1c34227a6fba45ea412b5129bcca4e12c7c090
4
- data.tar.gz: d6e8c875355d3745874ddaa8a10e8354039e363c
3
+ metadata.gz: 652831a8d7d2944da66760e78e268a05c9d01307
4
+ data.tar.gz: 173d18d0debb9c6c9eb0084bcdb081020c93451e
5
5
  SHA512:
6
- metadata.gz: 61516507de3ce242843086104524b69e38885b7e2f482e02da40a6a9c02a92021c0c00ed5ec62bc6e6cd4b20305752d9486a7d8ecc50080c669b9bc1c5a5af74
7
- data.tar.gz: fa6b2118a9c058a0cc3e6d164ddaf098661b1b76fa700f75a728659116441f176de1d80132cdb3a438ff1386754fd3b28f9b1fc79504463d0dc6722aeb837a19
6
+ metadata.gz: aa904c04014dcb42c0de301403dbe678c4b6315d48a484634588f0e3e52ca2a947ad9b0833e07605babfb9abaa24aedf4c1803a37e543b23851cbeb0894c13c5
7
+ data.tar.gz: a5e0d302490c148b207fceda6888a51ace6382f2cabef515a6ac554c4d494485ca84fa1d7a2ed24707923ca627ec165c35dc1930e706b5d195c529be4bcb0a39
@@ -190,7 +190,7 @@ module ForecastIo
190
190
  def do_the_sun_thing(forecast, chars)
191
191
  key = 'cloudCover'
192
192
  data_points = []
193
- data = forecast['daily']['data']
193
+ data = forecast['hourly']['data']
194
194
 
195
195
  data.each do |datum|
196
196
  data_points.push (1 - datum[key]).to_f # It's a cloud cover percentage, so let's inverse it to give us sun cover.
@@ -207,6 +207,29 @@ module ForecastIo
207
207
 
208
208
  max = 1 - get_min_by_data_key(forecast, 'hourly', key)
209
209
 
210
+ "48hr sun forecast |#{str}| max #{(max * 100).to_i}%"
211
+ end
212
+
213
+ def do_the_daily_sun_thing(forecast, chars)
214
+ key = 'cloudCover'
215
+ data_points = []
216
+ data = forecast['daily']['data']
217
+
218
+ data.each do |datum|
219
+ data_points.push (1 - datum[key]).to_f # It's a cloud cover percentage, so let's inverse it to give us sun cover.
220
+ datum[key] = (1 - datum[key]).to_f # Mod the source data for the get_dot_str call below.
221
+ end
222
+
223
+ differential = data_points.max - data_points.min
224
+
225
+ str = get_dot_str(chars, data, data_points.min, differential, key)
226
+
227
+ if config.colors
228
+ str = get_colored_string(data, key, str, get_sun_range_colors)
229
+ end
230
+
231
+ max = 1 - get_min_by_data_key(forecast, 'daily', key)
232
+
210
233
  "8 day sun forecast |#{str}| max #{(max * 100).to_i}%"
211
234
  end
212
235
 
@@ -87,6 +87,12 @@ module ForecastIo
87
87
  response.reply location.location_name + ' ' + do_the_sun_thing(forecast, ansi_chars)
88
88
  end
89
89
 
90
+ def handle_irc_dailysun(response)
91
+ location = geo_lookup(response.user, response.match_data[1])
92
+ forecast = get_forecast_io_results(response.user, location)
93
+ response.reply location.location_name + ' ' + do_the_daily_sun_thing(forecast, ansi_chars)
94
+ end
95
+
90
96
  def handle_irc_asciisun(response)
91
97
  location = geo_lookup(response.user, response.match_data[1])
92
98
  forecast = get_forecast_io_results(response.user, location)
@@ -120,6 +120,9 @@ module Lita
120
120
  help: { '!sunset [location]' => 'Get today\'s sunset time for [location].'})
121
121
  route(/^ansisun\s*$/i, :handle_irc_ansisun)
122
122
  route(/^ansisun\s+(.+)/i, :handle_irc_ansisun,
123
+ help: { '!ansisun [location]' => '48 hour chance-of-sun report for [location].'})
124
+ route(/^dailysun\s*$/i, :handle_irc_dailysun)
125
+ route(/^dailysun\s+(.+)/i, :handle_irc_dailysun,
123
126
  help: { '!ansisun [location]' => '7 day chance-of-sun report for [location].'})
124
127
  route(/^asciisun\s*$/i, :handle_irc_asciisun)
125
128
  route(/^asciisun\s+(.+)/i, :handle_irc_asciisun,
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-forecast-io'
3
- spec.version = '0.0.1'
3
+ spec.version = '0.0.2'
4
4
  spec.authors = ['Andrew Kreps']
5
5
  spec.email = ['andrew.kreps@gmail.com']
6
6
  spec.description = <<-EOS
@@ -30,6 +30,7 @@ describe Lita::Handlers::OnewheelForecastIo, lita_handler: true do
30
30
  it { is_expected.to route('ansiwind') }
31
31
  it { is_expected.to route('asciiwind') }
32
32
  it { is_expected.to route('ansisun') }
33
+ it { is_expected.to route('dailysun') }
33
34
  it { is_expected.to route('asciisun') }
34
35
  it { is_expected.to route('asciicloud') }
35
36
  it { is_expected.to route('ansicloud') }
@@ -185,12 +186,17 @@ describe Lita::Handlers::OnewheelForecastIo, lita_handler: true do
185
186
 
186
187
  it '!ansisun' do
187
188
  send_message 'ansisun'
188
- expect(replies.last).to eq("Portland, OR 8 day sun forecast |\u000308█\u000309▃\u000308▇\u000309▁_\u000307▅\u000309▃\u000307▅\u0003| max 100%")
189
+ expect(replies.last).to eq("Portland, OR 48hr sun forecast |\u000308████████████████████\u000307▇▇▅\u000309▅▅▃\u000303▁_▁\u000309▃▃▃\u000303▁▁▁▁▃\u000309▃▅\u000307▇▇▇▇\u000308▇▇▇▇▇▇\u0003| max 88%")
190
+ end
191
+
192
+ it '!dailysun' do
193
+ send_message 'dailysun'
194
+ expect(replies.last).to eq("Portland, OR 8 day sun forecast |\u000308█\u000309▃\u000308▇\u000309▁_\u000307▅\u000309▃\u000307▅\u0003| max 76%")
189
195
  end
190
196
 
191
197
  it '!asciisun' do
192
198
  send_message 'asciisun'
193
- expect(replies.last).to eq("Portland, OR 8 day sun forecast |\u000308'\u000309-\u000308*\u000309._\u000307~\u000309-\u000307~\u0003| max 100%")
199
+ expect(replies.last).to eq("Portland, OR 48hr sun forecast |\u000308''''''''''''''''''''\u000307**~\u000309~~-\u000303._.\u000309---\u000303....-\u000309-~\u000307****\u000308******\u0003| max 88%")
194
200
  end
195
201
 
196
202
  it '!ansicloud' do
@@ -331,8 +337,8 @@ describe Lita::Handlers::OnewheelForecastIo, lita_handler: true do
331
337
  expect(replies[2]).to include("|\u000302_\u000313▅\u000310▁\u000303▃\u000309▃\u000311▃\u000308▅\u000307▅\u000304▅\u000313▅\u000302___________________________________________________\u0003|")
332
338
  expect(replies[3]).to eq("Portland, OR 24 hr temps: 28.3°F |\u000306_▁▃\u000310▅▇█\u000303██\u000310██▇▅\u000306▅▃▃▃▃▃▃▁▁▁▁\u0003| 28.4°F Range: 28.3°F - 39.0°F")
333
339
  expect(replies[4]).to eq("Portland, OR 48h wind direction 4.3 mph|\u000306↓\u000310↙←\u000311↖↑↗\u000308→↘\u000311↓←←←←←←\u000310←←←←←←←\u000306←←←←←\u000302←←←↙↙↙↙↓↓↓\u000306↓↓↓↓↓↓↓↓↙↙\u0003|4.18 mph Range: 1.39 mph - 12.71 mph")
334
- expect(replies[5]).to eq("Portland, OR 8 day sun forecast |\u000308█\u000309▃\u000308▇\u000309▁_\u000307▅\u000309▃\u000307▅\u0003| max 100%")
335
- expect(replies[6]).to eq("Portland, OR 24h cloud cover |___________▁▁▁▁▁▁▁▁▃▅▅▅| max 49.0%")
340
+ expect(replies[5]).to eq("Portland, OR 48hr sun forecast |\u000308████████████████████\u000307▇▇▅\u000309▅▅▃\u000303▁_▁\u000309▃▃▃\u000303▁▁▁▁▃\u000309▃▅\u000307▇▇▇▇\u000308▇▇▇▇▇▇\u0003| max 88%")
341
+ expect(replies[6]).to eq("Portland, OR 24h cloud cover |████████████████████▇▇▇| max 100.0%")
336
342
  expect(replies[7]).to eq("Portland, OR 48 hr snows |\u000302_______________________❄❄❄❄▁▁▁▁▁▁▁▁▁▁▁▁▁❄❄❄❄❄❄❄❄_\u0003| max 4.0%")
337
343
  end
338
344
 
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: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-27 00:00:00.000000000 Z
11
+ date: 2015-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita