lita-onewheel-baileys 2.1.2 → 3.0.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: b316f12fc72ca113a653bfdec42fa311cd96ee61
4
- data.tar.gz: 40e257ea10470f1cc1e479f943a88f990df8f1f0
3
+ metadata.gz: f5c55180908443a45a44ddb871d851f02e17024f
4
+ data.tar.gz: 9b47445d6eeb64b0d93b00816e038beaca726be7
5
5
  SHA512:
6
- metadata.gz: 55a0a6e7627750aa09e5f52533b9aa4a4020b60f6ca861e9b20f6980f74b2509bc9353aedc81fb6242b6d590fa413a47e76ce63f3929c7c2d3e32348659ab3ae
7
- data.tar.gz: efb2751802ef05fd33b61b858c24e0ac9820005edc6122bd99c29e8a56c428ea612b12bfb9049edb32c7008547b9aae9677bacda38dcb5a9833851c89f8eb83f
6
+ metadata.gz: 9f950435d66827c36660f97bda8d28007d9e56e80f2a24abf1f64c4d9f0706d1a7e124cdfe6869c5d6103c3355c853dd0cc6dcfc13eeab6213833b311315fbe2
7
+ data.tar.gz: b814d0dd96ed8feda1daacad13c7c5b01421776e5e91dfca3a6def3631cda77174b18dc94a705afc68a034fc9e1ea349ddfa0ff3f4fcbb714d22fac78c07f2e5
data/README.md CHANGED
@@ -1,22 +1,28 @@
1
- # lita-automatic-pancake
1
+ # lita-onewheel-baileys
2
2
 
