coffee_drinks 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 65ad7607636c8d9e95f137c871753d99eb10f857e91e5807ca55031e5fa94867
4
+ data.tar.gz: 9be08d3a871df34bfd8bff330820501c3197207cb15f6ac8d69f45a819f2e157
5
+ SHA512:
6
+ metadata.gz: 328b43209ad121dde164724886089a5141663e453d27b30deb9517e4f745eaeb6564edc5c05426aedad2ce8aa33d91fd4da7827e9916130333fe95fa5ac7c96e
7
+ data.tar.gz: 7c0df4f44e149b8e9aab1e7c952be3b06eb7a40908a89e0aaf12ef16332710a0e10e2e6273ca12e75e0b98732c4993139694abe65a10b07d800225ecb106ae54
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at “mxsaschakala@gmail.com”. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in coffee_drinks.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ coffee_drinks (0.1.0)
5
+ bundler (~> 2.1.4)
6
+ colorize (~> 0.8.1)
7
+ nokogiri
8
+ require_all
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ coderay (1.1.3)
14
+ colorize (0.8.1)
15
+ diff-lcs (1.4.4)
16
+ method_source (0.8.2)
17
+ mini_portile2 (2.4.0)
18
+ nokogiri (1.10.10)
19
+ mini_portile2 (~> 2.4.0)
20
+ pry (0.10.4)
21
+ coderay (~> 1.1.0)
22
+ method_source (~> 0.8.1)
23
+ slop (~> 3.4)
24
+ rake (12.3.3)
25
+ require_all (1.5.0)
26
+ rspec (3.9.0)
27
+ rspec-core (~> 3.9.0)
28
+ rspec-expectations (~> 3.9.0)
29
+ rspec-mocks (~> 3.9.0)
30
+ rspec-core (3.9.2)
31
+ rspec-support (~> 3.9.3)
32
+ rspec-expectations (3.9.2)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.9.0)
35
+ rspec-mocks (3.9.1)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.9.0)
38
+ rspec-support (3.9.3)
39
+ slop (3.6.0)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ coffee_drinks!
46
+ pry (~> 0.10.3)
47
+ rake (~> 12.0)
48
+ rspec (~> 3.9.0)
49
+
50
+ BUNDLED WITH
51
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 “saschakala”
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # CoffeeDrinks
2
+
3
+ A database of different espresso drinks and their coffee to water to milk ratios (can be viewed by whether or not the drink contains milk for the lactose conscious).
4
+
5
+ ...that plus a few surprises.
6
+
7
+ Inspired by Bandersnatch.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'coffee_drinks'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install coffee_drinks
24
+
25
+ ## Usage
26
+
27
+ Entertainment.
28
+
29
+ ## Development
30
+
31
+ 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.
32
+
33
+ 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).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/<github username>/coffee_drinks. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/<github username>/coffee_drinks/blob/master/CODE_OF_CONDUCT.md).
38
+
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
43
+
44
+ ## Code of Conduct
45
+
46
+ Everyone interacting in the CoffeeDrinks project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<github username>/coffee_drinks/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/coffee_drinks"
4
+
5
+ CLI.new.call
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "coffee_drinks"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,37 @@
1
+ require_relative 'lib/coffee_drinks/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "coffee_drinks"
5
+ spec.version = CoffeeDrinks::VERSION
6
+ spec.authors = ["“saschakala”"]
7
+ spec.email = ["“mxsaschakala@gmail.com”"]
8
+
9
+ spec.summary = %q{A database of different espresso drinks and their coffee to water to milk ratios (can be viewed by whether or not the drink contains milk for the lactose conscious).}
10
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
11
+ spec.homepage = "https://github.com/saschakala/coffee-drinks"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/saschakala/coffee-drinks"
19
+ spec.metadata["changelog_uri"] = "https://github.com/saschakala/cli-project"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "colorize", "~> 0.8.1"
31
+ spec.add_dependency "bundler", "~> 2.1.4"
32
+ spec.add_dependency "nokogiri"
33
+ spec.add_dependency "require_all"
34
+
35
+ spec.add_development_dependency "rspec", "~> 3.9.0"
36
+ spec.add_development_dependency "pry", "~> 0.10.3"
37
+ end
@@ -0,0 +1,19 @@
1
+ require 'colorize'
2
+ require 'bundler'
3
+ require 'nokogiri'
4
+ require 'open-uri'
5
+ require 'pry'
6
+ require 'require_all'
7
+
8
+ require_all 'lib/coffee_drinks'
9
+
10
+
11
+ # require_relative "./coffee_drinks/version"
12
+ # require_relative "./coffee_drinks/cli"
13
+ # require_relative "./coffee_drinks/drink"
14
+ # require_relative "./coffee_drinks/pastry"
15
+ # require_relative "./coffee_drinks/scraper"
16
+ # require_relative "./coffee_drinks/tea"
17
+
18
+
19
+
@@ -0,0 +1,450 @@
1
+
2
+ class CLI
3
+
4
+ def initialize
5
+ Scraper.scrape_drinks
6
+ end
7
+
8
+
9
+ def call
10
+ greeting
11
+ puts "\nType 'list' to see a list of espresso beverages.\n\n** alternatively, for the lactose challenged, type 'milk' or 'no milk' to see drinks that both will and won't give you indigestion **"
12
+ puts"\n --> enter 'list', 'milk', or 'no milk' to caffeinate and 'exit' to leave <--".colorize(:color => :light_blue, :background => :white)
13
+ menu_main
14
+ end
15
+
16
+
17
+ def menu_main
18
+ input = gets.chomp.downcase
19
+ if input == "list"
20
+ list_drinks
21
+ puts "\nWhat's in a name? A drink by any other name would taste as sweet."
22
+ menu_details
23
+ elsif input == "milk"
24
+ milk_drinks
25
+ puts "\nLiving a life of lactose luxury, I see."
26
+ menu_milk
27
+ elsif input == "no milk"
28
+ no_milk_drinks
29
+ puts "\nFunfact: approximately 65% of the human population has a reduced ability to digest lactose after infancy. You are not alone."
30
+ menu_no_milk
31
+ elsif input == "exit"
32
+ puts "\nI know, I know: our latte art needs work. But wait, how about a nice strong cup of tea?".colorize(:magenta)
33
+ sleep(2)
34
+ tea_menu_details
35
+ else
36
+ try_again_boost
37
+ puts "\n--> enter 'list', 'milk', or 'no milk' to caffeinate and 'exit' to leave <--".colorize(:color => :light_red, :background => :white)
38
+ menu_main
39
+ end
40
+ end
41
+
42
+ def menu_details
43
+ puts "\nTo learn more about a specific beverage enter its corresponding number below or type 'exit' to leave.".colorize(:color => :light_blue, :background => :white)
44
+ input = gets.chomp.downcase
45
+ if input == "exit"
46
+ puts "\nAre you, perhaps, more of a tea person?".colorize(:magenta)
47
+ sleep(2)
48
+ tea_menu_details
49
+ elsif !input.to_i.between?(1, Drink.all.count)
50
+ list_drinks
51
+ doesnt_exist
52
+ menu_details
53
+ else
54
+ drink = Drink.sorted_all[input.to_i-1]
55
+ drink_details(drink)
56
+ puts "\nWould you like to see another drink (y / n), view brews by milk content (milk / no milk), or could we perhaps interest you in a German pastry to go with your coffee (pastry)?".colorize(:color => :light_blue, :background => :white)
57
+ menu_details_second
58
+ end
59
+ end
60
+
61
+ def menu_details_second
62
+ round_two = gets.chomp.downcase
63
+ if round_two == "n" || round_two == "exit"
64
+ puts "\nWhat about a nice cup of tea (y / n)?".colorize(:magenta)
65
+ tea_menu
66
+ elsif round_two == "milk"
67
+ milk_drinks
68
+ menu_milk
69
+ elsif round_two == "no milk"
70
+ no_milk_drinks
71
+ menu_no_milk
72
+ elsif round_two == "pastry"
73
+ pastry_menu_details
74
+ elsif round_two == "y"
75
+ list_drinks
76
+ # puts "\nSelect a number to get drink details or type 'exit' to leave.".colorize(:color => :light_blue, :background => :white)
77
+ menu_details
78
+ else
79
+ try_again_boost
80
+ puts "\n--> enter 'y', 'milk', 'no milk', or 'pastry' to stay, and 'n' to leave <--".colorize(:color => :light_red, :background => :white)
81
+ menu_details_second
82
+ end
83
+ end
84
+
85
+
86
+ def menu_milk
87
+ puts "\nSelect a number to learn more about your favorite drink's fuel to foam ratio or enter 'exit' to leave.".colorize(:color => :light_blue, :background => :white)
88
+ input = gets.chomp.downcase
89
+ if input == "exit"
90
+ puts "\nMaybe some tea would help?".colorize(:magenta)
91
+ sleep(2)
92
+ tea_menu_details
93
+ elsif !input.to_i.between?(1, Drink.milk.count)
94
+ milk_drinks
95
+ doesnt_exist
96
+ menu_milk
97
+ else
98
+ drink = Drink.sorted_milk[input.to_i-1]
99
+ drink_details(drink)
100
+ puts "\nWould you like to see another drink (y / n), visit the main or milk-free beverage lists (main / no milk), or could we perhaps tempt you with a German pastry (pastry)?".colorize(:color => :light_blue, :background => :white)
101
+ menu_milk_second
102
+ end
103
+ end
104
+
105
+ def menu_milk_second
106
+ round_two = gets.chomp.downcase
107
+ if round_two == "n" || round_two == "exit"
108
+ psych
109
+ tea_menu
110
+ elsif round_two == "y"
111
+ milk_drinks
112
+ menu_milk
113
+ elsif round_two == "main"
114
+ list_drinks
115
+ menu_details
116
+ elsif round_two == "no milk"
117
+ no_milk_drinks
118
+ menu_no_milk
119
+ elsif round_two == "pastry"
120
+ pastry_menu_details
121
+ else
122
+ try_again_boost
123
+ puts "\n--> enter 'y', 'main', 'no milk', or 'pastry' to stay, and 'n' to leave <--".colorize(:color => :light_red, :background => :white)
124
+ menu_milk_second
125
+ end
126
+ end
127
+
128
+
129
+ def menu_no_milk
130
+ puts "\nSelect a number to learn more about your favorite milk-free drink or type 'exit' to leave.".colorize(:color => :light_blue, :background => :white)
131
+ input = gets.chomp.downcase
132
+ if input == "exit"
133
+ puts "These warm drinks definitely don't have milk - maybe you're more interested in tea?".colorize(:magenta)
134
+ sleep(2)
135
+ tea_menu_details
136
+ elsif !input.to_i.between?(1, Drink.no_milk.count)
137
+ no_milk_drinks
138
+ doesnt_exist
139
+ menu_no_milk
140
+ else
141
+ drink = Drink.sorted_no_milk[input.to_i-1]
142
+ drink_details(drink)
143
+ puts "\nWould you like to see another drink (y / n), visit the main or milk-containing beverage lists (main / milk), or could we get you a German pastry (pastry) to go with that coffee *lactaid not included* ?".colorize(:color => :light_blue, :background => :white)
144
+ menu_no_milk_second
145
+ end
146
+ end
147
+
148
+ def menu_no_milk_second
149
+ round_two = gets.chomp.downcase
150
+ if round_two == "n" || round_two == "exit"
151
+ psych
152
+ tea_menu
153
+ elsif round_two == "y"
154
+ no_milk_drinks
155
+ menu_no_milk
156
+ elsif round_two == "main"
157
+ list_drinks
158
+ menu_details
159
+ elsif round_two == "milk"
160
+ milk_drinks
161
+ menu_milk
162
+ elsif round_two == "pastry"
163
+ pastry_menu_details
164
+ else
165
+ try_again_boost
166
+ puts "\n--> enter 'y', 'main', 'milk', or 'pastry' to stay, and 'n' to leave <--".colorize(:color => :light_red, :background => :white)
167
+ menu_no_milk_second
168
+ end
169
+ end
170
+
171
+ def tea_menu
172
+ input = gets.chomp.downcase
173
+ if input == "y"
174
+ tea_menu_details
175
+ elsif input == "n" || input == "exit"
176
+ puts "May your coffee kick in before reality does.".colorize(:green)
177
+ puts <<-DOC
178
+ ((((
179
+ ((((
180
+ ))))
181
+ _ .---.
182
+ ( |`---'|
183
+ \| |
184
+ : .___, :
185
+ `-----'
186
+ DOC
187
+ else
188
+ try_again_boost
189
+ puts "\n--> enter 'y' to stay (and learn about tea) or 'n' to leave <--".colorize(:color => :light_red, :background => :white)
190
+ tea_menu
191
+ end
192
+ end
193
+
194
+
195
+ def tea_menu_details
196
+ if Tea.all.count > 0
197
+ list_teas
198
+ else
199
+ Scraper.scrape_tea
200
+ list_teas
201
+ end
202
+ puts "\nTo learn more about a type of tea enter its corresponding number below.".colorize(:color => :light_blue, :background => :white)
203
+ puts "\n(Or if you really want to leave we promise this time we'll let you...just enter 'exit' here.)"
204
+ input = gets.chomp.downcase
205
+ if input == "exit"
206
+ puts "No need to be sal-tea.".colorize(:green)
207
+ puts <<-DOC
208
+ ((((
209
+ ((((
210
+ ))))
211
+ _ .---.
212
+ ( |`---'|
213
+ \| |
214
+ : .___, :
215
+ `-----'
216
+ DOC
217
+ elsif !input.to_i.between?(1, Tea.all.count)
218
+ list_teas
219
+ doesnt_exist
220
+ tea_menu_details_clone
221
+ else
222
+ tea = Tea.sorted_all[input.to_i-1]
223
+ tea_details(tea)
224
+ puts "\nWould you like to see another tea (y / n) or could we perhaps interest you in a German pastry (pastry)?".colorize(:color => :light_blue, :background => :white)
225
+ tea_menu_details_second
226
+ end
227
+ end
228
+
229
+ def tea_menu_details_clone
230
+ if Tea.all.count > 0
231
+ list_teas
232
+ else
233
+ Scraper.scrape_tea
234
+ list_teas
235
+ end
236
+ puts "\nTo learn more about a type of tea enter its corresponding number below.".colorize(:color => :light_blue, :background => :white)
237
+ input = gets.chomp.downcase
238
+ if input == "exit"
239
+ puts "No need to be sal-tea.".colorize(:blue)
240
+ puts <<-DOC
241
+ ((((
242
+ ((((
243
+ ))))
244
+ _ .---.
245
+ ( |`---'|
246
+ \| |
247
+ : .___, :
248
+ `-----'
249
+ DOC
250
+ elsif !input.to_i.between?(1, Tea.all.count)
251
+ list_teas
252
+ doesnt_exist
253
+ tea_menu_details_clone
254
+ else
255
+ tea = Tea.sorted_all[input.to_i-1]
256
+ tea_details(tea)
257
+ puts "\nWould you like to see another tea (y / n) or could we perhaps interest you in a German pastry (pastry)?".colorize(:color => :light_blue, :background => :white)
258
+ tea_menu_details_second
259
+ end
260
+ end
261
+
262
+ def tea_menu_details_second
263
+ round_two = gets.chomp.downcase
264
+ if round_two == "n" || round_two == "exit"
265
+ puts "What do you call a sad cup of coffee? A depresso.".colorize(:green)
266
+ puts <<-DOC
267
+ ((((
268
+ ((((
269
+ ))))
270
+ _ .---.
271
+ ( |`---'|
272
+ \| |
273
+ : .___, :
274
+ `-----'
275
+ DOC
276
+ elsif round_two == "y"
277
+ tea_menu_details_clone
278
+ elsif round_two == "pastry"
279
+ pastry_menu_details_tea
280
+ else
281
+ try_again_boost
282
+ puts "\n--> enter 'y', 'n', or 'pastry' <--".colorize(:color => :light_red, :background => :white)
283
+ tea_menu_details_second
284
+ end
285
+ end
286
+
287
+
288
+ def pastry_menu_details
289
+ if Pastry.all.count > 0
290
+ list_pastries
291
+ else
292
+ Scraper.scrape_pastries
293
+ list_pastries
294
+ end
295
+ puts "\nTo learn more about a pastry enter its corresponding number below.".colorize(:color => :light_blue, :background => :white)
296
+ input = gets.chomp.downcase
297
+ if input == "exit"
298
+ puts "Not so fast, how about some tea?".colorize(:magenta)
299
+ tea_menu_details
300
+ elsif !input.to_i.between?(1, Pastry.all.count)
301
+ list_pastries
302
+ try_again_boost
303
+ pastry_menu_details
304
+ else
305
+ pastry = Pastry.sorted_all[input.to_i-1]
306
+ pastry_details(pastry)
307
+ puts "\nWould you like to see another pastry (y / n) or maybe you're ready for some tea (tea) or more coffee (coffee)?".colorize(:color => :light_blue, :background => :white)
308
+ pastry_menu_details_second
309
+ end
310
+ end
311
+
312
+ def pastry_menu_details_tea
313
+ if Pastry.all.count > 0
314
+ list_pastries
315
+ else
316
+ Scraper.scrape_pastries
317
+ list_pastries
318
+ end
319
+ puts "\nTo learn more about a pastry enter its corresponding number below.".colorize(:color => :light_blue, :background => :white)
320
+ input = gets.chomp.downcase
321
+ if input == "exit"
322
+ puts "Not so fast, how about some tea?".colorize(:magenta)
323
+ tea_menu_details
324
+ elsif !input.to_i.between?(1, Pastry.all.count)
325
+ list_pastries
326
+ try_again_boost
327
+ pastry_menu_details
328
+ else
329
+ pastry = Pastry.sorted_all[input.to_i-1]
330
+ pastry_details(pastry)
331
+ puts "\nWould you like to see another pastry (y) or maybe you're ready to gtfo of this program (GET ME OUTTA HERE)?".colorize(:color => :light_blue, :background => :white)
332
+ pastry_menu_details_second_tea
333
+ end
334
+ end
335
+
336
+ def pastry_menu_details_second
337
+ round_two = gets.chomp.downcase
338
+ if round_two == "n" || round_two == "exit"
339
+ puts "Sometimes we go hours without drinking coffee. It’s called sleeping.".colorize(:green)
340
+ puts <<-DOC
341
+ ((((
342
+ ((((
343
+ ))))
344
+ _ .---.
345
+ ( |`---'|
346
+ \| |
347
+ : .___, :
348
+ `-----'
349
+ DOC
350
+ elsif round_two == "y"
351
+ pastry_menu_details
352
+ elsif round_two == "tea"
353
+ tea_menu_details_clone
354
+ elsif round_two == "coffee"
355
+ list_drinks
356
+ menu_details
357
+ else
358
+ try_again_boost
359
+ puts "\n--> enter 'y', 'n', 'tea', or 'coffee' <--".colorize(:color => :light_red, :background => :white)
360
+ pastry_menu_details_second
361
+ end
362
+ end
363
+
364
+ def pastry_menu_details_second_tea
365
+ round_two = gets.chomp.downcase
366
+ if round_two == "get me outta here" || round_two == "exit" || round_two == "no"
367
+ puts "Sometimes we go hours without drinking coffee. It’s called sleeping.".colorize(:green)
368
+ puts <<-DOC
369
+ ((((
370
+ ((((
371
+ ))))
372
+ _ .---.
373
+ ( |`---'|
374
+ \| |
375
+ : .___, :
376
+ `-----'
377
+ DOC
378
+ elsif round_two == "y"
379
+ pastry_menu_details
380
+ else
381
+ try_again_boost
382
+ puts "\n--> enter 'y', 'n', 'tea', or 'coffee' <--".colorize(:color => :light_red, :background => :white)
383
+ pastry_menu_details_second_tea
384
+ end
385
+ end
386
+
387
+
388
+ def list_drinks
389
+ Drink.all.sort_by {|drink| drink.name}.tap{|drink| drink.each.with_index(1) { |drink, i| puts "#{i}. #{drink.name}"}}
390
+ end
391
+
392
+ def milk_drinks
393
+ Drink.milk.sort_by {|drink| drink.name}.tap{|drink| drink.each.with_index(1) { |drink, i| puts "#{i}. #{drink.name}"}}
394
+ end
395
+
396
+ def no_milk_drinks
397
+ Drink.no_milk.sort_by {|drink| drink.name}.tap{|drink| drink.each.with_index(1) { |drink, i| puts "#{i}. #{drink.name}"}}
398
+ end
399
+
400
+ def list_pastries
401
+ Pastry.all.sort_by {|pastry| pastry.name}.tap{|pastry| pastry.each.with_index(1) { |pastry, i| puts "#{i}. #{pastry.name}"}}
402
+ end
403
+
404
+ def list_teas
405
+ Tea.all.sort_by {|tea| tea.name}.tap{|tea| tea.each.with_index(1) { |tea, i| puts "#{i}. #{tea.name}"}}
406
+ end
407
+
408
+
409
+ def drink_details (drink)
410
+ puts "\nOrder up! One #{drink.name}:"
411
+ puts "\n#{drink.description}"
412
+ puts "\n#{drink.ratio}"
413
+ puts "#{drink.cup}"
414
+ puts "Milk: #{drink.milk}"
415
+ end
416
+
417
+ def tea_details (tea)
418
+ puts "\nOrder up! One #{tea.name}:"
419
+ puts "\n#{tea.description}"
420
+ puts "\n#{tea.flavor}"
421
+ puts "\n#{tea.varieties}"
422
+ end
423
+
424
+ def pastry_details (pastry)
425
+ puts "\nOrder up! One #{pastry.name}:"
426
+ puts "\n#{pastry.description}"
427
+ end
428
+
429
+
430
+
431
+ def greeting
432
+ puts "Hello! And welcome to the Bevvie Bevy: an interactive experience for coffee connoisseurs and novices alike.".colorize(:color => :cyan, :background => :black)
433
+ puts"\nHave you ever wondered what the difference is between a flat white and long black? If so, the Bevy is here to help."
434
+ end
435
+
436
+ def try_again_boost
437
+ puts "\nLooks like you need a boost of caffeine! Give it another go, we didn't quite catch that.".colorize(:light_red)
438
+ end
439
+
440
+ def doesnt_exist
441
+ puts "\nLooks like that drink doesn't exist yet! Try again, captain.".colorize(:light_red)
442
+ end
443
+
444
+ def psych
445
+ puts "\nHow about a cup of tea before you go (y / n)?".colorize(:magenta)
446
+ end
447
+
448
+ end
449
+
450
+
@@ -0,0 +1,55 @@
1
+ class Drink
2
+
3
+ @@all = []
4
+ @@milk = []
5
+ @@no_milk = []
6
+ @@all_sorted = []
7
+ @@milk_sorted = []
8
+ @@no_milk_sorted = []
9
+
10
+ attr_accessor :name, :milk, :description, :ratio, :cup
11
+
12
+ def initialize (name, milk = "", description, ratio, cup)
13
+ @name = name
14
+ @milk = milk
15
+ @description = description
16
+ @ratio = ratio
17
+ @cup = cup
18
+ @@all << self
19
+ @@milk << self if milk == "yes"
20
+ @@no_milk << self if milk == "no"
21
+ end
22
+
23
+
24
+ def self.all
25
+ @@all
26
+ end
27
+
28
+ def self.milk
29
+ @@milk
30
+ end
31
+
32
+ def self.no_milk
33
+ @@no_milk
34
+ end
35
+
36
+ def self.sorted_all
37
+ self.all.sort_by {|drink| drink.name}.each {|instance| @@all_sorted << instance }
38
+ @@all_sorted
39
+ end
40
+
41
+ def self.sorted_milk
42
+ self.milk.sort_by {|drink| drink.name}.each {|instance| @@milk_sorted << instance }
43
+ @@milk_sorted
44
+ end
45
+
46
+
47
+ def self.sorted_no_milk
48
+ self.no_milk.sort_by {|drink| drink.name}.each {|instance| @@no_milk_sorted << instance }
49
+ @@no_milk_sorted
50
+ end
51
+
52
+
53
+ end
54
+
55
+
@@ -0,0 +1,24 @@
1
+ class Pastry
2
+
3
+ @@all = []
4
+ @@all_sorted = []
5
+
6
+ attr_accessor :name, :description
7
+
8
+ def initialize (name, description = nil)
9
+ @name = name
10
+ @description = description
11
+ @@all << self
12
+ end
13
+
14
+ def self.all
15
+ @@all
16
+ end
17
+
18
+ def self.sorted_all
19
+ self.all.sort_by {|pastry| pastry.name}.each {|instance| @@all_sorted << instance }
20
+ @@all_sorted
21
+ end
22
+
23
+ end
24
+
@@ -0,0 +1,45 @@
1
+ class Scraper
2
+
3
+ DRINK_URL = "https://www.webstaurantstore.com/article/397/types-of-coffee-drinks.html"
4
+ PASTRY_URL = "https://www.insider.com/best-german-desserts-2017-3"
5
+ TEA_URL = "https://www.webstaurantstore.com/guide/693/types-of-tea.html"
6
+
7
+ def self.scrape_drinks
8
+ doc = Nokogiri::HTML(open(DRINK_URL))
9
+ doc.css("div.blog-highlight-wrap").each do |drink|
10
+ name = drink.css("h3").text.strip
11
+ ratio_cup = drink.css("li.icon-check")
12
+ milk = if ratio_cup.text.include?("milk") || ratio_cup.text.include?("foam")|| ratio_cup.text.include?("cream") == true
13
+ "yes"
14
+ else
15
+ "no"
16
+ end
17
+ description = drink.css("p").text
18
+ ratio = drink.css("li.icon-check")[0].text.strip
19
+ cup = drink.css("li.icon-check")[1].text.strip
20
+ Drink.new(name, milk, description, ratio, cup)
21
+ end
22
+ end
23
+
24
+ def self.scrape_pastries
25
+ doc = Nokogiri::HTML(open(PASTRY_URL))
26
+ doc.css("div.slide").each do |pastry|
27
+ name = pastry.css("h2.slide-title-text").text.strip
28
+ description = pastry.css("p").text.strip
29
+ Pastry.new(name, description)
30
+ end
31
+ end
32
+
33
+ def self.scrape_tea
34
+ doc = Nokogiri::HTML(open(TEA_URL))
35
+ doc.css("div.template-text").each do |tea|
36
+ name = tea.css("b").text.strip
37
+ description = tea.css("p")[2].text.strip
38
+ flavor = tea.css("p")[3].text.strip
39
+ varieties = tea.css("p")[4].text.strip
40
+ Tea.new(name, description, flavor, varieties)
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,25 @@
1
+ class Tea
2
+
3
+ @@all = []
4
+ @@all_sorted = []
5
+
6
+ attr_accessor :name, :description, :flavor, :varieties
7
+
8
+ def initialize (name, description = nil, flavor = nil, varieties = nil)
9
+ @name = name
10
+ @description = description
11
+ @flavor = flavor
12
+ @varieties = varieties
13
+ @@all << self
14
+ end
15
+
16
+ def self.all
17
+ @@all
18
+ end
19
+
20
+ def self.sorted_all
21
+ self.all.sort_by {|tea| tea.name}.each {|instance| @@all_sorted << instance }
22
+ @@all_sorted
23
+ end
24
+
25
+ end
@@ -0,0 +1,3 @@
1
+ module CoffeeDrinks
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coffee_drinks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - "“saschakala”"
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-09-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.1.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.1.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
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: require_all
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
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.9.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.9.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.10.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.10.3
97
+ description:
98
+ email:
99
+ - "“mxsaschakala@gmail.com”"
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - CODE_OF_CONDUCT.md
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/coffee-drinks
112
+ - bin/console
113
+ - bin/setup
114
+ - coffee_drinks.gemspec
115
+ - lib/coffee_drinks.rb
116
+ - lib/coffee_drinks/cli.rb
117
+ - lib/coffee_drinks/drink.rb
118
+ - lib/coffee_drinks/pastry.rb
119
+ - lib/coffee_drinks/scraper.rb
120
+ - lib/coffee_drinks/tea.rb
121
+ - lib/coffee_drinks/version.rb
122
+ homepage: https://github.com/saschakala/coffee-drinks
123
+ licenses:
124
+ - MIT
125
+ metadata:
126
+ homepage_uri: https://github.com/saschakala/coffee-drinks
127
+ source_code_uri: https://github.com/saschakala/coffee-drinks
128
+ changelog_uri: https://github.com/saschakala/cli-project
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: 2.3.0
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubygems_version: 3.1.4
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: A database of different espresso drinks and their coffee to water to milk
148
+ ratios (can be viewed by whether or not the drink contains milk for the lactose
149
+ conscious).
150
+ test_files: []