lita-onewheel-baileys 3.8.0 → 3.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/lib/lita/handlers/onewheel_baileys.rb +3 -141
- data/lita-onewheel-baileys.gemspec +3 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f64891012d2f3ffce49277e74b8212e9f127856
|
4
|
+
data.tar.gz: 72918ce7117b587bed6605d1974db91e00075a58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7441a1096cc15fcac26dd1be26f473f7b96c2eb9596ccabf2dc30e858123c1ce1e7e1b32e302ad0684f8b638c3f6682a145b99aa73c685b71e9cf286d6e1e6cc
|
7
|
+
data.tar.gz: 9bc61da3d85aa239270f76bacede091df77d9f67f384f9b3134784d92c3e520a3f390127bc4190a9e1fe5f618a0d95c3e70dbbf9081937e3bbcff1fcacb50d5a
|
data/Gemfile
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'nokogiri'
|
3
3
|
require 'sanitize'
|
4
|
+
require 'lita-onewheel-beer-base'
|
4
5
|
|
5
6
|
module Lita
|
6
7
|
module Handlers
|
7
|
-
class OnewheelBaileys <
|
8
|
+
class OnewheelBaileys < OnewheelBeerBase
|
8
9
|
route /^taps$/i,
|
9
10
|
:taps_list,
|
10
11
|
command: true,
|
11
|
-
help: {'taps' => 'Display the current taps
|
12
|
+
help: {'taps' => 'Display the current taps.'}
|
12
13
|
|
13
14
|
route /^taps ([\w ]+)$/i,
|
14
15
|
:taps_deets,
|
@@ -45,141 +46,6 @@ module Lita
|
|
45
46
|
command: true,
|
46
47
|
help: {'tapslow' => 'Show me the highest abv keg.'}
|
47
48
|
|
48
|
-
def taps_list(response)
|
49
|
-
beers = get_source
|
50
|
-
reply = "Bailey's taps: "
|
51
|
-
beers.each do |tap, datum|
|
52
|
-
reply += "#{tap}) "
|
53
|
-
reply += get_tap_type_text(datum[:type])
|
54
|
-
reply += datum[:brewery] + ' '
|
55
|
-
reply += datum[:name] + ' '
|
56
|
-
end
|
57
|
-
reply = reply.strip.sub /,\s*$/, ''
|
58
|
-
|
59
|
-
Lita.logger.info "Replying with #{reply}"
|
60
|
-
response.reply reply
|
61
|
-
end
|
62
|
-
|
63
|
-
def taps_deets(response)
|
64
|
-
Lita.logger.debug "taps_deets started"
|
65
|
-
beers = get_source
|
66
|
-
beers.each do |tap, datum|
|
67
|
-
query = response.matches[0][0].strip
|
68
|
-
# Search directly by tap number OR full text match.
|
69
|
-
# Let's make cask and nitro taps specific.
|
70
|
-
if (query.match(/^\d+$/) and tap == query) or (datum[:search].match(/#{query}/i)) or (datum[:type].downcase.match(/#{query}/i)) # Cask and Nitro
|
71
|
-
send_response(tap, datum, response)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def taps_by_abv(response)
|
77
|
-
beers = get_source
|
78
|
-
beers.each do |tap, datum|
|
79
|
-
if datum[:abv].to_f == 0.0
|
80
|
-
next
|
81
|
-
end
|
82
|
-
query = response.matches[0][0].strip
|
83
|
-
# Search directly by abv matcher.
|
84
|
-
if (abv_matches = query.match(/([><=]+)\s*(\d+\.*\d*)/))
|
85
|
-
direction = abv_matches.to_s.match(/[<>=]+/).to_s
|
86
|
-
abv_requested = abv_matches.to_s.match(/\d+.*\d*/).to_s
|
87
|
-
if direction == '>' and datum[:abv].to_f > abv_requested.to_f
|
88
|
-
send_response(tap, datum, response)
|
89
|
-
end
|
90
|
-
if direction == '<' and datum[:abv].to_f < abv_requested.to_f
|
91
|
-
send_response(tap, datum, response)
|
92
|
-
end
|
93
|
-
if direction == '>=' and datum[:abv].to_f >= abv_requested.to_f
|
94
|
-
send_response(tap, datum, response)
|
95
|
-
end
|
96
|
-
if direction == '<=' and datum[:abv].to_f <= abv_requested.to_f
|
97
|
-
send_response(tap, datum, response)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def taps_by_price(response)
|
104
|
-
beers = get_source
|
105
|
-
beers.each do |tap, datum|
|
106
|
-
# if datum[:prices][1][:cost].to_f == 0.0
|
107
|
-
# next
|
108
|
-
# end
|
109
|
-
|
110
|
-
query = response.matches[0][0].strip
|
111
|
-
# Search directly by tap number OR full text match.
|
112
|
-
if (price_matches = query.match(/([><=]+)\s*\$(\d+\.*\d*)/))
|
113
|
-
direction = price_matches.to_s.match(/[<>=]+/).to_s
|
114
|
-
price_requested = price_matches.to_s.match(/\d+.*\d*/).to_s
|
115
|
-
if direction == '>' and datum[:prices][1][:cost].to_f > price_requested.to_f
|
116
|
-
send_response(tap, datum, response)
|
117
|
-
end
|
118
|
-
if direction == '<' and datum[:prices][1][:cost].to_f < price_requested.to_f
|
119
|
-
send_response(tap, datum, response)
|
120
|
-
end
|
121
|
-
if direction == '>=' and datum[:prices][1][:cost].to_f >= price_requested.to_f
|
122
|
-
send_response(tap, datum, response)
|
123
|
-
end
|
124
|
-
if direction == '<=' and datum[:prices][1][:cost].to_f <= price_requested.to_f
|
125
|
-
send_response(tap, datum, response)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def taps_by_random(response)
|
132
|
-
beers = get_source
|
133
|
-
beer = beers.to_a.sample
|
134
|
-
send_response(beer[0], beer[1], response)
|
135
|
-
end
|
136
|
-
|
137
|
-
def taps_by_remaining(response)
|
138
|
-
beers = get_source
|
139
|
-
response_sent = false
|
140
|
-
low_tap = nil
|
141
|
-
beers.each do |tap, datum|
|
142
|
-
unless low_tap
|
143
|
-
low_tap = tap
|
144
|
-
end
|
145
|
-
if low_tap and beers[low_tap][:remaining] > datum[:remaining]
|
146
|
-
low_tap = tap
|
147
|
-
end
|
148
|
-
if datum[:remaining].to_i <= 10
|
149
|
-
send_response(tap, datum, response)
|
150
|
-
response_sent = true
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def taps_low_abv(response)
|
156
|
-
beers = get_source
|
157
|
-
low_tap = nil
|
158
|
-
beers.each do |tap, datum|
|
159
|
-
unless low_tap
|
160
|
-
low_tap = tap
|
161
|
-
end
|
162
|
-
if datum[:abv] != 0 and beers[low_tap][:abv] > datum[:abv]
|
163
|
-
low_tap = tap
|
164
|
-
end
|
165
|
-
end
|
166
|
-
send_response(low_tap, beers[low_tap], response)
|
167
|
-
end
|
168
|
-
|
169
|
-
def taps_high_abv(response)
|
170
|
-
beers = get_source
|
171
|
-
high_tap = nil
|
172
|
-
beers.each do |tap, datum|
|
173
|
-
unless high_tap
|
174
|
-
high_tap = tap
|
175
|
-
end
|
176
|
-
if datum[:abv] != 0 and beers[high_tap][:abv] < datum[:abv]
|
177
|
-
high_tap = tap
|
178
|
-
end
|
179
|
-
end
|
180
|
-
send_response(high_tap, beers[high_tap], response)
|
181
|
-
end
|
182
|
-
|
183
49
|
def send_response(tap, datum, response)
|
184
50
|
reply = "Bailey's tap #{tap}) #{get_tap_type_text(datum[:type])}"
|
185
51
|
reply += "#{datum[:brewery]} "
|
@@ -194,10 +60,6 @@ module Lita
|
|
194
60
|
response.reply reply
|
195
61
|
end
|
196
62
|
|
197
|
-
def get_tap_type_text(type)
|
198
|
-
(type.empty?) ? '' : "(#{type}) "
|
199
|
-
end
|
200
|
-
|
201
63
|
def get_display_prices(prices)
|
202
64
|
price_array = []
|
203
65
|
prices.each do |p|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-onewheel-baileys'
|
3
|
-
spec.version = '3.8.
|
3
|
+
spec.version = '3.8.1'
|
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.}
|
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_runtime_dependency 'sanitize', '~> 4.0'
|
21
21
|
|
22
22
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
|
+
spec.add_development_dependency 'lita-onewheel-beer-base', '~> 1'
|
24
|
+
|
23
25
|
# spec.add_development_dependency 'pry-byebug', '~> 3.1'
|
24
26
|
spec.add_development_dependency 'rake', '~> 10.4'
|
25
27
|
spec.add_development_dependency 'rack-test', '~> 0.6'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-baileys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.8.
|
4
|
+
version: 3.8.1
|
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-
|
11
|
+
date: 2016-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: lita-onewheel-beer-base
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|