3
- [![Build Status](https://travis-ci.org/onewheelskyward/lita-automatic-pancake.png?branch=master)](https://travis-ci.org/onewheelskyward/lita-automatic-pancake)
4
- [![Coverage Status](https://coveralls.io/repos/onewheelskyward/lita-automatic-pancake/badge.png)](https://coveralls.io/r/onewheelskyward/lita-automatic-pancake)
3
+ [![Build Status](https://travis-ci.org/onewheelskyward/lita-onewheel-baileys.png?branch=master)](https://travis-ci.org/onewheelskyward/lita-onewheel-baileys)
4
+ [![Coverage Status](https://coveralls.io/repos/onewheelskyward/lita-onewheel-baileys/badge.png)](https://coveralls.io/r/onewheelskyward/lita-onewheel-baileys)
5
5
 
6
- TODO: Add a description of the plugin.
6
+ Searches Bailey's Taproom draft list for data and displays it in IRC.
7
+
8
+ http://www.baileystaproom.com/draft-list/
7
9
 
8
10
  ## Installation
9
11
 
10
- Add lita-automatic-pancake to your Lita instance's Gemfile:
12
+ Add lita-onewheel-baileys to your Lita instance's Gemfile:
11
13
 
12
14
  ``` ruby
13
- gem "lita-onewheel-"
15
+ gem 'lita-onewheel-baileys'
14
16
  ```
15
17
 
16
- ## Configuration
18
+ ## Usage
17
19
 
18
- TODO: Describe any configuration attributes the plugin exposes.
20
+ taps
19
21
 
20
- ## Usage
22
+ taps 4
23
+
24
+ taps nitro
25
+
26
+ taps >5%
21
27
 
22
- TODO: Describe the plugin's features and how to use them.
28
+ taps <$5
@@ -98,11 +98,19 @@ module Lita
98
98
  reply += "#{datum[:name]} "
99
99
  reply += "- #{datum[:desc]}, "
100
100
  # reply += "Served in a #{datum[1]['glass']} glass. "
101
- reply += "#{datum[:prices]}, "
101
+ reply += "#{get_display_prices datum[:prices]}, "
102
102
  reply += "#{datum[:remaining]}"
103
103
  response.reply reply
104
104
  end
105
105
 
106
+ def get_display_prices(prices)
107
+ price_array = []
108
+ prices.each do |p|
109
+ price_array.push "#{p[:size]} - #{p[:cost]}"
110
+ end
111
+ price_array.join ' | '
112
+ end
113
+
106
114
  def get_baileys
107
115
  response = RestClient.get('http://www.baileystaproom.com/draft-list/')
108
116
  response.gsub! '<div id="responsecontainer"">', ''
@@ -167,13 +175,24 @@ module Lita
167
175
  # There are a bunch of hidden html fields that get stripped after sanitize.
168
176
  def get_prices(noko)
169
177
  prices_str = noko.css('div#prices').children.to_s.strip
170
- Sanitize.clean(prices_str)
178
+ prices = Sanitize.clean(prices_str)
171
179
  .gsub(/We're Sorry/, '')
172
180
  .gsub(/Inventory Restriction/, '')
173
181
  .gsub(/Inventory Failure/, '')
174
182
  .gsub('Success!', '')
175
183
  .gsub(/\s+/, ' ')
176
184
  .strip
185
+ price_points = prices.split(/\s\|\s/)
186
+ prices_array = []
187
+ price_points.each do |price|
188
+ size = price.match /\d+(oz|cl)/
189
+ dollars = price.match /\$\d+\.*\d*/
190
+ crowler = price.match ' Crowler'
191
+ size = size.to_s + crowler.to_s
192
+ p = {size: size, cost: dollars}
193
+ prices_array.push p
194
+ end
195
+ prices_array
177
196
  end
178
197
 
179
198
  # Returns 1, 2, Cask 3, Nitro 4...
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-baileys'
3
- spec.version = '2.1.2'
3
+ spec.version = '3.0.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.}
@@ -16,45 +16,63 @@ describe Lita::Handlers::OnewheelBaileys, lita_handler: true do
16
16
 
17
17
  it 'displays details for tap 4' do
18
18
  send_command 'taps 4'
19
- expect(replies.last).to eq('Bailey\'s tap 4) Wild Ride Solidarity - Abbey Dubbel – Barrel Aged (Pinot Noir) 8.2%, 4oz Pour $4 | 12oz $7, 26% remaining')
19
+ expect(replies.last).to eq('Bailey\'s tap 4) Wild Ride Solidarity - Abbey Dubbel – Barrel Aged (Pinot Noir) 8.2%, 4oz - $4 | 12oz - $7, 26% remaining')
20
20
  end
21
21
 
22
22
  it 'doesn\'t explode on 1' do
23
23
  send_command 'taps 1'
24
24
  expect(replies.count).to eq(1)
25
- expect(replies.last).to eq('Bailey\'s tap 1) Cider Riot! Plastic Paddy - Apple Cider w/ Irish tea 6.0%, 10oz $4 | 20oz $7 | 32oz Crowler $10, 48% remaining')
25
+ expect(replies.last).to eq('Bailey\'s tap 1) Cider Riot! Plastic Paddy - Apple Cider w/ Irish tea 6.0%, 10oz - $4 | 20oz - $7 | 32oz Crowler - $10, 48% remaining')
26
26
  end
27
27
 
28
28
  it 'gets nitro' do
29
29
  send_command 'taps nitro'
30
- expect(replies.last).to eq('Bailey\'s tap Nitro 6) Backwoods Winchester Brown - Brown Ale 6.2%, 10oz $3 | 20oz $5, 98% remaining')
30
+ expect(replies.last).to eq('Bailey\'s tap Nitro 6) Backwoods Winchester Brown - Brown Ale 6.2%, 10oz - $3 | 20oz - $5, 98% remaining')
31
31
  end
32
32
 
33
33
  it 'gets cask' do
34
34
  send_command 'taps cask'
35
- expect(replies.last).to eq('Bailey\'s tap Cask 3) Machine House Crystal Maze - ESB 4.0%, 10oz $3 | 20oz $5, 57% remaining')
35
+ expect(replies.last).to eq("Bailey's tap Cask 3) Machine House Crystal Maze - ESB 4.0%, 10oz - $3 | 20oz - $5, 57% remaining")
36
36
  end
37
37
 
38
38
  it 'searches for ipa' do
39
39
  send_command 'taps ipa'
40
- expect(replies.last).to eq("Bailey's tap 24) Oakshire Perfect Storm - Imperial IPA 9.0%, 10oz $4 | 20oz $6 | 32oz Crowler $10, 61% remaining")
40
+ expect(replies.last).to eq("Bailey's tap 24) Oakshire Perfect Storm - Imperial IPA 9.0%, 10oz - $4 | 20oz - $6 | 32oz Crowler - $10, 61% remaining")
41
41
  end
42
42
 
43
43
  it 'searches for brown' do
44
44
  send_command 'taps brown'
45
- expect(replies.last).to eq("Bailey's tap 22) GoodLife 29er - India Brown Ale 6.0%, 10oz $3 | 20oz $5 | 32oz Crowler $8, 37% remaining")
45
+ expect(replies.last).to eq("Bailey's tap 22) GoodLife 29er - India Brown Ale 6.0%, 10oz - $3 | 20oz - $5 | 32oz Crowler - $8, 37% remaining")
46
46
  end
47
47
 
48
48
  it 'searches for abv > 9%' do
49
49
  send_command 'taps >9%'
50
- expect(replies[0]).to eq("Bailey's tap 8) Fat Head’s Zeus Juice - Belgian Strong Blonde 10.0%, 4oz Pour – $2 | 12oz – $4 | 32oz Crowler $9, 44% remaining")
51
- expect(replies[1]).to eq("Bailey's tap 9) Hopworks NogginFloggin’ - Barleywine 11.0%, 4oz Pour $3 | 12oz $6 | 32oz Crowler $13, 34% remaining")
52
- expect(replies.last).to eq("Bailey's tap 24) Oakshire Perfect Storm - Imperial IPA 9.0%, 10oz $4 | 20oz $6 | 32oz Crowler $10, 61% remaining")
50
+ expect(replies.count).to eq(5)
51
+ expect(replies[0]).to eq("Bailey's tap 8) Fat Heads Zeus Juice - Belgian Strong Blonde 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $9, 44% remaining")
52
+ expect(replies[1]).to eq("Bailey's tap 9) Hopworks Noggin’ Floggin’ - Barleywine 11.0%, 4oz - $3 | 12oz - $6 | 32oz Crowler - $13, 34% remaining")
53
+ expect(replies[2]).to eq("Bailey's tap 18) Knee Deep Hop Surplus - Triple IPA 10.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $10, 25% remaining")
54
+ expect(replies[3]).to eq("Bailey's tap 20) Knee Deep Dark Horse - Imperial Stout 12.0%, 4oz - $2 | 12oz - $4 | 32oz Crowler - $10, 39% remaining")
55
+ expect(replies.last).to eq("Bailey's tap 24) Oakshire Perfect Storm - Imperial IPA 9.0%, 10oz - $4 | 20oz - $6 | 32oz Crowler - $10, 61% remaining")
53
56
  end
54
57
 
55
58
  it 'searches for abv < 4%' do
56
59
  send_command 'taps <4%'
57
60
  expect(replies.count).to eq(2)
61
+ expect(replies[0]).to eq("Bailey's tap Cask 3) Machine House Crystal Maze - ESB 4.0%, 10oz - $3 | 20oz - $5, 57% remaining")
62
+ expect(replies.last).to eq("Bailey's tap 11) Lagunitas Copper Fusion Ale - Copper Ale 4.0%, 10oz - $3 | 20oz - $5 | 32oz Crowler - $8, 19% remaining")
63
+ end
64
+
65
+ it 'searches for prices > $6' do
66
+ send_command 'taps >$6'
67
+ # expect(replies.count).to eq(3)
68
+ expect(replies[0]).to eq("")
69
+ expect(replies[1]).to eq("")
70
+ expect(replies.last).to eq("")
71
+ end
72
+
73
+ it 'searches for prices < $4' do
74
+ send_command 'taps <$4'
75
+ # expect(replies.count).to eq(2)
58
76
  expect(replies[0]).to eq("Bailey's tap Cask 3) Machine House Crystal Maze - ESB 4.0%, 10oz – $3 | 20oz – $5, 57% remaining")
59
77
  expect(replies.last).to eq("Bailey's tap 11) Lagunitas Copper Fusion Ale - Copper Ale 4.0%, 10oz – $3 | 20oz – $5 | 32oz Crowler $8, 19% remaining")
60
78
  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: 2.1.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps