beer-advocate-cli 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfc4114a5026ff4039bac75337b721c38e848e430962451309e048f63a097328
4
- data.tar.gz: 2118f459a6e7d59ceb1ed624e776d5252674b185965ccc8b1a9e1dc5e8f1b975
3
+ metadata.gz: 60d58d42e4b3624debf0c1c85c7f92ee01b93c0cf4d89fed3dba6bf559e8f0ec
4
+ data.tar.gz: d74d982cb35bb8c3eaa9a578a5e3d357670ebac1f29f7792f8e7f6febb8e221f
5
5
  SHA512:
6
- metadata.gz: d89e0c8238eae80921e9af4e758ef205dd23668e7f60ad399377b74011e54e69842b4f4094838f84e06e15a651970c42f2a8cf1dc4a255060cc8682f7d24bde5
7
- data.tar.gz: 860df5866715e1857762a3887c888a1f60e8193de3e9676a7512f9ff8ba7caccaf5329fae312ad0cfd7cd093541c9ec6ba4fb92560ddb0de6370697ed4fa442a
6
+ metadata.gz: 9f3689986cbc669f7623ea03115926b20a5a2020d46ab623089090e429ba826f869c37883bdccc9fce0a8c8848b9b7ff8eb84c755d8d4b3be4014413663faf97
7
+ data.tar.gz: a4c3a6b11a2b5c2e93648eb552f37da5fa81e1bed2cfada4d6876e64e0707b5a4d310a87667e6bceec611b8b54301582f596fddd087f14f67bb6747c3edecb87
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beer-advocate-cli (0.2.1)
4
+ beer-advocate-cli (0.2.2)
5
5
  colorize (~> 0.8.1)
6
6
  nokogiri (~> 1.8)
7
7
 
@@ -12,7 +12,7 @@ GEM
12
12
  colorize (0.8.1)
13
13
  method_source (0.9.2)
14
14
  mini_portile2 (2.4.0)
15
- nokogiri (1.10.3)
15
+ nokogiri (1.10.4)
16
16
  mini_portile2 (~> 2.4.0)
17
17
  pry (0.12.2)
18
18
  coderay (~> 1.1.0)
@@ -29,4 +29,4 @@ DEPENDENCIES
29
29
  rake (~> 10.0)
30
30
 
31
31
  BUNDLED WITH
32
- 2.0.1
32
+ 2.0.2
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Beer Advocate CLI Gem
2
2
 
3
- This gem enables you to browse the Beer Advocate website (beeradvocate.com) in a CLI.
3
+ This ruby gem enables you to browse the Beer Advocate website (beeradvocate.com) in a CLI.
4
4
 
5
- ## Installation
5
+ ## Usage
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'beer-advocate-cli-gem'
10
+ gem 'beer-advocate-cli'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -16,25 +16,7 @@ And then execute:
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install beer-advocate-cli-gem
20
-
21
- ## Usage
22
-
23
- * ~ Mac Terminal installation not working...any input highly appreciated... ~
24
-
25
- If using the Mac Terminal app, ensure Xcode is installed:
26
-
27
- xcode-select --install
28
-
29
- Then type:
30
-
31
- ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
32
-
33
- brew install ruby
34
-
35
- sudo gem install beer-advocate-cli -n /usr/local/bin
36
-
37
- * ~ ~
19
+ $ gem install beer-advocate-cli
38
20
 
39
21
  To run the CLI, simply type 'beer-advocate'.
40
22
 
@@ -42,7 +24,7 @@ Video walkthrough: https://www.youtube.com/watch?v=0gne-y8op7k&t=2s
42
24
 
43
25
  ## Development
44
26
 
