lita-onewheel-beer-untappd-lib 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +6 -0
- data/README.md +20 -0
- data/Rakefile +6 -0
- data/lib/lita/handlers/onewheel_beer_untappd_lib.rb +54 -0
- data/lib/lita-onewheel-beer-untappd-lib.rb +3 -0
- data/lita-onewheel-beer-untappd-lib.gemspec +30 -0
- data/spec/fixtures/pp-20220222.html +1486 -0
- data/spec/fixtures/pp.html +1357 -0
- data/spec/lita/handlers/onewheel_beer_untappd_lib_spec.rb +185 -0
- data/spec/spec_helper.rb +13 -0
- metadata +199 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5f89cebc8990f0d552a57b0cc9eabc52656b2705be0e7c50d473914388bd6af4
|
4
|
+
data.tar.gz: f7ec579c126994600f6519227da560f805b1c46e8a9c8e8d45bc9522722dc6e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce03d22c93d6dab0e4023015fafe24458ce3148f29cf5bb0d7f0ded3f2303a8b502c3adbebfb248827f0274af8585102e6fa56d99cc426a46b764aea13aa9f54
|
7
|
+
data.tar.gz: b0a2673adefd227003a062aa6136e23077a9c61c0f70edbd6888a7228122cd257f0eee304023ea414753c7d6ff8792498347919a2581f7c862634468bf6f597b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# lita-onewheel-beer-untappd-lib
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/onewheelskyward/lita-onewheel-beer-untappd-lib.png?branch=master)](https://travis-ci.org/onewheelskyward/lita-onewheel-beer-untappd-lib)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/onewheelskyward/lita-onewheel-beer-untappd-lib/badge.png)](https://coveralls.io/r/onewheelskyward/lita-onewheel-beer-untappd-lib)
|
5
|
+
|
6
|
+
Lib for html processing untappd into a reasonable format.
|
7
|
+
|
8
|
+
e.g. https://untappd.com/v/proper-pint-taproom/6478413
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add lita-onewheel-beer-untappd-lib to your Lita instance's Gemfile:
|
13
|
+
|
14
|
+
``` ruby
|
15
|
+
gem 'lita-onewheel-beer-untappd-lib'
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
subclass it and create your untappd lita handler!
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'lita-onewheel-beer-base'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Lita
|
6
|
+
module Handlers
|
7
|
+
class OnewheelBeerUntappdLib < OnewheelBeerBase
|
8
|
+
|
9
|
+
# This is the worker bee- decoding the html into our "standard" document.
|
10
|
+
# Future implementations could simply override this implementation-specific
|
11
|
+
# code to help this grow more widely.
|
12
|
+
def parse_response(response)
|
13
|
+
Lita.logger.debug 'parse_response started.'
|
14
|
+
|
15
|
+
gimme_what_you_got = {}
|
16
|
+
noko = Nokogiri.HTML response
|
17
|
+
noko.css('div.beer-details').each do |beer_node|
|
18
|
+
# beer_node = beer_node.css('div#section_217106141')
|
19
|
+
name_n_tap = beer_node.css('h5 a').first.children.to_s
|
20
|
+
short_desc = beer_node.css('h5 em').first.children.to_s
|
21
|
+
brewery = beer_node.css('h6 a').first.children.to_s
|
22
|
+
abv_node = beer_node.css('h6 span').first.children.to_s
|
23
|
+
|
24
|
+
# Lita.logger.info("NnT: #{name_n_tap}")
|
25
|
+
/^(?<tap>\d)\.\s*(?<beer_name>.*)/ =~ name_n_tap
|
26
|
+
# tap = name_n_tap[/^\d+/]
|
27
|
+
next if tap.nil?
|
28
|
+
# print "name_n_tap #{name_n_tap}"
|
29
|
+
# beer_name = name_n_tap[/[^\..]+$/].strip
|
30
|
+
abv = abv_node[/^\d+\.\d+/]
|
31
|
+
beer_desc = short_desc
|
32
|
+
|
33
|
+
# full_text_search = "#{tap.sub /\d+/, ''} #{brewery} #{beer_name} #{beer_desc.to_s.gsub /\d+\.*\d*%*/, ''}"
|
34
|
+
# prices = get_prices(beer_node)
|
35
|
+
|
36
|
+
gimme_what_you_got[tap] = {
|
37
|
+
# type: tap_type,
|
38
|
+
# remaining: remaining,
|
39
|
+
brewery: brewery.to_s,
|
40
|
+
name: beer_name.to_s,
|
41
|
+
desc: beer_desc.to_s,
|
42
|
+
abv: abv.to_f
|
43
|
+
# prices: prices,
|
44
|
+
# price: prices[1][:cost],
|
45
|
+
# search: full_text_search
|
46
|
+
}
|
47
|
+
end
|
48
|
+
gimme_what_you_got
|
49
|
+
end
|
50
|
+
|
51
|
+
Lita.register_handler(self)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'lita-onewheel-beer-untappd-lib'
|
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 untappd taproom listings.}
|
7
|
+
spec.summary = spec.description
|
8
|
+
spec.homepage = 'https://github.com/onewheelskyward/lita-onewheel-beer-untappd-lib'
|
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', '~> 2'
|
19
|
+
spec.add_runtime_dependency 'lita-onewheel-beer-base', '~> 2'
|
20
|
+
spec.add_runtime_dependency 'json', '~> 2'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 2'
|
23
|
+
|
24
|
+
# spec.add_development_dependency 'pry-byebug', '~> 3.1'
|
25
|
+
spec.add_development_dependency 'rake', '~> 13'
|
26
|
+
spec.add_development_dependency 'rack-test', '~> 1'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
28
|
+
spec.add_development_dependency 'simplecov', '~> 0'
|
29
|
+
spec.add_development_dependency 'coveralls', '~> 0'
|
30
|
+
end
|