beer_bash 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +74 -0
- data/Rakefile +1 -0
- data/beer_bash.gemspec +24 -0
- data/bin/ontap +23 -0
- data/lib/beer_bash/beer_menus.rb +84 -0
- data/lib/beer_bash/version.rb +4 -0
- data/lib/beer_bash.rb +38 -0
- metadata +112 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8c9dc72c8d34c4b58a55e0afecc9018f921ce972
|
|
4
|
+
data.tar.gz: 30cd95b8c46c02852548f79eb7a867386731ed63
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: da188f55ba7826f4ea78fef716294b17bfe671c4cdf3cd96126acfee56009ef3439b4d1f5a72f1ec35eb58275437353090789df97e5c32535507c0efc1833b97
|
|
7
|
+
data.tar.gz: 454d3df368ea3d55472e5b7898167491b9dec60fe382d76c3da5b50e40f7ac604e636ac4f07141e9edcf7f0e69bfc685d2b8fcabcdb084464576dccb823a534f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Todd Evanoff
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# beer bash
|
|
2
|
+
|
|
3
|
+
See what tasty beverages are on tap at your favorite place, directly from your command line.
|
|
4
|
+
|
|
5
|
+
This only pulls from BeerMenus currently, but perhaps that will change.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
$ gem install beer_bash
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
$ ontap at the owl farm
|
|
16
|
+
|
|
17
|
+
+----------------------------------------------------+------+-------------+--------+
|
|
18
|
+
| The Owl Farm * Updated on 03/31/2014 |
|
|
19
|
+
+----------------------------------------------------+------+-------------+--------+
|
|
20
|
+
| Beer | ABV | Format | Price |
|
|
21
|
+
+----------------------------------------------------+------+-------------+--------+
|
|
22
|
+
| Aecht Schlenkerla Fastenbier | 5.5 | 12oz. Draft | $8.00 |
|
|
23
|
+
| Against The Grain Da Butt | 6.8 | 12oz. Draft | $8.00 |
|
|
24
|
+
| Allagash Saison | 6.1 | 12oz. Draft | $7.00 |
|
|
25
|
+
| Anchor Brekle’s Brown | 6.0 | 16oz. Draft | $7.00 |
|
|
26
|
+
| Barrier Mollycoddle English Mild Nitro | | 16oz. Draft | $6.00 |
|
|
27
|
+
| BFM Bon Chien Zymatore PX | 8.0 | 8oz. Draft | $10.00 |
|
|
28
|
+
| Brooklyn Dry Irish Stout | 4.7 | 16oz. Draft | $6.00 |
|
|
29
|
+
| Founders Pale Ale | 5.4 | 16oz. Draft | $6.00 |
|
|
30
|
+
| Great South Bay Dirty Deeds | 10.0 | 8oz. Draft | $5.00 |
|
|
31
|
+
| Greenport Harbor NY Common | 5.0 | 16oz. Draft | $6.00 |
|
|
32
|
+
| Narragansett Lager | 5.0 | 16oz. Draft | $4.00 |
|
|
33
|
+
| Other Half Lambeek 86 | 5.9 | 12oz. Draft | $7.00 |
|
|
34
|
+
| Peak Organic Hop Noir | 8.2 | 16oz. Draft | $6.00 |
|
|
35
|
+
| Professor Fritz Briem Grodziskie | 4.0 | 12oz. Draft | $9.00 |
|
|
36
|
+
| Sierra Nevada Bigfoot 2014 | 9.6 | 12oz. Draft | $7.00 |
|
|
37
|
+
| Sierra Nevada Ruthless Rye IPA | 6.6 | 16oz. Draft | $6.00 |
|
|
38
|
+
| Stillwater/ Omnipollo Remix Project Nebuchadnezzar | 6.0 | 12oz. Draft | $9.00 |
|
|
39
|
+
| Stone Enjoy By 04.20.14 | 9.4 | 12oz. Draft | $7.00 |
|
|
40
|
+
| Stone Stochasticity Project Grapefruit Slam IPA | 8.2 | 12oz. Draft | $7.00 |
|
|
41
|
+
| Stoudt's Karnival Kolsch | 4.8 | 16oz. Draft | $6.00 |
|
|
42
|
+
| Thirsty Dog Irish Setter Red | 5.9 | 16oz. Draft | $7.00 |
|
|
43
|
+
| Timmermans Bourgogne des Flandres Brune | 5.0 | 12oz. Draft | $8.00 |
|
|
44
|
+
| Toccalmatto Kilowatt | 8.0 | 8oz. Draft | $8.00 |
|
|
45
|
+
| To Ol Snowball Saison Ale | 8.0 | 8oz. Draft | $7.00 |
|
|
46
|
+
| Victory Donnybrook Stout Nitro | 3.7 | 16oz. Draft | $6.00 |
|
|
47
|
+
| Victory Hop Ticket #2 Hoppy Wheat | | 16oz. Draft | $6.00 |
|
|
48
|
+
| White Birch Hop Session Ale | 5.0 | 16oz. Draft | $7.00 |
|
|
49
|
+
| Wild Beer Co Iduna Cru | 9.0 | 8oz. Draft | $7.00 |
|
|
50
|
+
+----------------------------------------------------+------+-------------+--------+
|
|
51
|
+
|
|
52
|
+
Look at that, the BFM Zymatore is on tap. Why am I at home working on this?
|
|
53
|
+
|
|
54
|
+
To look up a name with apostrophes and such, use quotes:
|
|
55
|
+
|
|
56
|
+
$ ontap at "decicco's"
|
|
57
|
+
|
|
58
|
+
The 'at' is also optional if you like to keep things short:
|
|
59
|
+
|
|
60
|
+
$ ontap double windsor
|
|
61
|
+
|
|
62
|
+
## Contributing
|
|
63
|
+
|
|
64
|
+
1. Fork it
|
|
65
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
66
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
67
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
68
|
+
5. Create new Pull Request
|
|
69
|
+
6. Big thanks from me
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## Attribution
|
|
73
|
+
|
|
74
|
+
This gem was inspired by [Barcade](https://github.com/maxstoller/barcade). I just needed more options.
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/beer_bash.gemspec
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'beer_bash/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = 'beer_bash'
|
|
8
|
+
s.version = BeerBash::VERSION
|
|
9
|
+
s.authors = ['Todd Evanoff']
|
|
10
|
+
s.email = ['evanoff@gmail.com']
|
|
11
|
+
s.summary = %q{See what tasty beverages are on tap at your favorite place, directly from your command line.}
|
|
12
|
+
s.homepage = 'http://github.com/tevanoff/beer_bash'
|
|
13
|
+
s.license = 'MIT'
|
|
14
|
+
s.files = `git ls-files -z`.split("\x0")
|
|
15
|
+
s.require_paths = ['lib']
|
|
16
|
+
s.bindir = 'bin'
|
|
17
|
+
s.executables << 'ontap'
|
|
18
|
+
|
|
19
|
+
s.add_development_dependency 'rake'
|
|
20
|
+
|
|
21
|
+
s.add_dependency 'commander'
|
|
22
|
+
s.add_dependency 'mechanize'
|
|
23
|
+
s.add_dependency 'terminal-table'
|
|
24
|
+
end
|
data/bin/ontap
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'commander/import'
|
|
5
|
+
require 'beer_bash'
|
|
6
|
+
|
|
7
|
+
program :version, BeerBash::VERSION
|
|
8
|
+
program :description, 'See what tasty beverages are on tap at your favorite place, directly from your command line.'
|
|
9
|
+
|
|
10
|
+
default_command :at
|
|
11
|
+
|
|
12
|
+
command :at do |c|
|
|
13
|
+
c.syntax = 'ontap at some place'
|
|
14
|
+
c.description = "See what's on tap at the given place."
|
|
15
|
+
|
|
16
|
+
c.action do |args, options|
|
|
17
|
+
if args.length < 1
|
|
18
|
+
raise 'Where?'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
BeerBash.on_tap_at(args * ' ')
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
module BeerBash
|
|
2
|
+
module BeerMenus
|
|
3
|
+
|
|
4
|
+
class Place
|
|
5
|
+
def self.search(name)
|
|
6
|
+
Scraper.new.places(name)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
attr_reader :name, :path
|
|
10
|
+
|
|
11
|
+
def initialize(name, path)
|
|
12
|
+
@name = name
|
|
13
|
+
@path = path
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def on_tap
|
|
17
|
+
Scraper.new.taps(path)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_s
|
|
21
|
+
name
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
TapList = Struct.new(:updated_at, :taps)
|
|
26
|
+
|
|
27
|
+
Beer = Struct.new(:name, :abv, :format, :price) do
|
|
28
|
+
def on_tap?
|
|
29
|
+
format =~ /draft|cask|growler/i
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class Scraper
|
|
34
|
+
BASE_URL = 'http://www.beermenus.com'
|
|
35
|
+
|
|
36
|
+
def places(name)
|
|
37
|
+
page = scrape(places_url(name))
|
|
38
|
+
links = page.links_with(href: %r"/places/\d+-") # like /places/12-some-place
|
|
39
|
+
links.collect {|link| Place.new(link.to_s, link.href)}
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def taps(place_path)
|
|
43
|
+
page = scrape(taps_url(place_path))
|
|
44
|
+
TapList.new(find_updated(page), find_taps(page))
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def agent
|
|
50
|
+
@agent ||= Mechanize.new
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def scrape(url)
|
|
54
|
+
agent.get(url)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def places_url(place_name)
|
|
58
|
+
URI.escape("#{BASE_URL}/search?q=#{place_name}")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def taps_url(place_path)
|
|
62
|
+
URI.escape("#{BASE_URL}/#{place_path}")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def find_updated(page)
|
|
66
|
+
page.search('//div[contains(@class,"content")]/p[contains(text(),"Updated: ")]')
|
|
67
|
+
.first.text.strip.match(/Updated: (.*)/)[1] rescue '???'
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def find_taps(page)
|
|
71
|
+
page.search('//table[contains(@class,"beermenu")]/tbody/tr').each_with_object([]) do |row, beers|
|
|
72
|
+
next unless row.element_children.size == 4 # some rows are for a description
|
|
73
|
+
|
|
74
|
+
name = row.at('td[1]').text.strip
|
|
75
|
+
abv = row.at('td[2]').text.strip
|
|
76
|
+
format = row.at('td[3]').text.strip
|
|
77
|
+
price = row.at('td[4]').text.strip
|
|
78
|
+
beer = Beer.new(name, abv, format, price)
|
|
79
|
+
beers << beer if beer.on_tap?
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
data/lib/beer_bash.rb
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
require 'beer_bash/beer_menus'
|
|
3
|
+
require 'beer_bash/version'
|
|
4
|
+
require 'mechanize'
|
|
5
|
+
require 'terminal-table'
|
|
6
|
+
|
|
7
|
+
module BeerBash
|
|
8
|
+
class << self
|
|
9
|
+
def on_tap_at(name)
|
|
10
|
+
places = BeerMenus::Place.search(name)
|
|
11
|
+
place = choose_place(places) or raise "Sorry, I couldn't find a place called #{name}"
|
|
12
|
+
print(place)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def choose_place(places)
|
|
18
|
+
if places.size == 1
|
|
19
|
+
places.first
|
|
20
|
+
elsif places.size > 1
|
|
21
|
+
choose("\n** Which one of these did you have in mind?\n\n", *places)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def print(place)
|
|
26
|
+
tap_list = place.on_tap
|
|
27
|
+
|
|
28
|
+
table = Terminal::Table.new do |t|
|
|
29
|
+
t.title = "#{place} * Updated on #{tap_list.updated_at}"
|
|
30
|
+
t.headings = %w(Beer ABV Format Price)
|
|
31
|
+
t.rows = tap_list.taps.collect {|beer| [beer.name, beer.abv, beer.format, beer.price]}
|
|
32
|
+
(1..3).each {|idx| t.align_column(idx, :right)}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
puts table
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: beer_bash
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Todd Evanoff
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-04-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rake
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '>='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '>='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: commander
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: mechanize
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - '>='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: terminal-table
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - '>='
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
description:
|
|
70
|
+
email:
|
|
71
|
+
- evanoff@gmail.com
|
|
72
|
+
executables:
|
|
73
|
+
- ontap
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- .gitignore
|
|
78
|
+
- Gemfile
|
|
79
|
+
- LICENSE.txt
|
|
80
|
+
- README.md
|
|
81
|
+
- Rakefile
|
|
82
|
+
- beer_bash.gemspec
|
|
83
|
+
- bin/ontap
|
|
84
|
+
- lib/beer_bash.rb
|
|
85
|
+
- lib/beer_bash/beer_menus.rb
|
|
86
|
+
- lib/beer_bash/version.rb
|
|
87
|
+
homepage: http://github.com/tevanoff/beer_bash
|
|
88
|
+
licenses:
|
|
89
|
+
- MIT
|
|
90
|
+
metadata: {}
|
|
91
|
+
post_install_message:
|
|
92
|
+
rdoc_options: []
|
|
93
|
+
require_paths:
|
|
94
|
+
- lib
|
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - '>='
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - '>='
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '0'
|
|
105
|
+
requirements: []
|
|
106
|
+
rubyforge_project:
|
|
107
|
+
rubygems_version: 2.0.14
|
|
108
|
+
signing_key:
|
|
109
|
+
specification_version: 4
|
|
110
|
+
summary: See what tasty beverages are on tap at your favorite place, directly from
|
|
111
|
+
your command line.
|
|
112
|
+
test_files: []
|