cocktail_library 0.1.4 → 0.1.5
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/lib/cocktail_library/cli.rb +48 -45
- data/lib/cocktail_library/cocktail_db.rb +9 -9
- data/lib/cocktail_library/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f07fa3f3a26e2bd59c377ee741eb9ef48b319dfe
|
4
|
+
data.tar.gz: a01e759d00752d8cf2467ccc6e4dea0a197783cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cd66614222e3f5aa20547a83e2934be9952aedc2db62b672f87d3378b509eedb9cddc9b479bab5a11545819484ce3495a9c575917308249a90177f7d63f3941
|
7
|
+
data.tar.gz: 538e36886a98d4338affe76033918e89e730f3cb3fe9925b5c4529f5369d7477f4c7c107a92d58964c664c5b504dd79a6feeebb59f53800d1164480307700ce7
|
data/lib/cocktail_library/cli.rb
CHANGED
@@ -1,58 +1,58 @@
|
|
1
1
|
|
2
2
|
class CocktailLibrary::CLI
|
3
|
-
|
3
|
+
|
4
4
|
def initialize
|
5
5
|
@bases = CocktailLibrary::BASES
|
6
6
|
@cocktail_db = CocktailLibrary::CocktailDB.new
|
7
|
-
end
|
7
|
+
end
|
8
8
|
|
9
9
|
def run
|
10
10
|
greeting
|
11
|
-
base_selection
|
11
|
+
base_selection
|
12
12
|
drinks_available
|
13
13
|
drink_directions
|
14
14
|
end
|
15
15
|
|
16
16
|
def greeting
|
17
|
-
puts <<-DOC
|
18
|
-
|
19
|
-
|
20
|
-
/| /|
|
21
|
-
// ( `""-
|
22
|
-
\\| / .\\___
|
23
|
-
/ . 4
|
24
|
-
/ _ /
|
25
|
-
/ .--'
|
26
|
-
( \\
|
27
|
-
/ \\ \\
|
28
|
-
/ \\ \\ \\
|
29
|
-
, / \\ \\ \\
|
30
|
-
)\\ / \\ \\
|
31
|
-
\\/ | .'` _ \\ \\______/_/
|
32
|
-
\\. / .' '. ,\\ \\/ \\ (o)/
|
33
|
-
\\' / / \\ ; | / \\ ' /
|
34
|
-
\\' \\ | | | | ' \\ /
|
35
|
-
\\, `" | /.| | | ||
|
36
|
-
''-..-\\ _.;.'| |.;-. ||
|
37
|
-
\\ <`.._ )) | .;-.)) / \\
|
38
|
-
(__. ` ))-' \\_ ))' +++++
|
17
|
+
puts <<-DOC
|
18
|
+
|
19
|
+
|
20
|
+
/| /|
|
21
|
+
// ( `""-
|
22
|
+
\\| / .\\___
|
23
|
+
/ . 4
|
24
|
+
/ _ /
|
25
|
+
/ .--'
|
26
|
+
( \\
|
27
|
+
/ \\ \\
|
28
|
+
/ \\ \\ \\
|
29
|
+
, / \\ \\ \\
|
30
|
+
)\\ / \\ \\
|
31
|
+
\\/ | .'` _ \\ \\______/_/
|
32
|
+
\\. / .' '. ,\\ \\/ \\ (o)/
|
33
|
+
\\' / / \\ ; | / \\ ' /
|
34
|
+
\\' \\ | | | | ' \\ /
|
35
|
+
\\, `" | /.| | | ||
|
36
|
+
''-..-\\ _.;.'| |.;-. ||
|
37
|
+
\\ <`.._ )) | .;-.)) / \\
|
38
|
+
(__. ` ))-' \\_ ))' +++++
|
39
39
|
`'--"` `"""`
|
40
40
|
DOC
|
41
41
|
|
42
42
|
puts <<~DOC
|
43
43
|
Hello there, I am Tiki, your very floofy bartender!
|
44
44
|
I'm going to give you a list of drinks based on whatever liquor you have on hand.
|
45
|
-
|
45
|
+
|
46
46
|
What would you like to use for your drink?
|
47
47
|
|
48
48
|
DOC
|
49
|
-
end
|
49
|
+
end
|
50
50
|
|
51
51
|
def base_selection
|
52
52
|
@bases.each_with_index do |base, index|
|
53
53
|
puts "#{index + 1}. #{base}"
|
54
|
-
end
|
55
|
-
|
54
|
+
end
|
55
|
+
|
56
56
|
puts ""
|
57
57
|
puts "Please enter the number of the base you'd like to use, or enter exit to quit."
|
58
58
|
|
@@ -60,36 +60,39 @@ class CocktailLibrary::CLI
|
|
60
60
|
@base_choice = gets.chomp.downcase
|
61
61
|
if @base_choice == "exit"
|
62
62
|
puts ""
|
63
|
-
|
63
|
+
|
64
64
|
puts "Perhaps the smoothie place down the road would be more to your liking."
|
65
65
|
exit
|
66
|
-
elsif
|
66
|
+
elsif @bases[@base_choice.to_i-1] == nil || @base_choice.to_i < 1
|
67
|
+
|
68
|
+
puts ""
|
67
69
|
puts "Ehmm... Our menu is a little limited.. sorry."
|
68
70
|
puts "Do you have anything on hand from these options?"
|
71
|
+
puts ""
|
69
72
|
base_selection
|
70
73
|
else
|
71
74
|
#this is defining the search object
|
72
75
|
@base_type = @bases[@base_choice.to_i-1].downcase
|
73
|
-
end
|
76
|
+
end
|
74
77
|
end
|
75
78
|
|
76
79
|
def drinks_available
|
77
80
|
#this calls the search
|
78
81
|
@drinks_list = @cocktail_db.search_by_base(@base_type)
|
79
|
-
|
80
|
-
#escape for
|
82
|
+
|
83
|
+
#escape for empty return
|
81
84
|
if @drinks_list == nil
|
82
85
|
puts "I'm sorry, we have no idea how to make drinks with #{@base_type.gsub(/\w+/) {|word| word.capitalize}}."
|
83
86
|
puts "Here is a beer."
|
84
87
|
exit(0)
|
85
88
|
else
|
86
89
|
puts "Here are the drinks you can make with #{@base_type.gsub(/\w+/) {|word| word.capitalize}}:"
|
87
|
-
|
90
|
+
|
88
91
|
puts @drinks_list
|
89
|
-
end
|
90
|
-
end
|
92
|
+
end
|
93
|
+
end
|
91
94
|
|
92
|
-
def drink_directions
|
95
|
+
def drink_directions
|
93
96
|
puts ""
|
94
97
|
puts "Which of these would you like to make?"
|
95
98
|
puts ""
|
@@ -111,24 +114,24 @@ class CocktailLibrary::CLI
|
|
111
114
|
puts "Hmm, not sure how to make that one... Sorry about that!"
|
112
115
|
puts ""
|
113
116
|
drink_directions
|
114
|
-
|
115
|
-
else
|
117
|
+
|
118
|
+
else
|
116
119
|
#take drink selection and push it into the API
|
117
120
|
drink = @cocktail_db.drink_components(drink_selection)
|
118
|
-
|
121
|
+
|
119
122
|
puts "One second, let me grab that recipe for you!"
|
120
123
|
sleep(1)
|
121
124
|
|
122
125
|
puts ""
|
123
126
|
puts "Ok, here how to make your #{drink.name.gsub(/\w+/) {|word| word.capitalize}}: "
|
124
|
-
|
127
|
+
|
125
128
|
drink.ingredients.each_with_index do |ing, idx|
|
126
129
|
puts "#{drink.measurements[idx]}: #{ing}"
|
127
|
-
end
|
128
|
-
|
130
|
+
end
|
131
|
+
|
129
132
|
puts "#{drink.instructions}"
|
130
133
|
puts ""
|
131
134
|
puts "Hope you enjoy it!"
|
132
|
-
end
|
135
|
+
end
|
133
136
|
end
|
134
137
|
end
|
@@ -7,32 +7,32 @@ class CocktailLibrary::CocktailDB
|
|
7
7
|
base_results = open("http://www.thecocktaildb.com/api/json/v1/1/filter.php?i=#{base}")
|
8
8
|
|
9
9
|
#this code breaks that object (StringIO) into a parsable hash
|
10
|
-
#and then it returns a list of the names of the drinks
|
10
|
+
#and then it returns a list of the names of the drinks
|
11
11
|
drink_names = []
|
12
12
|
|
13
13
|
JSON.load(base_results)['drinks'].each do |k,v|
|
14
14
|
k.each do |k, v|
|
15
15
|
if k == "strDrink"
|
16
16
|
drink_names << v
|
17
|
-
end
|
17
|
+
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
drink_names
|
21
|
-
end
|
21
|
+
end
|
22
22
|
|
23
23
|
def drink_components(drink)
|
24
24
|
drink_results = open("http://www.thecocktaildb.com/api/json/v1/1/search.php?s=#{drink}")
|
25
25
|
|
26
|
-
drink_details = JSON.load(drink_results)[
|
26
|
+
drink_details = JSON.load(drink_results)['drinks'].first.reject do |k,v|
|
27
27
|
v == "" || v == " " || v == nil
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
instructions = drink_details["strInstructions"]
|
31
31
|
ingredients = []
|
32
32
|
measurements = []
|
33
|
-
|
33
|
+
|
34
34
|
drink_details.each do |k,v|
|
35
|
-
#the API returns the ingredients and measurements ordered to match the other, so we can be confident that
|
35
|
+
#the API returns the ingredients and measurements ordered to match the other, so we can be confident that
|
36
36
|
#when we add them to an array in order, they will be returned properly
|
37
37
|
if k.include?("Ingredient")
|
38
38
|
ingredients << v
|
@@ -43,5 +43,5 @@ class CocktailLibrary::CocktailDB
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
CocktailLibrary::Drink.new(drink, instructions, ingredients, measurements)
|
46
|
-
end
|
47
|
-
end
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocktail_library
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lita Stephenson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|