brewery_search 0.1.0 → 0.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +17 -1
- data/bin/brewery-search +2 -2
- data/brewery_search-0.1.0.gem +0 -0
- data/brewery_search.gemspec +2 -8
- data/config/environment.rb +1 -0
- data/lib/brewery_search/brewery.rb +18 -5
- data/lib/brewery_search/cli.rb +6 -9
- data/lib/brewery_search/scraper.rb +2 -1
- data/lib/brewery_search/version.rb +1 -1
- metadata +19 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 578c2464bb9048a6758fb13eca2d9ac70ddd651d
|
|
4
|
+
data.tar.gz: 3ac18b0061c01c338c5ccdd8b72a60340fe7a30b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bfbdf4f520031a0b59566f9eaf369a6fbcc6030b30aab2c4eab1e5598c711d0d59ecba6bed8073587ca8ce25019fefb4b2053ffb59c0422e680aac033c3d10b6
|
|
7
|
+
data.tar.gz: 99f258025db39cb530a5623a3803452ae2c9d0e2debf015f81688343e3f7c37a8df54e40599375c0afd9b5d8ed542af8963029019dfa12683155c816faedab1b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Type the following to get started:
|
|
|
24
24
|
|
|
25
25
|
$ brewery-search
|
|
26
26
|
|
|
27
|
-
Follow the on-screen prompts to continue.
|
|
27
|
+
A user will be greeted with a welcome screen. Follow the on-screen prompts to continue.
|
|
28
28
|
|
|
29
29
|
Users will have the ability to search by state abbreviations (case senstitive). From there a user will be presented with a list of all registered breweries in that state. A user can call
|
|
30
30
|
|
|
@@ -32,6 +32,22 @@ Users will have the ability to search by state abbreviations (case senstitive).
|
|
|
32
32
|
|
|
33
33
|
to receive a prompt to filter by a specific city, otherwise they can select the number of any brewery for more information.
|
|
34
34
|
|
|
35
|
+
Additional commands from the menu include:
|
|
36
|
+
|
|
37
|
+
$ new search
|
|
38
|
+
$ exit
|
|
39
|
+
|
|
40
|
+
New search will bring the user back to the beginning to search for a different state. Exit will quit the program.
|
|
41
|
+
|
|
42
|
+
When viewing additional information for any brewery, a user will be able to do any of the following commands (if that information is made available) to either launch the corresponding page, return, or exit the program:
|
|
43
|
+
|
|
44
|
+
$ Website
|
|
45
|
+
$ Facebook
|
|
46
|
+
$ Twitter
|
|
47
|
+
$ Instagram
|
|
48
|
+
$ Menu
|
|
49
|
+
$ Exit
|
|
50
|
+
|
|
35
51
|
## Development
|
|
36
52
|
|
|
37
53
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/bin/brewery-search
CHANGED
|
Binary file
|
data/brewery_search.gemspec
CHANGED
|
@@ -9,12 +9,10 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.email = ["btmcco8@gmail.com"]
|
|
10
10
|
|
|
11
11
|
spec.summary = "A CLI brewery directory leveraging BrewBound"
|
|
12
|
-
spec.description = "Allows a user to search for breweries by state by utilizing the www.brewbound.com brewery database.
|
|
12
|
+
spec.description = "Allows a user to search for breweries by state by utilizing the www.brewbound.com brewery database. Results will be returned as a numbered list. Contains a welcome screen upon launch and will have several prompts for a user to follow."
|
|
13
13
|
spec.homepage = "https://github.com/btmccollum/brewery_search"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
16
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
16
|
if spec.respond_to?(:metadata)
|
|
19
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
20
18
|
else
|
|
@@ -22,22 +20,18 @@ Gem::Specification.new do |spec|
|
|
|
22
20
|
"public gem pushes."
|
|
23
21
|
end
|
|
24
22
|
|
|
25
|
-
# Specify which files should be added to the gem when it is released.
|
|
26
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
27
23
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
28
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
29
25
|
end
|
|
30
26
|
spec.bindir = "bin"
|
|
31
27
|
spec.executables = ["brewery-search"]
|
|
32
|
-
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
33
|
-
# spec.executables << "brewery-search"
|
|
34
28
|
spec.require_paths = ["lib"]
|
|
35
29
|
|
|
36
30
|
spec.add_development_dependency "bundler", "~> 1.16"
|
|
37
31
|
spec.add_development_dependency "rake", "~> 10.0"
|
|
38
32
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
33
|
+
spec.add_development_dependency "require_all", "~> 2.0"
|
|
39
34
|
spec.add_development_dependency "nokogiri", "~> 1.8", ">= 1.8.4"
|
|
40
35
|
spec.add_development_dependency "launchy", "~> 2.4", ">= 2.4.3"
|
|
41
|
-
spec.add_development_dependency "require_all", "~> 2.0"
|
|
42
36
|
|
|
43
37
|
end
|
data/config/environment.rb
CHANGED
|
@@ -4,6 +4,7 @@ class BrewerySearch::Brewery
|
|
|
4
4
|
|
|
5
5
|
@@all = []
|
|
6
6
|
|
|
7
|
+
#creates a brewery entry for every result returned by the scraped state
|
|
7
8
|
def self.create_from_state_scrape(input)
|
|
8
9
|
search_state = BrewerySearch::Scraper.scrape_by_state(input)
|
|
9
10
|
search_state.pages.each do |page|
|
|
@@ -25,22 +26,34 @@ class BrewerySearch::Brewery
|
|
|
25
26
|
def create_profile_attributes
|
|
26
27
|
profile = BrewerySearch::Scraper.scrape_by_profile(self.site_url)
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
#determining address based one one of several formats the site can use
|
|
30
|
+
if (profile.css("div #overview dl dd dt").text.include?("PARENT") || profile.css("div #overview dl dd dt").text.include?("Founded")) && !!profile.css("div #overview dl dd")[0].text.match(/[0-9]/) == true
|
|
31
|
+
self.address = profile.css("div #overview dl dd")[3].css("a").attr("href").text.gsub(/\bhttps:.*=(?:,)?/, '')
|
|
32
|
+
elsif profile.css("div #overview dl dd dt").text.include?("PARENT") || profile.css("div #overview dl dd dt").text.include?("Founded")
|
|
33
|
+
self.address = profile.css("div #overview dl dd")[2].css("a").attr("href").text.gsub(/\bhttps:.*=(?:,)?/, '')
|
|
34
|
+
elsif profile.css("div #overview dl dd")[0].text.include?("JOB") && !!profile.css("div #overview dl dd")[0].text.match(/[0-9]/) == true
|
|
35
|
+
self.address = profile.css("div #overview dl dd")[3].css("a").attr("href").text.gsub(/\bhttps:.*=(?:,)?/, '')
|
|
30
36
|
else
|
|
31
|
-
self.address = profile.css("div #overview dl dd")[2].css("a").attr("href").text.gsub(/\bhttps
|
|
37
|
+
self.address = profile.css("div #overview dl dd")[2].css("a").attr("href").text.gsub(/\bhttps:.*=(?:,)?/, '')
|
|
32
38
|
end
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
#determining overview based on one of several formats the site can use
|
|
41
|
+
if (profile.css("div #overview dl dd dt").text.include?("PARENT") || profile.css("div #overview dl dd dt").text.include?("Founded")) && !!profile.css("div #overview dl dd")[0].text.match(/[0-9]/) == true
|
|
42
|
+
self.overview = profile.css("div #overview dl dd")[4].text
|
|
43
|
+
elsif profile.css("div #overview dl dd dt").text.include?("PARENT") || profile.css("div #overview dl dd dt").text.include?("Founded")
|
|
44
|
+
self.overview = profile.css("div #overview dl dd")[3].text
|
|
45
|
+
elsif profile.css("div #overview dl dd")[0].text.include?("JOB") && !!profile.css("div #overview dl dd")[0].text.match(/[0-9]/) == true
|
|
35
46
|
self.overview = profile.css("div #overview dl dd")[4].text
|
|
36
47
|
else
|
|
37
48
|
self.overview = profile.css("div #overview dl dd")[3].text
|
|
38
49
|
end
|
|
39
|
-
|
|
50
|
+
|
|
51
|
+
#determine phone number
|
|
40
52
|
if profile.css("div.contact dt")[1].text == "Phone"
|
|
41
53
|
self.phone = profile.css("div.contact dd")[1].text
|
|
42
54
|
end
|
|
43
55
|
|
|
56
|
+
#determine external website
|
|
44
57
|
self.external_site = profile.css("div.contact a").attr("href").text
|
|
45
58
|
|
|
46
59
|
#grab social media links depending on what they have available
|
data/lib/brewery_search/cli.rb
CHANGED
|
@@ -50,9 +50,6 @@ class BrewerySearch::CLI
|
|
|
50
50
|
@last_searched_state = input
|
|
51
51
|
if VALID_STATES.include?(input)
|
|
52
52
|
list_breweries(input)
|
|
53
|
-
elsif
|
|
54
|
-
puts "Invalid entry received."
|
|
55
|
-
self.start
|
|
56
53
|
elsif input == "exit"
|
|
57
54
|
self.quit
|
|
58
55
|
elsif input == "BrewBound"
|
|
@@ -158,7 +155,7 @@ class BrewerySearch::CLI
|
|
|
158
155
|
input = gets.strip
|
|
159
156
|
|
|
160
157
|
#has to use @last_brew_list_searched in order to continue to use state specific results
|
|
161
|
-
if input.to_i > 0
|
|
158
|
+
if (input.to_i > 0) && (input.to_i <= @last_brew_list_searched.size)
|
|
162
159
|
brewery = @last_brew_list_searched[input.to_i - 1]
|
|
163
160
|
brewery.create_profile_attributes
|
|
164
161
|
|
|
@@ -205,7 +202,7 @@ class BrewerySearch::CLI
|
|
|
205
202
|
input = gets.strip
|
|
206
203
|
|
|
207
204
|
#has to utilize @last_city_list_searched in order to continue to use city specific results
|
|
208
|
-
if input.to_i > 0
|
|
205
|
+
if (input.to_i > 0) && (input.to_i <= @last_city_list_searched.size)
|
|
209
206
|
brewery = @last_city_list_searched[input.to_i - 1]
|
|
210
207
|
brewery.create_profile_attributes
|
|
211
208
|
|
|
@@ -214,16 +211,16 @@ class BrewerySearch::CLI
|
|
|
214
211
|
input = gets.strip
|
|
215
212
|
if input == "Website"
|
|
216
213
|
Launchy.open("#{brewery.external_site}") {|exception| puts "Attempted to open #{brewery.external_site} but failed due to : #{exception}"}
|
|
217
|
-
self.
|
|
214
|
+
self.city_menu
|
|
218
215
|
elsif input == "Facebook"
|
|
219
216
|
Launchy.open("#{brewery.facebook_link}") {|exception| puts "Attempted to open #{brewery.facebook_link} but failed due to : #{exception}"}
|
|
220
|
-
self.
|
|
217
|
+
self.city_menu
|
|
221
218
|
elsif input == "Twitter"
|
|
222
219
|
Launchy.open("#{brewery.twitter_link}") {|exception| puts "Attempted to open #{brewery.twitter_link} but failed due to : #{exception}"}
|
|
223
|
-
self.
|
|
220
|
+
self.city_menu
|
|
224
221
|
elsif input == "Instagram"
|
|
225
222
|
Launchy.open("#{brewery.insta_link}") {|exception| puts "Attempted to open #{brewery.insta_link} but failed due to : #{exception}"}
|
|
226
|
-
self.
|
|
223
|
+
self.city_menu
|
|
227
224
|
elsif input == "Youtube"
|
|
228
225
|
Launchy.open("#{brewery.youtube_link}") {|exception| puts "Attempted to open #{brewery.youtube_link} but failed due to : #{exception}"}
|
|
229
226
|
self.city_menu
|
|
@@ -16,10 +16,11 @@ class BrewerySearch::Scraper
|
|
|
16
16
|
|
|
17
17
|
page = 2
|
|
18
18
|
|
|
19
|
+
#all state search pages use same HTML format, user input for state abbreviation is injected
|
|
19
20
|
doc = Nokogiri::HTML(open("https://www.brewbound.com/mvc/Breweries/state/#{input}?displayOutOfBiz=False"))
|
|
20
21
|
state_object.pages << doc
|
|
21
22
|
|
|
22
|
-
#is able to scrape data from additional pages when applicable
|
|
23
|
+
#is able to scrape data from additional pages when applicable, all pages use same format for additional page results, # and user input are injected
|
|
23
24
|
while doc.css("table.breweries-list tfoot p.text-center").text.include?("Next") do
|
|
24
25
|
doc = Nokogiri::HTML(open("https://www.brewbound.com/mvc/Breweries/state/#{input}/page/#{page}?displayOutOfBiz=False"))
|
|
25
26
|
state_object.pages << doc
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: brewery_search
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- btmccollum
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-09-
|
|
11
|
+
date: 2018-09-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: require_all
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '2.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '2.0'
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: nokogiri
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -92,23 +106,9 @@ dependencies:
|
|
|
92
106
|
- - ">="
|
|
93
107
|
- !ruby/object:Gem::Version
|
|
94
108
|
version: 2.4.3
|
|
95
|
-
- !ruby/object:Gem::Dependency
|
|
96
|
-
name: require_all
|
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
|
98
|
-
requirements:
|
|
99
|
-
- - "~>"
|
|
100
|
-
- !ruby/object:Gem::Version
|
|
101
|
-
version: '2.0'
|
|
102
|
-
type: :development
|
|
103
|
-
prerelease: false
|
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
-
requirements:
|
|
106
|
-
- - "~>"
|
|
107
|
-
- !ruby/object:Gem::Version
|
|
108
|
-
version: '2.0'
|
|
109
109
|
description: Allows a user to search for breweries by state by utilizing the www.brewbound.com
|
|
110
|
-
brewery database.
|
|
111
|
-
|
|
110
|
+
brewery database. Results will be returned as a numbered list. Contains a welcome
|
|
111
|
+
screen upon launch and will have several prompts for a user to follow.
|
|
112
112
|
email:
|
|
113
113
|
- btmcco8@gmail.com
|
|
114
114
|
executables:
|
|
@@ -126,6 +126,7 @@ files:
|
|
|
126
126
|
- bin/brewery-search
|
|
127
127
|
- bin/console
|
|
128
128
|
- bin/setup
|
|
129
|
+
- brewery_search-0.1.0.gem
|
|
129
130
|
- brewery_search.gemspec
|
|
130
131
|
- config/environment.rb
|
|
131
132
|
- lib/brewery_search.rb
|