lita-onewheel-baileys 3.6.0 → 3.7.0

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: 8d7f3a77e5632386242cad3dea416acec650cdce
4
- data.tar.gz: c85e4caaaaf0c69b930e8b5487d16f9a3b064653
3
+ metadata.gz: 2e90058b743a865aedf604f785f990ec34bad601
4
+ data.tar.gz: ef07f531bdaf3469e2aeb4b516a6138fad435d4a
5
5
  SHA512:
6
- metadata.gz: f3ef79346e8b6dc4944e3665e259973601f39fca103908bb33c716b3523507908aeda1a2bb7afe133cc16590220284997d3dfcc78fc858367b4a4f43a922a5bf
7
- data.tar.gz: 7bdf4621e3aa5674adc478dd61941af4ff88dea8f4963f94e7b4e5233d3e0fde82f9f240e883fb7099e4a06ba7cc216c5058c2a814c4eedf33a2f950e87b0308
6
+ metadata.gz: a3db2432d784242bc33370b190b91f6c2432fb291cdde168fc51895b5c449bbad1aaa48ae4fae8a384d7b86dc0d7926940fa7bbbbcf279ec9cbedb3a0f0c9570
7
+ data.tar.gz: dbb0adbd0b2f4ae3fff30dc46b0fc63232749a0968424786327e5a5f986a8e1c9fe3f90b1b575c782efb5f19d68ea44a66507e89aa7e267e0bd865d9d392c3ea
@@ -30,6 +30,11 @@ module Lita
30
30
  command: true,
31
31
  help: {'taps roulette' => 'Can\'t decide? Let me do it for you!'}
32
32
 
33
+ route /^tapslow$/i,
34
+ :taps_by_remaining,
35
+ command: true,
36
+ help: {'tapslow' => 'Show me the kegs at <10% remaining, or the lowest one available.'}
37
+
33
38
  def taps_list(response)
34
39
  beers = get_source
35
40
  reply = "Bailey's taps: "
@@ -118,6 +123,21 @@ module Lita
118
123
  send_response(beer[0], beer[1], response)
119
124
  end
120
125
 
126
+ def taps_by_remaining(response)
127
+ beers = get_source
128
+ response_sent = false
129
+ low_tap = nil
130
+ beers.each do |tap, datum|
131
+ if low_tap and beers[low_tap][:remaining] > datum[:remaining]
132
+ low_tap = tap
133
+ end
134
+ if datum[:remaining].to_i <= 10
135
+ send_response(tap, datum, response)
136
+ response_sent = true
137
+ end
138
+ end
139
+ end
140
+
121
141
  def send_response(tap, datum, response)
122
142
  reply = "Bailey's tap #{tap}) #{get_tap_type_text(datum[:type])}"
123
143
  reply += "#{datum[:brewery]} "
@@ -163,7 +183,7 @@ module Lita
163
183
  tap = tap_name.match(/\d+/).to_s
164
184
  tap_type = tap_name.match(/(cask|nitro)/i).to_s
165
185
 
166
- remaining = beer_node.attributes['title']
186
+ remaining = beer_node.attributes['title'].to_s
167
187
 
168
188
  brewery = get_brewery(beer_node)
169
189
  beer_name = beer_node.css('span i').first.children.to_s
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-baileys'
3
- spec.version = '3.6.0'
3
+ spec.version = '3.7.0'
4
4
  spec.authors = ['Andrew Kreps']
5
5
  spec.email = ['andrew.kreps@gmail.com']
6
6
  spec.description = %q{Lita interface to Bailey's Taproom listings.}
@@ -3,6 +3,17 @@ require 'spec_helper'
3
3
  describe Lita::Handlers::OnewheelBaileys, lita_handler: true do
4
4
  it { is_expected.to route_command('taps') }
5
5
  it { is_expected.to route_command('taps 4') }
6
+ it { is_expected.to route_command('taps nitro') }
7
+ it { is_expected.to route_command('taps CASK') }
8
+ it { is_expected.to route_command('taps <$4') }
9
+ it { is_expected.to route_command('taps < $4') }
10
+ it { is_expected.to route_command('taps <=$4') }
11
+ it { is_expected.to route_command('taps <= $4') }
12
+ it { is_expected.to route_command('taps >4%') }
13
+ it { is_expected.to route_command('taps > 4%') }
14
+ it { is_expected.to route_command('taps >=4%') }
15
+ it { is_expected.to route_command('taps >= 4%') }
16
+ it { is_expected.to route_command('tapslow') }
6
17
 
7
18
  before do
8
19
  mock = File.open('spec/fixtures/baileys.html').read
@@ -149,4 +160,9 @@ describe Lita::Handlers::OnewheelBaileys, lita_handler: true do
149
160
  send_command 'taps zeus juice'
150
161
  expect(replies.last).to eq("Bailey's tap 8) Fat Head’s Zeus Juice - Belgian Strong Blonde 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $9, 44% remaining")
151
162
  end
163
+
164
+ it 'displays low taps' do
165
+ send_command 'tapslow'
166
+ expect(replies.last).to eq("Bailey's tap 25) Green Flash Passion Fruit Kicker - Wheat Ale w/ Passion Fruit 5.5%, 10oz - $3 | 20oz - $5, <= 1% remaining")
167
+ end
152
168
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-onewheel-baileys
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps