lita-onewheel-beer-btu 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c6e31d0e61d66bf43528e6883a9d1b38bc3f3c5f
4
+ data.tar.gz: 0ecb4c6605e8829680b0a2b2ad209c7e3f55dc4f
5
+ SHA512:
6
+ metadata.gz: 2e97af02ab38414d072397d1b9e96e7376bcb21ba143bc1df4ea5e1504c24bab24133214276ce8128c8003b0522941a6b45622f2d6511595fd21975ed8af35ec
7
+ data.tar.gz: b467de20bfd27cf5d0c1bee7d80ce25b95bde4c58f2e25272e0fa3eeb3aae65d554bcf0a47766946377e1c58e7f2e57677d68bc719ab1d01d998d31536a73d94
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
19
+ lita_config.rb
20
+ bin
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.2.6
5
+ - 2.3.3
6
+
7
+ script: bundle exec rspec -fp spec
8
+
9
+ # Travis CI has an outdated version of bundler on older versions of ruby.
10
+ # See bundler/bundler#3558 for more information
11
+ #before_install:
12
+ # - gem update --system
13
+ # - gem update bundler
14
+
15
+ services:
16
+ - redis-server
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ # For local development and base testing
6
+ # gem 'lita-onewheel-beer-base', :github => 'onewheelskyward/lita-onewheel-beer-base', branch: :master
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # lita-onewheel-beer-btu
2
+
3
+ [![Build Status](https://travis-ci.org/onewheelskyward/lita-onewheel-beer-btu.png?branch=master)](https://travis-ci.org/onewheelskyward/lita-onewheel-beer-btu)
4
+ [![Coverage Status](https://coveralls.io/repos/onewheelskyward/lita-onewheel-beer-btu/badge.png)](https://coveralls.io/r/onewheelskyward/lita-onewheel-beer-btu)
5
+
6
+ Searches BTU Brasserie's Taproom draft list for data and displays it in IRC.
7
+
8
+ http://www.baileystaproom.com/draft-list/
9
+
10
+ ## Installation
11
+
12
+ Add lita-onewheel-beer-btu to your Lita instance's Gemfile:
13
+
14
+ ``` ruby
15
+ gem 'lita-onewheel-beer-btu'
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ taps
21
+
22
+ taps 4
23
+
24
+ taps nitro
25
+
26
+ taps >(=)5%
27
+
28
+ taps <(=)$5
29
+
30
+ taps roulette|random
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,2 @@
1
+ require 'lita'
2
+ require 'lita/handlers/onewheel_beer_btu'
@@ -0,0 +1,139 @@
1
+ require 'rest-client'
2
+ require 'lita-onewheel-beer-base'
3
+ require 'open-uri'
4
+ require 'pdf-reader'
5
+
6
+ module Lita
7
+ module Handlers
8
+ class OnewheelBeerBtu < OnewheelBeerBase
9
+ route /^btu$/i,
10
+ :taps_list,
11
+ command: true,
12
+ help: {'btu' => 'Display the current taps.'}
13
+
14
+ route /^btu ([\w ]+)$/i,
15
+ :taps_deets,
16
+ command: true,
17
+ help: {'btu 4' => 'Display the tap 4 deets, including prices.'}
18
+
19
+ route /^btu ([<>=\w.\s]+)%$/i,
20
+ :taps_by_abv,
21
+ command: true,
22
+ help: {'btu >4%' => 'Display beers over 4% ABV.'}
23
+
24
+ route /^btu ([<>=\$\w.\s]+)$/i,
25
+ :taps_by_price,
26
+ command: true,
27
+ help: {'btu <$5' => 'Display beers under $5.'}
28
+
29
+ route /^btu (roulette|random)$/i,
30
+ :taps_by_random,
31
+ command: true,
32
+ help: {'btu roulette' => 'Can\'t decide? Let me do it for you!'}
33
+
34
+ route /^btuabvlow$/i,
35
+ :taps_low_abv,
36
+ command: true,
37
+ help: {'btuabvlow' => 'Show me the lowest abv keg.'}
38
+
39
+ route /^btuabvhigh$/i,
40
+ :taps_high_abv,
41
+ command: true,
42
+ help: {'btuabvhigh' => 'Show me the highest abv keg.'}
43
+
44
+ def taps_list(response)
45
+ beers = self.get_source
46
+ reply = 'BTU taps: '
47
+ beers.each do |tap, datum|
48
+ reply += "#{tap}) "
49
+ reply += datum[:name] + ' '
50
+ reply += '- ' + datum[:abv].to_s + '% '
51
+ reply += ' '
52
+ # reply += datum[:ibu].to_s + ' IBU '
53
+ end
54
+ reply = reply.strip.sub /,\s*$/, ''
55
+
56
+ Lita.logger.info "Replying with #{reply}"
57
+ response.reply reply
58
+ end
59
+
60
+ def send_response(tap, datum, response)
61
+ reply = "BTU's tap #{tap}) "
62
+ reply += "#{datum[:name]} - "
63
+ reply += datum[:abv].to_s + '% ABV '
64
+ reply += datum[:ibu].to_s + ' IBU '
65
+ reply += "- #{datum[:desc]}"
66
+
67
+ Lita.logger.info "send_response: Replying with #{reply}"
68
+
69
+ response.reply reply
70
+ end
71
+
72
+ def get_source
73
+ # Lita.logger.debug 'get_source started'
74
+ # unless (response = redis.get('page_response'))
75
+ # Lita.logger.info 'No cached result found, fetching.'
76
+ # response = RestClient.get('http://www.btupdx.com/ftp/TapList/BTUbeerlist.pdf')
77
+ # redis.setex('page_response', 18000, response)
78
+ # end
79
+ parse_response pull_pdf
80
+ end
81
+
82
+ def pull_pdf
83
+ reader = PDF::Reader.new(open 'http://www.btupdx.com/ftp/TapList/BTUbeerlist.pdf')
84
+ reader.pages[0].text.split /\n/
85
+ end
86
+
87
+ # This is the worker bee- decoding the pdf into our "standard" document.
88
+ def parse_response(response)
89
+ gimme_what_you_got = {}
90
+ tap = 1
91
+ beer_name = nil
92
+ beer_abv = nil
93
+ beer_ibu = nil
94
+ beer_desc = ''
95
+
96
+ response.each_with_index do |line, index|
97
+ line.strip!
98
+ if index >= 2
99
+ if line.empty?
100
+ unless beer_name.nil?
101
+ gimme_what_you_got[tap] = {
102
+ brewery: 'BTU',
103
+ name: beer_name.to_s,
104
+ desc: beer_desc.to_s.strip,
105
+ abv: beer_abv.to_f,
106
+ ibu: beer_ibu,
107
+ search: "#{beer_name} #{beer_desc}"
108
+ }
109
+ tap += 1
110
+ beer_name = nil
111
+ beer_desc = ''
112
+ beer_abv = nil
113
+ beer_ibu = nil
114
+ end
115
+ next
116
+ end
117
+
118
+ if beer_name.nil?
119
+ beer_name = line
120
+ next
121
+ end
122
+
123
+ if (matchdata = line.match(/(.+)\sIBUS\s([0-9.]+)\%\s*ABV/))
124
+ beer_ibu = matchdata[1]
125
+ beer_abv = matchdata[2]
126
+ next
127
+ end
128
+
129
+ beer_desc += line + ' '
130
+ end
131
+ end
132
+
133
+ gimme_what_you_got
134
+ end
135
+
136
+ Lita.register_handler(self)
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,30 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-onewheel-beer-btu'
3
+ spec.version = '0.0.0'
4
+ spec.authors = ['Andrew Kreps']
5
+ spec.email = ['andrew.kreps@gmail.com']
6
+ spec.description = %q{Lita interface to BTU PDX}
7
+ spec.summary = %q{See above}
8
+ spec.homepage = 'https://github.com/onewheelskyward/lita-onewheel-beer-btu'
9
+ spec.license = 'MIT'
10
+ spec.metadata = { 'lita_plugin_type' => 'handler' }
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.add_runtime_dependency 'lita', '~> 4'
18
+ spec.add_runtime_dependency 'rest-client', '~> 1.8'
19
+ spec.add_runtime_dependency 'pdf-reader', '~> 1.4'
20
+ spec.add_runtime_dependency 'lita-onewheel-beer-base', '~> 2'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+
24
+ # spec.add_development_dependency 'pry-byebug', '~> 3.1'
25
+ spec.add_development_dependency 'rake', '~> 12'
26
+ spec.add_development_dependency 'rack-test', '~> 0.6'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ spec.add_development_dependency 'simplecov', '~> 0.12'
29
+ spec.add_development_dependency 'coveralls', '~> 0.8'
30
+ end
Binary file
@@ -0,0 +1,61 @@
1
+ BTU BREWING
2
+ ALL BREWING DONE ON PREMISES!
3
+
4
+
5
+ BRUMATOR
6
+ 23 IBUS 8.7% ABV
7
+ A strong dark ale brewed with rye and
8
+ finished with blood orange juice.
9
+ Available again this year for a limited time!
10
+
11
+
12
+ HORNED HAND
13
+ 17 IBUS 9.5%ABV
14
+ Our latest creation! This doppelbock has aged
15
+ four months, and we have just been waiting for
16
+ cooler weather to tap it!
17
+
18
+
19
+ JADE TIGER IPA
20
+ 65 IBUS 6.8% ABV
21
+ Two tigers cannot share one mountain.
22
+ -Chinese proverb
23
+
24
+
25
+ BTU LAGER
26
+ 24 IBUS 5.8% ABV
27
+ Our light American Lager is brewed with puffed
28
+ jasmine rice to be light, crisp and refreshing…just
29
+ like Dad used to drink!
30
+
31
+
32
+ GHOSTMAN WHITE LAGER
33
+ 16 IBUS 5.4% ABV
34
+ An unfiltered wheat lager using oats to create a
35
+ creamy head. Coriander and orange peel give
36
+ this lager its floral aroma.
37
+
38
+
39
+ BUTTAH-NUT GOSE
40
+ 3 IBUS 4.9% ABV
41
+ A tart wheat ale brewed with
42
+ butternut squash and a touch of sea salt.
43
+
44
+
45
+ WET TIGER IPA
46
+ ?? IBUS 6.8% ABV
47
+ Our standard Jade Tiger IPA recipe made with
48
+ fresh mosaic hops. It’s the most wonderful
49
+ time of the year!
50
+
51
+
52
+ IMPERIAL RED
53
+ 55 IBUS 8.3% ABV
54
+ It’s back again, and this time to celebrate our
55
+ Second Anniversary! This time around we
56
+ packed this big red ale full of azacca hops.
57
+
58
+
59
+ COMING SOON
60
+ “The Sword” kettle-sour ale
61
+ brewed with beets
@@ -0,0 +1,37 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ describe Lita::Handlers::OnewheelBeerBtu, lita_handler: true do
4
+ it { is_expected.to route_command('btu') }
5
+ it { is_expected.to route_command('btu 4') }
6
+ it { is_expected.to route_command('btu <$4') }
7
+ it { is_expected.to route_command('btu <=$4') }
8
+ it { is_expected.to route_command('btu >4%') }
9
+ it { is_expected.to route_command('btu >=4%') }
10
+ it { is_expected.to route_command('btuabvhigh') }
11
+ it { is_expected.to route_command('btuabvlow') }
12
+
13
+ before do
14
+ mock = File.open('spec/fixtures/btu.txt').read
15
+ allow(Lita::Handlers::OnewheelBeerBtu).to receive(:pull_pdf) { mock }
16
+ end
17
+
18
+ it 'shows the taps' do
19
+ send_command 'btu'
20
+ expect(replies.last).to include("BTU taps: 1) BRUMATOR - 8.7% 2) HORNED HAND - 9.5% 3) JADE TIGER IPA - 6.8% 4) BTU LAGER - 5.8% 5) GHOSTMAN WHITE LAGER - 5.4% 6) BUTTAH-NUT GOSE - 4.9% 7) WET TIGER IPA - 6.8% 8) IMPERIAL RED - 8.3%")
21
+ end
22
+
23
+ it 'displays details for tap jade' do
24
+ send_command 'btu jade'
25
+ expect(replies.last).to eq("BTU's tap 7) WET TIGER IPA - 6.8% ABV ?? IBU - Our standard Jade Tiger IPA recipe made with fresh mosaic hops. It’s the most wonderful time of the year!")
26
+ end
27
+
28
+ it 'displays details for tap 7' do
29
+ send_command 'btu 7'
30
+ expect(replies.last).to include("BTU's tap 7) WET TIGER IPA - 6.8% ABV ?? IBU - Our standard Jade Tiger IPA recipe made with fresh mosaic hops. It’s the most wonderful time of the year!")
31
+ end
32
+
33
+ it 'displays details for tap 5' do
34
+ send_command 'btu 5'
35
+ expect(replies.last).to include("BTU's tap 5) GHOSTMAN WHITE LAGER - 5.4% ABV 16 IBU - An unfiltered wheat lager using oats to create a creamy head. Coriander and orange peel give this lager its floral aroma.")
36
+ end
37
+ end
@@ -0,0 +1,14 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatters = [
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter '/spec/' }
8
+
9
+ require 'lita-onewheel-beer-btu'
10
+ require 'lita/rspec'
11
+
12
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
13
+ # was generated with Lita 4, the compatibility mode should be left disabled.
14
+ Lita.version_3_compatibility_mode = false
metadata ADDED
@@ -0,0 +1,202 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-onewheel-beer-btu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Kreps
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pdf-reader
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: lita-onewheel-beer-base
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '12'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '12'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rack-test
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.6'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.6'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.12'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.12'
139
+ - !ruby/object:Gem::Dependency
140
+ name: coveralls
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.8'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.8'
153
+ description: Lita interface to BTU PDX
154
+ email:
155
+ - andrew.kreps@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".ruby-version"
162
+ - ".travis.yml"
163
+ - Gemfile
164
+ - README.md
165
+ - Rakefile
166
+ - lib/lita-onewheel-beer-btu.rb
167
+ - lib/lita/handlers/onewheel_beer_btu.rb
168
+ - lita-onewheel-beer-btu.gemspec
169
+ - spec/fixtures/btu.pdf
170
+ - spec/fixtures/btu.txt
171
+ - spec/lita/handlers/onewheel_beer_btu_spec.rb
172
+ - spec/spec_helper.rb
173
+ homepage: https://github.com/onewheelskyward/lita-onewheel-beer-btu
174
+ licenses:
175
+ - MIT
176
+ metadata:
177
+ lita_plugin_type: handler
178
+ post_install_message:
179
+ rdoc_options: []
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ requirements: []
193
+ rubyforge_project:
194
+ rubygems_version: 2.5.1
195
+ signing_key:
196
+ specification_version: 4
197
+ summary: See above
198
+ test_files:
199
+ - spec/fixtures/btu.pdf
200
+ - spec/fixtures/btu.txt
201
+ - spec/lita/handlers/onewheel_beer_btu_spec.rb
202
+ - spec/spec_helper.rb