45
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
27
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bin/beer-advocate` to run the app.
46
28
 
47
29
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
30
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'bundler/setup'
4
- require 'beer_advocate'
4
+ require 'beer-advocate'
5
5
 
6
6
  BeerAdvocate::CLI.new.run
@@ -1,6 +1,7 @@
1
1
  require 'nokogiri'
2
2
  require 'open-uri'
3
3
  require 'colorize'
4
+ require 'pry'
4
5
 
5
6
  require_relative './beer_advocate/version'
6
7
 
@@ -18,9 +18,9 @@ class BeerAdvocate::CLI
18
18
  def take_input
19
19
  input = gets.strip.downcase
20
20
  if input == "exit"
21
- puts " - - - - - - - - - - -".light_blue
21
+ puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
22
22
  puts "Goodbye!"
23
- puts " - - - - - - - - - - -".light_blue
23
+ puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
24
24
  exit
25
25
  elsif input == "menu"
26
26
  run
@@ -153,7 +153,7 @@ class BeerAdvocate::CLI
153
153
  @styles.uniq!
154
154
  @styles.sort!
155
155
 
156
- puts "- - - - - - - - - - - - - - - - -".light_blue
156
+ puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
157
157
  puts "Type a style number:".yellow.bold
158
158
  puts " "
159
159
  @styles.each do |style|
@@ -161,7 +161,7 @@ class BeerAdvocate::CLI
161
161
  end
162
162
  puts " "
163
163
  puts "Type a style number:".yellow.bold
164
- puts "- - - - - - - - - - - - - - - - -".light_blue
164
+ puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
165
165
 
166
166
  show_styles_list_input
167
167
  end
@@ -189,7 +189,7 @@ class BeerAdvocate::CLI
189
189
  score = "Score".yellow.bold
190
190
  complete_beer = green_beer << interlude << bold_brewery << interlude << abv << interlude << score
191
191
 
192
- puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
192
+ puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
193
193
  puts "#{find_style[:style]}".bold
194
194
  puts " "
195
195
  puts "Type a beer name for more info.".yellow.bold
@@ -232,7 +232,7 @@ class BeerAdvocate::CLI
232
232
  style_page_details = BeerAdvocate::Scraper.find_url_details(find_style[:style_url])
233
233
  end
234
234
 
235
- puts "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -".light_blue
235
+ puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
236
236
  puts "#{find_style[:style]}".yellow.bold
237
237
  puts " "
238
238
  puts "#{style_page_details[:description]}"
@@ -242,7 +242,7 @@ class BeerAdvocate::CLI
242
242
  puts "#{style_page_details[:glassware]}".bold
243
243
  puts " "
244
244
  puts "Press '1' for a list of beers of this style.".yellow.bold
245
- puts "- - - - - - - - - - - - - - - - - - - - - -".light_blue
245
+ puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
246
246
 
247
247
  show_style_input
248
248
  end
@@ -258,7 +258,7 @@ class BeerAdvocate::CLI
258
258
  score = "Score".yellow.bold
259
259
  complete_beer = green_beer << interlude << bold_style << interlude << abv << interlude << score
260
260
 
261
- puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
261
+ puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
262
262
  puts "#{find_brewery[:brewery]}".bold
263
263
  puts " "
264
264
  puts "Type a beer name for more info.".yellow.bold
@@ -307,7 +307,7 @@ class BeerAdvocate::CLI
307
307
  brewery_page_details = BeerAdvocate::Scraper.find_url_details(find_brewery[:brewery_url])
308
308
  end
309
309
 
310
- puts "- - - - - - - - - - - - - - - - - - - - - - - - - -".light_blue
310
+ puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
311
311
  puts "#{find_brewery[:brewery]}".yellow.bold
312
312
  puts " "
313
313
  puts "#{brewery_page_details[:type]}"
@@ -319,7 +319,7 @@ class BeerAdvocate::CLI
319
319
  puts "#{brewery_page_details[:website]}"
320
320
  puts " "
321
321
  puts "Press '1' for a list of beers from this brewery.".yellow.bold
322
- puts "- - - - - - - - - - - - - - - - - - - - - - - - - -".light_blue
322
+ puts " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ".light_blue
323
323
 
324
324
  show_brewery_input
325
325
  end
@@ -21,7 +21,7 @@ class BeerAdvocate::Scraper
21
21
  end
22
22
 
23
23
  def self.scrape_list_page
24
- puts "SCRAPING #{BEER_ADVOCATE_URL} ************"
24
+ #puts "SCRAPING #{BEER_ADVOCATE_URL}"
25
25
 
26
26
  html = open(BEER_ADVOCATE_URL)
27
27
  beer_list_page = Nokogiri::HTML(html)
@@ -40,24 +40,26 @@ class BeerAdvocate::Scraper
40
40
  beer_hash[:score] = beer.css("td")[3].text
41
41
  beer_hash[:name_url] = "http://www.beeradvocate.com#{beer.css("td")[1].css("a")[0]["href"]}?sort=topr&start=0"
42
42
  beer_hash[:brewery_url] = "http://www.beeradvocate.com#{beer.css("td")[1].css("a")[1]["href"]}"
43
- beer_hash[:style_url] = "http://www.beeradvocate.com#{beer.css("td")[1].css("a")[2]["href"]}"
43
+ wrong_style_url_with_right_style_id = "http://www.beeradvocate.com#{beer.css("td")[1].css("a")[2]["href"]}"
44
+ style_id = wrong_style_url_with_right_style_id.scan(/\d+/)[0]
45
+ beer_hash[:style_url] = "http://www.beeradvocate.com/beer/styles/#{style_id}"
44
46
  beer_hashes << beer_hash
47
+ #binding.pry
45
48
  end
46
49
 
47
50
  beer_hashes
48
51
  end
49
52
 
50
53
  def self.scrape_name_page(name_url)
51
- puts "SCRAPING #{name_url} ************"
54
+ #puts "SCRAPING #{name_url}"
52
55
 
53
56
  html = open(name_url)
54
57
  name_page = Nokogiri::HTML(html)
55
58
 
56
- info_box = name_page.css("div#info_box.break")
57
- reviews = name_page.css("div#rating_fullview_content_2")
58
-
59
+ info_box = name_page.css("div#info_box")
60
+ reviews = name_page.css("div#rating_fullview_container")
61
+ #binding.pry
59
62
  name_hash = {}
60
- name_hash[:description] = info_box.text.split("\n\n")[7..-1].join("\n\n").strip
61
63
  name_hash[:pdev] = name_page.css("span.ba-pdev").text.strip
62
64
 
63
65
  name_hash[:top_reviews] = []
@@ -78,7 +80,7 @@ class BeerAdvocate::Scraper
78
80
  end
79
81
 
80
82
  def self.scrape_brewery_page(brewery_url)
81
- puts "SCRAPING #{brewery_url} ************"
83
+ #puts "SCRAPING #{brewery_url}"
82
84
 
83
85
  html = open(brewery_url)
84
86
  brewery_page = Nokogiri::HTML(html)
@@ -86,13 +88,17 @@ class BeerAdvocate::Scraper
86
88
  info_box = brewery_page.css("div#info_box.break")
87
89
  info_box.css("br").each{|br| br.replace("\n")}
88
90
  info_array = info_box.text.split("\n\n\n\n")
89
- jumbled_phone_number = info_array[2].split("\n\n")[1]
90
-
91
+ jumbled_phone_number = info_array[1].split("\n\n")[1]
92
+
93
+ #binding.pry
94
+
91
95
  brewery_hash = {}
92
- brewery_hash[:type] = info_array[1]
93
- brewery_hash[:address] = info_array[2].split("\n\n")[0]
96
+ brewery_hash[:type] = info_array[0].strip
97
+ brewery_hash[:address] = info_array[1].split("\n\n")[0]
94
98
  brewery_hash[:phone_number] = jumbled_phone_number.split("|")[0].strip
95
99
  brewery_hash[:website] = jumbled_phone_number.split("\n")[1].strip
100
+
101
+ #binding.pry
96
102
 
97
103
  scraped_url_hash = {}
98
104
  scraped_url_hash[brewery_url.to_sym] = brewery_hash
@@ -102,7 +108,7 @@ class BeerAdvocate::Scraper
102
108
  end
103
109
 
104
110
  def self.scrape_style_page(style_url)
105
- puts "SCRAPING #{style_url} ************"
111
+ #puts "SCRAPING #{style_url}"
106
112
 
107
113
  html = open(style_url)
108
114
  style_page = Nokogiri::HTML(html)
@@ -1,3 +1,3 @@
1
1
  module BeerAdvocate
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beer-advocate-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Tan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,7 +98,7 @@ files:
98
98
  - bin/beer-advocate
99
99
  - bin/console
100
100
  - bin/setup
101
- - lib/beer_advocate.rb
101
+ - lib/beer-advocate.rb
102
102
  - lib/beer_advocate/beer.rb
103
103
  - lib/beer_advocate/brewery.rb
104
104
  - lib/beer_advocate/cli.rb
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 3.0.3
127
+ rubygems_version: 3.0.4
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: A CLI for the Beer Advocate website (beeradvocate.com).