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 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
@@ -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/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,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,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,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,3 @@
1
+ require 'lita'
2
+
3
+ require 'lita/handlers/onewheel_beer_untappd_lib'
@@ -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