lita-onewheel-beer-loyal-legion 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: 2183dfce069e684f02dd2b6c354038d5f33584e1
4
+ data.tar.gz: 390b139d05ed68b986d0a7eebb0a57a4d2d0d680
5
+ SHA512:
6
+ metadata.gz: 169548023f3a3e72d17435612a1d17c143a8f056b3be7585ad46c0387d28f3dda465634c7ddcd6339aad5010e2c349b2e4ab4d7cf42bf10ce8802ee0d0378a30
7
+ data.tar.gz: 1a5ecd8a2b524b3ac55446e0a723552ff50a6f70bed12ce0a570b3f255e6e02b8de4f698e2a8b8483b54d8099fb62eff445dfb5e095443838ca904b7825aa5d7
data/.gitignore ADDED
@@ -0,0 +1,19 @@
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
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.2.4
5
+ - 2.3.0
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-loyal-legion
2
+
3
+ [![Build Status](https://travis-ci.org/onewheelskyward/lita-onewheel-beer-loyal-legion.png?branch=master)](https://travis-ci.org/onewheelskyward/lita-onewheel-beer-loyal-legion)
4
+ [![Coverage Status](https://coveralls.io/repos/onewheelskyward/lita-onewheel-beer-loyal-legion/badge.png)](https://coveralls.io/r/onewheelskyward/lita-onewheel-beer-loyal-legion)
5
+
6
+ Searches Loyal Legion's draft list for data and displays it in IRC.
7
+ http://loyallegionpdx.com/taplist/
8
+
9
+ ## Installation
10
+
11
+ Add lita-onewheel-beer-loyal-legion to your Lita instance's Gemfile:
12
+
13
+ ``` ruby
14
+ gem 'lita-onewheel-beer-loyal-legion'
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ loyallegion
20
+
21
+ loyallegion 4
22
+
23
+ loyallegion nitro
24
+
25
+ loyallegion >(=)5%
26
+
27
+ loyallegion <(=)$5
28
+
29
+ loyallegion roulette|random
30
+
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,104 @@
1
+ require 'rest-client'
2
+ require 'nokogiri'
3
+ require 'sanitize'
4
+ require 'lita-onewheel-beer-base'
5
+
6
+ module Lita
7
+ module Handlers
8
+ class OnewheelBeerLoyalLegion < OnewheelBeerBase
9
+ route /^loyallegion$/i,
10
+ :taps_list,
11
+ command: true,
12
+ help: {'taps' => 'Display the current loyallegion Bar taps.'}
13
+
14
+ route /^loyallegion ([\w ]+)$/i,
15
+ :taps_deets,
16
+ command: true,
17
+ help: {'taps 4' => 'Display the tap 4 deets, including prices.'}
18
+
19
+ route /^loyallegion ([<>=\w.\s]+)%$/i,
20
+ :taps_by_abv,
21
+ command: true,
22
+ help: {'taps >4%' => 'Display beers over 4% ABV.'}
23
+
24
+ route /^loyallegion ([<>=\$\w.\s]+)$/i,
25
+ :taps_by_price,
26
+ command: true,
27
+ help: {'taps <$5' => 'Display beers under $5.'}
28
+
29
+ route /^loyallegion (roulette|random|rand|ran|ra|r)$/i,
30
+ :taps_by_random,
31
+ command: true,
32
+ help: {'taps roulette' => 'Can\'t decide? Let me do it for you!'}
33
+
34
+ route /^loyallegionabvlow$/i,
35
+ :taps_low_abv,
36
+ command: true,
37
+ help: {'tapslow' => 'Show me the lowest abv keg.'}
38
+
39
+ route /^loyallegionabvhigh$/i,
40
+ :taps_high_abv,
41
+ command: true,
42
+ help: {'tapslow' => 'Show me the highest abv keg.'}
43
+
44
+ def send_response(tap, datum, response)
45
+ reply = "Loyal Legion tap #{tap}) #{get_tap_type_text(datum[:type])}"
46
+ # reply += "#{datum[:brewery]} "
47
+ reply += "#{datum[:name]}"
48
+ # reply += "- #{datum[:desc]}, "
49
+ # reply += "Served in a #{datum[1]['glass']} glass. "
50
+ # reply += "#{datum[:remaining]}"
51
+ # reply += "#{datum[:abv]}%, "
52
+ # reply += "$#{datum[:price].to_s.sub '.0', ''}"
53
+
54
+ Lita.logger.info "send_response: Replying with #{reply}"
55
+
56
+ response.reply reply
57
+ end
58
+
59
+ def get_source
60
+ Lita.logger.debug 'get_source started'
61
+ unless (response = redis.get('page_response'))
62
+ Lita.logger.info 'No cached result found, fetching.'
63
+ response = RestClient.get('http://loyallegionbar.com/menu')
64
+ redis.setex('page_response', 1800, response)
65
+ end
66
+ parse_response response
67
+ end
68
+
69
+ # This is the worker bee- decoding the html into our "standard" document.
70
+ # Future implementations could simply override this implementation-specific
71
+ # code to help this grow more widely.
72
+ def parse_response(response)
73
+ Lita.logger.debug 'parse_response started.'
74
+ gimme_what_you_got = {}
75
+ noko = Nokogiri.HTML response
76
+
77
+ noko.css('article.tap-item').each do |beer_node|
78
+ # gimme_what_you_got
79
+ tap_name = beer_node.css('small.tapnum').children.to_s.sub 'Tap#', ''
80
+ next if tap_name.empty?
81
+
82
+ beer_name = beer_node.css('div.tap-content h1').children.to_s.strip
83
+ full_text_search = beer_name
84
+
85
+ gimme_what_you_got[tap_name] = {
86
+ # type: tap_type,
87
+ # remaining: remaining,
88
+ # brewery: brewery.to_s,
89
+ name: beer_name.to_s,
90
+ # desc: beer_type.to_s,
91
+ # abv: abv.to_f,
92
+ # price: price,
93
+ search: full_text_search
94
+ }
95
+ end
96
+ # puts gimme_what_you_got.inspect
97
+
98
+ gimme_what_you_got
99
+ end
100
+
101
+ Lita.register_handler(self)
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,12 @@
1
+ require 'lita'
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join('..', '..', 'locales', '*.yml'), __FILE__
5
+ )]
6
+
7
+ require 'lita/handlers/onewheel_beer_loyal_legion'
8
+
9
+ Lita::Handlers::OnewheelBeerLoyalLegion.template_root File.expand_path(
10
+ File.join('..', '..', 'templates'),
11
+ __FILE__
12
+ )
@@ -0,0 +1,31 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-onewheel-beer-loyal-legion'
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 Loyal Legion's listings.}
7
+ spec.summary = %q{See above.}
8
+ spec.homepage = 'https://github.com/onewheelskyward/lita-onewheel-beer-loyal-legion'
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.7'
18
+ spec.add_runtime_dependency 'rest-client', '~> 1.8'
19
+ spec.add_runtime_dependency 'nokogiri', '~> 1.6'
20
+ spec.add_runtime_dependency 'sanitize', '~> 4.0'
21
+ spec.add_runtime_dependency 'lita-onewheel-beer-base', '~> 2'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.3'
24
+
25
+ # spec.add_development_dependency 'pry-byebug', '~> 3.1'
26
+ spec.add_development_dependency 'rake', '~> 10.4'
27
+ spec.add_development_dependency 'rack-test', '~> 0.6'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'simplecov', '~> 0.10'
30
+ spec.add_development_dependency 'coveralls', '~> 0.8'
31
+ end