Meal_Finder_CLI 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/NOTES.md +46 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/mealfinder +6 -0
- data/bin/setup +8 -0
- data/lib/CLI_project/cli.rb +179 -0
- data/lib/CLI_project/concerns/memorable.rb +13 -0
- data/lib/CLI_project/course.rb +28 -0
- data/lib/CLI_project/recipes.rb +33 -0
- data/lib/CLI_project/scraper.rb +74 -0
- data/lib/CLI_project/version.rb +3 -0
- data/lib/environment.rb +19 -0
- data/meal_finder.gemspec +34 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 62190bd6f69ca99b1e4f68442a98ef773d9d3b83410105cf9e00fa0a1765e960
|
4
|
+
data.tar.gz: b0fbb4174e9f7dd6a3357b62641a8c2b80164bc87def357715e61abb583da240
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8be4a3a5caebcbf90ac7dd45645e747d6aa3a9c61ae166310cb2d5f1b3163483d69278e66661302bd138066e1034ab9517005e3587a895fd48d0c246d79ff77
|
7
|
+
data.tar.gz: 1e2b157ab6acab0cf141c6b8af85bbceba8e61823e5940c8d20017f439fb9f5c18ad43991ed08970bc2a2db710c68ea44a4b4176b39cede635bf3741dc703788
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 jenniferanndcb@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 [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Jen
|
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.
|
data/NOTES.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
Welcome greeting :
|
2
|
+
|
3
|
+
"Hello, choose whether you are looking for breakfast, lunch or dinner inspiration"
|
4
|
+
|
5
|
+
User types meal: "breakfast", "lunch" OR "dinner"
|
6
|
+
|
7
|
+
List recipe inspirations by meal #self.list_recipes (meal i.e. breakfast, lunch, dinner)
|
8
|
+
|
9
|
+
List by skill level - Easy, More Effort, A Challenge
|
10
|
+
|
11
|
+
Select from list of recipes
|
12
|
+
|
13
|
+
Open URL or Pull methods
|
14
|
+
|
15
|
+
Add to "Today's #{meal} menu"
|
16
|
+
|
17
|
+
BONUS: Create a shopping list from recipes chosen and added to menu list
|
18
|
+
|
19
|
+
FILES - Single Responsibility Principle:
|
20
|
+
|
21
|
+
/bin/cli - executable
|
22
|
+
|
23
|
+
cli.rb - handles display logic and user input #CLI Controller
|
24
|
+
|
25
|
+
meal.rb - first level scraping - breakfast, lunch, dinner
|
26
|
+
|
27
|
+
recipes.rb - second level scraping - recipes are saved
|
28
|
+
--> if second time choose another recipe
|
29
|
+
--> Done? List menu
|
30
|
+
|
31
|
+
ingredients_and_method.rb - third level scraping - lists ingredients and method for chosen recipe
|
32
|
+
--> asks users would you like to add to today's menu?
|
33
|
+
--> go back one level
|
34
|
+
|
35
|
+
menu.rb - saves recipes added
|
36
|
+
--> List shopping list? List ingredients.
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
LET THE USER CHOOSE WHERE TO GO - if in recipe menu - can go back to main menu - if in recipe - can get out to go back to recipe list
|
45
|
+
|
46
|
+
ONLY SCRAPE ONCE - if the user chose dinner - list recipe of dinner - if user got out, do not scrape again but bring up list of dinner recipes... how???
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Meal Finder CLI
|
2
|
+
|
3
|
+
Meal Finder is a comman line interface that enables the user to browse and find recipe inspirations from the BBC Good Food website. The user will be presented with a list of available courses, and then the recipes for their chosen course. The user can then choose a recipe to find out more about the ingredients needed and the step by step methods for making their chosen dish.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'Meal_Finder_CLI'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install Meal_finder_CLI_gem
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
From the local directory, execute
|
24
|
+
|
25
|
+
$ meal-finder-cli-gem
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/CLI_project. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the CLIProject project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/CLI_project/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "CLI_project"
|
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__)
|
data/bin/mealfinder
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
|
4
|
+
module RecipeInspiration
|
5
|
+
class CLI
|
6
|
+
|
7
|
+
def start
|
8
|
+
puts " -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-"
|
9
|
+
puts " | |"
|
10
|
+
puts " | Hello and welcome to the Meal Finder CLI. |"
|
11
|
+
puts " | |"
|
12
|
+
puts " -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-"
|
13
|
+
menu
|
14
|
+
end
|
15
|
+
|
16
|
+
def menu
|
17
|
+
puts "\t If you are looking for inspirations for your next meal then you've come to the right place.
|
18
|
+
\t To see what courses we have available, simply type 'list courses'
|
19
|
+
\t To exit the program, simply type 'exit'"
|
20
|
+
|
21
|
+
menu_user_input
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def menu_user_input
|
27
|
+
input = gets.chomp
|
28
|
+
|
29
|
+
if input.downcase == "list courses"
|
30
|
+
RecipeInspiration::Course.list_course_names
|
31
|
+
list_courses
|
32
|
+
elsif input.downcase == "exit"
|
33
|
+
goodbye
|
34
|
+
else
|
35
|
+
puts "\t Sorry I did not recognise that..."
|
36
|
+
|
37
|
+
menu
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def list_courses
|
43
|
+
|
44
|
+
course_arr = RecipeInspiration::Course.all
|
45
|
+
|
46
|
+
puts "\t
|
47
|
+
\t Here are the courses that we have available.
|
48
|
+
\t To choose a course, type in the corresponding number below to get a list of recipe suggestions.
|
49
|
+
|
50
|
+
\t Or simply type 'exit' to exit the program
|
51
|
+
|
52
|
+
\t"
|
53
|
+
|
54
|
+
puts course_arr.map.with_index {|meal,index|
|
55
|
+
"\t#{index+1}. #{meal.name}"}
|
56
|
+
|
57
|
+
select_course(course_arr)
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
def select_course(course_arr)
|
62
|
+
|
63
|
+
input = gets.chomp
|
64
|
+
|
65
|
+
if input.downcase == "exit"
|
66
|
+
goodbye
|
67
|
+
|
68
|
+
elsif input.to_i > 0 && input.to_i < 23
|
69
|
+
selected_course = course_arr[input.to_i-1]
|
70
|
+
|
71
|
+
puts "\t Great! Here are some ideas for you to make for #{selected_course.name}. Please type in the number of the dish you would like to
|
72
|
+
\t find out more about or simply type in 'list courses' to go back to the main menu and choose a different course\t"
|
73
|
+
|
74
|
+
|
75
|
+
else
|
76
|
+
puts "\t Sorry, I did not recognise that..."
|
77
|
+
|
78
|
+
list_courses
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
RecipeInspiration::Recipes.list_recipe_names(selected_course)
|
83
|
+
list_recipes(selected_course)
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
def list_recipes(selected_course)
|
88
|
+
recipe_arr = RecipeInspiration::Recipes.all
|
89
|
+
|
90
|
+
puts recipe_arr.map.with_index {|recipe, i|
|
91
|
+
"#{i+1}. #{recipe.name}"}
|
92
|
+
|
93
|
+
select_recipe(recipe_arr)
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def select_recipe(recipe_arr)
|
99
|
+
|
100
|
+
input = gets.chomp
|
101
|
+
|
102
|
+
|
103
|
+
if input.downcase == "list courses"
|
104
|
+
RecipeInspiration::Recipes.all.clear
|
105
|
+
list_courses
|
106
|
+
|
107
|
+
elsif input.downcase == "exit"
|
108
|
+
goodbye
|
109
|
+
|
110
|
+
elsif input.to_i > 0 && input.to_i < 16
|
111
|
+
selected_recipe = recipe_arr[input.to_i-1]
|
112
|
+
|
113
|
+
recipe_details(selected_recipe)
|
114
|
+
|
115
|
+
else
|
116
|
+
puts "\t Sorry, I did not recognise that.
|
117
|
+
\t Please type in the number of the dish that you are looking for
|
118
|
+
\t or 'list courses' to see the courses again or 'exit' to exit the program"
|
119
|
+
select_recipe(recipe_arr)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
def recipe_details(selected_recipe)
|
125
|
+
|
126
|
+
RecipeInspiration::Recipes.recipe_details(selected_recipe)
|
127
|
+
|
128
|
+
puts "\t Not quite what you are looking for?
|
129
|
+
\t Type 'list recipes' to go back to list of recipes from the same Course and choose a different dish\n\t
|
130
|
+
\t To go back to the main menu, simply type 'list courses'
|
131
|
+
\t To exit the program, type 'exit'"
|
132
|
+
|
133
|
+
recipe_next_steps
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
def recipe_next_steps
|
138
|
+
|
139
|
+
input = gets.chomp
|
140
|
+
|
141
|
+
if input.downcase == "list recipes"
|
142
|
+
recipe_arr = RecipeInspiration::Recipes.all
|
143
|
+
|
144
|
+
puts recipe_arr.map.with_index {|recipe, i|
|
145
|
+
"#{i+1}. #{recipe.name}"}
|
146
|
+
|
147
|
+
select_recipe(recipe_arr)
|
148
|
+
|
149
|
+
elsif input.downcase == "list courses"
|
150
|
+
RecipeInspiration::Recipes.all.clear
|
151
|
+
list_courses
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
elsif input.downcase == "exit"
|
157
|
+
goodbye
|
158
|
+
|
159
|
+
else
|
160
|
+
puts "\t Sorry I did not recognise that...
|
161
|
+
\t Type 'list recipes' to go back to list of recipes from the same Course and choose a different dish\n\t
|
162
|
+
\t To go back to the main menu, simply type 'list courses'
|
163
|
+
\t To exit the program, type 'exit'"
|
164
|
+
|
165
|
+
recipe_next_steps
|
166
|
+
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def goodbye
|
171
|
+
puts "\t Thank you for using the Meal Finder CLI. See you next time!"
|
172
|
+
exit
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative './concerns/memorable.rb'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
module RecipeInspiration
|
7
|
+
class Course
|
8
|
+
|
9
|
+
include Memorable::InstanceMethods
|
10
|
+
|
11
|
+
attr_accessor :name, :url
|
12
|
+
|
13
|
+
@@all = []
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.list_course_names
|
20
|
+
RecipeInspiration::Scraper.scrape_courses
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.all
|
24
|
+
@@all
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
require_relative './concerns/memorable.rb'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
module RecipeInspiration
|
6
|
+
class Recipes
|
7
|
+
|
8
|
+
include Memorable::InstanceMethods
|
9
|
+
|
10
|
+
attr_accessor :name, :url
|
11
|
+
|
12
|
+
@@recipe_collection = []
|
13
|
+
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def self.list_recipe_names(selected_course)
|
21
|
+
RecipeInspiration::Scraper.scrape_recipes(selected_course)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.recipe_details(selected_recipe)
|
25
|
+
RecipeInspiration::Scraper.scrape_recipe_details(selected_recipe)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.all
|
29
|
+
@@recipe_collection
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module RecipeInspiration
|
2
|
+
|
3
|
+
class Scraper
|
4
|
+
|
5
|
+
BASE_URL = "https://www.bbcgoodfood.com"
|
6
|
+
|
7
|
+
def self.scrape_courses
|
8
|
+
html = open('https://www.bbcgoodfood.com/search/recipes?query=')
|
9
|
+
doc = Nokogiri::HTML(html)
|
10
|
+
|
11
|
+
doc.css('ul#facetapi-facet-search-apinode-index-block-field-bbcgf-course li.leaf').each do |course|
|
12
|
+
new_course = Course.new
|
13
|
+
new_course.name = course.css("a :first-child").text.gsub(/Apply|filter/, "").strip
|
14
|
+
|
15
|
+
new_course.url = BASE_URL + course.css("a")[0]["href"]
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def self.scrape_recipes(selected_course)
|
23
|
+
|
24
|
+
doc = Nokogiri::HTML(open(selected_course.url))
|
25
|
+
|
26
|
+
doc.css(".view-content h3").each do |recipes|
|
27
|
+
new_recipe = Recipes.new
|
28
|
+
new_recipe.name = recipes.css("a").text.strip
|
29
|
+
new_recipe.url = BASE_URL + recipes.css("a")[0]["href"]
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def self.scrape_recipe_details(selected_recipe)
|
37
|
+
ingredients_list = []
|
38
|
+
method_list = []
|
39
|
+
|
40
|
+
doc = Nokogiri::HTML(open(selected_recipe.url))
|
41
|
+
|
42
|
+
puts "\t"
|
43
|
+
puts "Here is the recipe for #{selected_recipe.name}\n\t"
|
44
|
+
puts "#{doc.css(".recipe-header__description p").text}\n\t"
|
45
|
+
puts "#{doc.css(".recipe-details .recipe-details__text .recipe-details__cooking-time-prep").text}"
|
46
|
+
puts "#{doc.css(".recipe-details .recipe-details__text .recipe-details__cooking-time-cook").text}\n\t"
|
47
|
+
|
48
|
+
|
49
|
+
doc.css(".recipe-content").each do |recipe|
|
50
|
+
recipe.css(".ingredients-list li").each do |ingredient|
|
51
|
+
ingredients = ingredient.attr("content")
|
52
|
+
|
53
|
+
ingredients_list << ingredients
|
54
|
+
|
55
|
+
end
|
56
|
+
recipe.css(".method__list li").each do |method|
|
57
|
+
method_actions = method.css("p").text
|
58
|
+
|
59
|
+
method_list << method_actions
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
puts "Ingredients:\n\t"
|
64
|
+
puts ingredients_list.collect {|item| "#{item}"}
|
65
|
+
puts "\nMethod:\n\t"
|
66
|
+
puts method_list.map.with_index {|method, index| "#{index+1}. #{method}\n\t"}
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/lib/environment.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
require_relative "./CLI_project/recipes"
|
7
|
+
require_relative "./CLI_project/cli"
|
8
|
+
require_relative "./CLI_project/course"
|
9
|
+
require_relative "./CLI_project/scraper"
|
10
|
+
require_relative "./CLI_project/version"
|
11
|
+
require_relative "./CLI_project/concerns/memorable"
|
12
|
+
|
13
|
+
|
14
|
+
module CLIProject
|
15
|
+
class Error < StandardError; end
|
16
|
+
# Your code goes here...
|
17
|
+
end
|
18
|
+
|
19
|
+
|
data/meal_finder.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "CLI_project/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "Meal_Finder_CLI"
|
7
|
+
spec.version = CLIProject::VERSION
|
8
|
+
spec.authors = ["Jen"]
|
9
|
+
spec.email = ["jenniferanndcb@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Meal Finder }
|
12
|
+
spec.description = %q{Meal Finder CLI gives users the tool to find recipes from the BBC Good Food website by course.}
|
13
|
+
spec.homepage = "https://github.com/jenniferanndcb/meal-finder-cli-gem"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
20
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Meal_Finder_CLI
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jen
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Meal Finder CLI gives users the tool to find recipes from the BBC Good
|
56
|
+
Food website by course.
|
57
|
+
email:
|
58
|
+
- jenniferanndcb@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- CODE_OF_CONDUCT.md
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- NOTES.md
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/mealfinder
|
74
|
+
- bin/setup
|
75
|
+
- lib/CLI_project/cli.rb
|
76
|
+
- lib/CLI_project/concerns/memorable.rb
|
77
|
+
- lib/CLI_project/course.rb
|
78
|
+
- lib/CLI_project/recipes.rb
|
79
|
+
- lib/CLI_project/scraper.rb
|
80
|
+
- lib/CLI_project/version.rb
|
81
|
+
- lib/environment.rb
|
82
|
+
- meal_finder.gemspec
|
83
|
+
homepage: https://github.com/jenniferanndcb/meal-finder-cli-gem
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata:
|
87
|
+
homepage_uri: https://github.com/jenniferanndcb/meal-finder-cli-gem
|
88
|
+
source_code_uri: https://github.com/jenniferanndcb/meal-finder-cli-gem
|
89
|
+
changelog_uri: https://github.com/jenniferanndcb/meal-finder-cli-gem
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubygems_version: 3.0.4
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Meal Finder
|
109
|
+
test_files: []
|