ma_breweries 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +1 -4
- data/bin/ma_breweries +2 -2
- data/lib/ma_breweries/brewery.rb +56 -0
- data/lib/ma_breweries/cli.rb +116 -0
- data/lib/ma_breweries/version.rb +1 -1
- data/lib/ma_breweries.rb +7 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3fb5f15bbc1a8d1f4068b443020a095d948013296319c9408a2f6e9d70efd40
|
4
|
+
data.tar.gz: dfeea8b72bda4d870722ae468d4d15aea1cb3d1237f683600f0fccdadca1e6ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f368f7f80c25543cc8c82072910b9b9c7bfc2a28b0e71fec21eea270fb362dea08c193ea83fc5ac0e912d41c8f763276def2534814fc7621760873478701963
|
7
|
+
data.tar.gz: a30e666b0cd168ce4878f0367660af2bcc90ec8636713610950ffc8b201e7310eb78dfabf57e268a74d2d360b2fb6e9381bad5153487b04f01f2eaf24afa34ad
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ma_breweries (0.1.
|
4
|
+
ma_breweries (0.1.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
pry (0.12.2)
|
13
13
|
coderay (~> 1.1.0)
|
14
14
|
method_source (~> 0.9.0)
|
15
|
-
rake (
|
15
|
+
rake (12.3.2)
|
16
16
|
|
17
17
|
PLATFORMS
|
18
18
|
ruby
|
@@ -25,4 +25,4 @@ DEPENDENCIES
|
|
25
25
|
rake
|
26
26
|
|
27
27
|
BUNDLED WITH
|
28
|
-
1.17.
|
28
|
+
1.17.3
|
data/README.md
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# MaBreweries
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
3
|
+
Brewery search that allows you to find all of the local Massachusetts breweries. You are able to list all of the breweries by name in a numbered list. Also you can search all of the breweries by Name, Brewery type, Street, and City. This CLI project is based on the Open Brewery DB API.
|
7
4
|
## Installation
|
8
5
|
|
9
6
|
Add this line to your application's Gemfile:
|
data/bin/ma_breweries
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
2
|
+
require_relative "../lib/ma_breweries"
|
3
|
+
MaBreweries::CLI.new.call
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class MaBreweries::BREWERY
|
2
|
+
|
3
|
+
attr_accessor :name, :brewery_type, :street, :city, :state, :postal_code, :country, :phone, :website_url
|
4
|
+
@@all = []
|
5
|
+
|
6
|
+
def initialize(attributes)
|
7
|
+
attributes.each do |key, value|
|
8
|
+
if self.respond_to?(key)
|
9
|
+
self.send(("#{key}="), value)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
@@all << self
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.all
|
16
|
+
@@all
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.all_names
|
20
|
+
self.all.each_with_index do |brewery, i|
|
21
|
+
puts "#{i+1}: #{brewery.name}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.find_by_name(name)
|
26
|
+
self.all.detect {|brewery| brewery.name.downcase == name.downcase}
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.find_by_brewery_type(brewery_type)
|
31
|
+
self.all.select {|brewery| brewery.brewery_type.downcase == brewery_type.downcase}
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.find_by_street(street)
|
35
|
+
self.all.select {|brewery| brewery.street.downcase == street.downcase}
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.find_by_city(city)
|
39
|
+
self.all.select {|brewery| brewery.city.downcase == city.downcase}
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.all_names
|
43
|
+
self.all.each_with_index do |brewery, i|
|
44
|
+
puts "#{i+1}: #{brewery.name}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def brew_info
|
49
|
+
puts "Brewery Name: #{self.name}"
|
50
|
+
puts "Brewery Type: #{self.brewery_type}"
|
51
|
+
puts "Adress: #{self.street} #{self.city} #{self.state}, #{self.postal_code} #{self.country}"
|
52
|
+
puts "Phone Number: #{self.phone}"
|
53
|
+
puts "Website: #{self.website_url}"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class MaBreweries::CLI
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
boolean = true
|
9
|
+
i = 1
|
10
|
+
while boolean do
|
11
|
+
page = open("https://api.openbrewerydb.org/breweries?by_state=Massachusetts&per_page=50&page=#{i}")
|
12
|
+
i+=1
|
13
|
+
breweries = JSON.parse(page.read)
|
14
|
+
if breweries.count == 0
|
15
|
+
boolean = false
|
16
|
+
else
|
17
|
+
breweries.each do |attributes_hash|
|
18
|
+
MaBreweries::BREWERY.new(attributes_hash)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def call
|
25
|
+
puts " ** Welcome to your one stop search or all of your local breweries. **"
|
26
|
+
puts "\n"
|
27
|
+
puts " ** Do you want to know where the brews are? **"
|
28
|
+
puts "\n"
|
29
|
+
puts " ** I can help you search but you will have to share! **"
|
30
|
+
puts "\n"
|
31
|
+
|
32
|
+
menu
|
33
|
+
brewery_input = gets.chomp.downcase
|
34
|
+
while (brewery_input != "exit")
|
35
|
+
if brewery_input == "name"
|
36
|
+
search_breweries_by_name
|
37
|
+
elsif brewery_input == "type"
|
38
|
+
search_breweries_by_type
|
39
|
+
elsif brewery_input == "street"
|
40
|
+
search_breweries_by_street
|
41
|
+
elsif brewery_input == "city"
|
42
|
+
search_breweries_by_city
|
43
|
+
elsif brewery_input == "all"
|
44
|
+
show_all_breweries
|
45
|
+
else
|
46
|
+
puts " ** I am sorry you won't find any brews that way! ** "
|
47
|
+
end
|
48
|
+
menu
|
49
|
+
brewery_input = gets.chomp.downcase
|
50
|
+
end
|
51
|
+
puts " ** Peace out! Have fun and drive carefully! ** "
|
52
|
+
end
|
53
|
+
|
54
|
+
def menu
|
55
|
+
puts " * There are many ways fo you to search."
|
56
|
+
puts "\n"
|
57
|
+
puts " * To search by brewery name please enter - Name"
|
58
|
+
puts " * To search by brewery type please enter - Type"
|
59
|
+
puts " * To search by street name please enter - Street"
|
60
|
+
puts " * To search by city please enter - City"
|
61
|
+
puts " * To list all the breweries by name please enter - All"
|
62
|
+
puts "\n"
|
63
|
+
puts " * To exit please enter - exit"
|
64
|
+
end
|
65
|
+
|
66
|
+
def search_breweries_by_name
|
67
|
+
puts "Please enter the brewery name: "
|
68
|
+
input = gets.chomp
|
69
|
+
brewery = MaBreweries::BREWERY.find_by_name(input)
|
70
|
+
if brewery
|
71
|
+
brewery.brew_info
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def search_breweries_by_type
|
76
|
+
puts "Please enter the brewery type: "
|
77
|
+
input = gets.chomp
|
78
|
+
breweries = MaBreweries::BREWERY.find_by_brewery_type(input)
|
79
|
+
if breweries
|
80
|
+
breweries.each do |brewery|
|
81
|
+
brewery.brew_info
|
82
|
+
puts "\n"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def search_breweries_by_street
|
88
|
+
puts "Pease enter the street you think the brews are on:"
|
89
|
+
input = gets.chomp
|
90
|
+
breweries = MaBreweries::BREWERY.find_by_street(input)
|
91
|
+
if breweries
|
92
|
+
breweries.each do |brewery|
|
93
|
+
brewery.brew_info
|
94
|
+
puts "\n"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def search_breweries_by_city
|
101
|
+
puts "Please enter the city you would like to search in:"
|
102
|
+
input = gets.chomp
|
103
|
+
breweries = MaBreweries::BREWERY.find_by_city(input)
|
104
|
+
if breweries
|
105
|
+
breweries.each do |brewery|
|
106
|
+
brewery.brew_info
|
107
|
+
puts "\n"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def show_all_breweries
|
113
|
+
MaBreweries::BREWERY.all_names
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
data/lib/ma_breweries/version.rb
CHANGED
data/lib/ma_breweries.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
require "
|
1
|
+
require "pry"
|
2
|
+
require "open-uri"
|
3
|
+
require "json"
|
4
|
+
require_relative "./ma_breweries/version"
|
5
|
+
require_relative "./ma_breweries/brewery"
|
6
|
+
require_relative "./ma_breweries/cli"
|
7
|
+
|
2
8
|
|
3
9
|
module MaBreweries
|
4
10
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ma_breweries
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "'Justin Beaulieu'"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,6 +85,8 @@ files:
|
|
85
85
|
- bin/ma_breweries
|
86
86
|
- bin/setup
|
87
87
|
- lib/ma_breweries.rb
|
88
|
+
- lib/ma_breweries/brewery.rb
|
89
|
+
- lib/ma_breweries/cli.rb
|
88
90
|
- lib/ma_breweries/version.rb
|
89
91
|
- ma_breweries.gemspec
|
90
92
|
homepage: https://github.com/Beaulieu527/ma_breweries
|
@@ -106,8 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
108
|
- !ruby/object:Gem::Version
|
107
109
|
version: '0'
|
108
110
|
requirements: []
|
109
|
-
|
110
|
-
rubygems_version: 2.7.8
|
111
|
+
rubygems_version: 3.0.2
|
111
112
|
signing_key:
|
112
113
|
specification_version: 4
|
113
114
|
summary: Cli for displaying all local breweries in Mass.
|