meal_finder 0.1.1 → 0.1.3
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/README.md +6 -4
- data/lib/meal_finder/cli.rb +62 -42
- data/lib/meal_finder/concerns/memorable.rb +0 -13
- data/lib/meal_finder/course.rb +13 -6
- data/lib/meal_finder/recipes.rb +10 -10
- data/lib/meal_finder/scraper.rb +29 -19
- data/lib/meal_finder/version.rb +1 -1
- data/meal_finder-0.1.1.gem +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a3d2c754d979ef40df87e741bdf08f801a3417a72275889bf3acbdff07a7877a
|
|
4
|
+
data.tar.gz: 0eb0ff41e21374f6b4e9589057765c28fdf4fb4c7ade70238152307e758de6fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a3cb5ff2a4472a53203972bf5a56d5e3f481e25c370c3ac1e38a68207ec40eabc99bf9ca9e61efff5e191f523713aa535880e1ea7a8e71bd49a0f0e209d84691
|
|
7
|
+
data.tar.gz: 97c921a7a08f68420caf81a25b8e73cc50e6b201b79a7e782ca817abeded45d6ea5bbcbb0fdf430b5d2403931fa7dbbd9182106edc9a5cbab1410c0c29d224f7
|
data/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# MealFinder
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
|
3
|
+
Meal Finder is a command 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.
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
@@ -22,7 +20,11 @@ Or install it yourself as:
|
|
|
22
20
|
|
|
23
21
|
## Usage
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
From the local directory, execute
|
|
24
|
+
|
|
25
|
+
$ mealfinder
|
|
26
|
+
|
|
27
|
+
and follow the prompts.
|
|
26
28
|
|
|
27
29
|
## Development
|
|
28
30
|
|
data/lib/meal_finder/cli.rb
CHANGED
|
@@ -26,7 +26,7 @@ module MealFinder
|
|
|
26
26
|
input = gets.chomp
|
|
27
27
|
|
|
28
28
|
if input.downcase == "list courses"
|
|
29
|
-
MealFinder::Course.
|
|
29
|
+
MealFinder::Scraper.scrape_courses if MealFinder::Course.all.size == 0
|
|
30
30
|
list_courses
|
|
31
31
|
elsif input.downcase == "exit"
|
|
32
32
|
goodbye
|
|
@@ -39,9 +39,7 @@ module MealFinder
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def list_courses
|
|
42
|
-
|
|
43
|
-
course_arr = MealFinder::Course.all
|
|
44
|
-
|
|
42
|
+
|
|
45
43
|
puts "\t
|
|
46
44
|
\t Here are the courses that we have available.
|
|
47
45
|
\t To choose a course, type in the corresponding number below to get a list of recipe suggestions.
|
|
@@ -50,26 +48,28 @@ module MealFinder
|
|
|
50
48
|
|
|
51
49
|
\t"
|
|
52
50
|
|
|
53
|
-
puts
|
|
51
|
+
puts MealFinder::Course.all.map.with_index {|meal,index|
|
|
54
52
|
"\t#{index+1}. #{meal.name}"}
|
|
55
53
|
|
|
56
|
-
select_course
|
|
54
|
+
select_course
|
|
57
55
|
|
|
58
56
|
end
|
|
59
57
|
|
|
60
|
-
def select_course
|
|
58
|
+
def select_course
|
|
61
59
|
|
|
62
60
|
input = gets.chomp
|
|
63
61
|
|
|
64
62
|
if input.downcase == "exit"
|
|
65
63
|
goodbye
|
|
66
64
|
|
|
67
|
-
elsif input.to_i > 0 && input.to_i
|
|
68
|
-
selected_course =
|
|
65
|
+
elsif input.to_i > 0 && input.to_i <= MealFinder::Course.all.size
|
|
66
|
+
selected_course = MealFinder::Course.all[input.to_i-1]
|
|
69
67
|
|
|
70
68
|
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
|
|
71
69
|
\t find out more about or simply type in 'list courses' to go back to the main menu and choose a different course\t"
|
|
72
|
-
|
|
70
|
+
|
|
71
|
+
MealFinder::Scraper.scrape_recipes(selected_course) if MealFinder::Recipes.all.size == 0
|
|
72
|
+
list_recipes
|
|
73
73
|
|
|
74
74
|
else
|
|
75
75
|
puts "\t Sorry, I did not recognise that..."
|
|
@@ -78,80 +78,99 @@ module MealFinder
|
|
|
78
78
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
list_recipes(selected_course)
|
|
81
|
+
|
|
83
82
|
|
|
84
83
|
end
|
|
85
84
|
|
|
86
|
-
def list_recipes
|
|
87
|
-
|
|
85
|
+
def list_recipes
|
|
86
|
+
|
|
88
87
|
|
|
89
|
-
puts
|
|
88
|
+
puts MealFinder::Recipes.all.map.with_index {|recipe, i|
|
|
90
89
|
"#{i+1}. #{recipe.name}"}
|
|
90
|
+
|
|
91
|
+
|
|
91
92
|
|
|
92
|
-
select_recipe
|
|
93
|
+
select_recipe
|
|
93
94
|
|
|
94
95
|
end
|
|
95
96
|
|
|
96
97
|
|
|
97
|
-
def select_recipe
|
|
98
|
+
def select_recipe
|
|
98
99
|
|
|
99
|
-
input = gets.chomp
|
|
100
|
+
input = gets.chomp.downcase
|
|
100
101
|
|
|
101
102
|
|
|
102
|
-
if input
|
|
103
|
-
MealFinder::Recipes.all.clear
|
|
103
|
+
if input == "list courses"
|
|
104
104
|
list_courses
|
|
105
105
|
|
|
106
|
-
elsif input
|
|
106
|
+
elsif input == "exit"
|
|
107
107
|
goodbye
|
|
108
108
|
|
|
109
|
-
elsif input.to_i > 0 && input.to_i
|
|
110
|
-
selected_recipe =
|
|
111
|
-
|
|
109
|
+
elsif input.to_i > 0 && input.to_i <= MealFinder::Recipes.all.size
|
|
110
|
+
selected_recipe = MealFinder::Recipes.all[input.to_i-1]
|
|
111
|
+
|
|
112
112
|
recipe_details(selected_recipe)
|
|
113
|
+
|
|
113
114
|
|
|
114
115
|
else
|
|
115
116
|
puts "\t Sorry, I did not recognise that.
|
|
116
117
|
\t Please type in the number of the dish that you are looking for
|
|
117
118
|
\t or 'list courses' to see the courses again or 'exit' to exit the program"
|
|
118
|
-
select_recipe
|
|
119
|
+
select_recipe
|
|
119
120
|
end
|
|
120
121
|
end
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
def recipe_details(selected_recipe)
|
|
124
|
+
MealFinder::Scraper.scrape_recipe_details(selected_recipe) unless selected_recipe.details
|
|
125
|
+
|
|
126
|
+
recipe_details_content(selected_recipe)
|
|
127
|
+
|
|
128
|
+
recipe_next_steps
|
|
129
|
+
|
|
124
130
|
|
|
125
|
-
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def recipe_details_content(selected_recipe)
|
|
134
|
+
#binding.pry
|
|
135
|
+
deets = selected_recipe.details
|
|
136
|
+
|
|
137
|
+
puts "\t"
|
|
138
|
+
puts "Here is the recipe for #{selected_recipe.name}\n\t"
|
|
139
|
+
|
|
140
|
+
puts "#{deets[:description]}\n\t"
|
|
141
|
+
puts "#{deets[:prep_time]}"
|
|
142
|
+
puts "#{deets[:cook_time]}\n\t"
|
|
143
|
+
|
|
144
|
+
puts "Ingredients:\n\t"
|
|
145
|
+
puts deets[:ingredients_list].collect {|item| "#{item}"}
|
|
146
|
+
puts "\nMethod:\n\t"
|
|
147
|
+
puts deets[:method_list].collect.with_index {|method, index| "#{index+1}. #{method}\n\t"}
|
|
148
|
+
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def recipe_next_steps
|
|
126
156
|
|
|
127
157
|
puts "\t Not quite what you are looking for?
|
|
128
158
|
\t Type 'list recipes' to go back to list of recipes from the same Course and choose a different dish\n\t
|
|
129
159
|
\t To go back to the main menu, simply type 'list courses'
|
|
130
160
|
\t To exit the program, type 'exit'"
|
|
131
|
-
|
|
132
|
-
recipe_next_steps
|
|
133
161
|
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def recipe_next_steps
|
|
137
|
-
|
|
138
162
|
input = gets.chomp
|
|
139
163
|
|
|
140
164
|
if input.downcase == "list recipes"
|
|
141
|
-
recipe_arr = MealFinder::Recipes.all
|
|
142
165
|
|
|
143
|
-
puts
|
|
166
|
+
puts MealFinder::Recipes.all.map.with_index {|recipe, i|
|
|
144
167
|
"#{i+1}. #{recipe.name}"}
|
|
145
168
|
|
|
146
|
-
select_recipe
|
|
169
|
+
select_recipe
|
|
147
170
|
|
|
148
171
|
elsif input.downcase == "list courses"
|
|
149
|
-
MealFinder::Recipes.all.clear
|
|
150
172
|
list_courses
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
173
|
+
|
|
155
174
|
elsif input.downcase == "exit"
|
|
156
175
|
goodbye
|
|
157
176
|
|
|
@@ -171,6 +190,7 @@ module MealFinder
|
|
|
171
190
|
exit
|
|
172
191
|
end
|
|
173
192
|
|
|
193
|
+
|
|
174
194
|
end
|
|
175
195
|
|
|
176
196
|
end
|
data/lib/meal_finder/course.rb
CHANGED
|
@@ -9,18 +9,25 @@ module MealFinder
|
|
|
9
9
|
|
|
10
10
|
@@all = []
|
|
11
11
|
|
|
12
|
-
def initialize
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def self.list_course_names
|
|
17
|
-
MealFinder::Scraper.scrape_courses
|
|
12
|
+
def initialize (name = nil, url = nil)
|
|
13
|
+
@name = name
|
|
14
|
+
@url = url
|
|
15
|
+
@recipes = []
|
|
18
16
|
end
|
|
17
|
+
|
|
19
18
|
|
|
20
19
|
def self.all
|
|
21
20
|
@@all
|
|
22
21
|
end
|
|
22
|
+
|
|
23
|
+
def save
|
|
24
|
+
@@all << self
|
|
25
|
+
end
|
|
23
26
|
|
|
27
|
+
def recipes
|
|
28
|
+
@recipes
|
|
29
|
+
end
|
|
30
|
+
|
|
24
31
|
end
|
|
25
32
|
|
|
26
33
|
end
|
data/lib/meal_finder/recipes.rb
CHANGED
|
@@ -5,27 +5,27 @@ module MealFinder
|
|
|
5
5
|
|
|
6
6
|
include Memorable::InstanceMethods
|
|
7
7
|
|
|
8
|
-
attr_accessor :name, :url
|
|
8
|
+
attr_accessor :name, :url, :details
|
|
9
9
|
|
|
10
10
|
@@recipe_collection = []
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
def initialize
|
|
14
|
-
|
|
13
|
+
def initialize (name = nil, url = nil)
|
|
14
|
+
@name = name
|
|
15
|
+
@url = url
|
|
16
|
+
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
|
|
18
|
-
def
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self.recipe_details(selected_recipe)
|
|
23
|
-
MealFinder::Scraper.scrape_recipe_details(selected_recipe)
|
|
20
|
+
def save
|
|
21
|
+
@@recipe_collection << self
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
def self.all
|
|
27
25
|
@@recipe_collection
|
|
28
26
|
end
|
|
29
|
-
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
30
|
end
|
|
31
31
|
end
|
data/lib/meal_finder/scraper.rb
CHANGED
|
@@ -8,6 +8,7 @@ module MealFinder
|
|
|
8
8
|
BASE_URL = "https://www.bbcgoodfood.com"
|
|
9
9
|
|
|
10
10
|
def self.scrape_courses
|
|
11
|
+
puts "************ scraping ***************"
|
|
11
12
|
html = open('https://www.bbcgoodfood.com/search/recipes?query=course')
|
|
12
13
|
doc = Nokogiri::HTML(html)
|
|
13
14
|
|
|
@@ -18,60 +19,69 @@ module MealFinder
|
|
|
18
19
|
|
|
19
20
|
new_course.url = BASE_URL + course.css("a")[0]["href"]
|
|
20
21
|
|
|
22
|
+
Course.all << new_course
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
def self.scrape_recipes(selected_course)
|
|
27
|
-
|
|
29
|
+
puts "************ scraping ***************"
|
|
28
30
|
doc = Nokogiri::HTML(open(selected_course.url))
|
|
29
|
-
|
|
31
|
+
|
|
30
32
|
doc.css("#search-results h3").each do |recipes|
|
|
31
33
|
|
|
32
34
|
new_recipe = Recipes.new
|
|
33
35
|
new_recipe.name = recipes.css("a").text.strip
|
|
34
36
|
new_recipe.url = BASE_URL + recipes.css("a")[0]["href"]
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
|
|
38
|
+
|
|
37
39
|
|
|
40
|
+
Recipes.all << new_recipe
|
|
41
|
+
end
|
|
42
|
+
|
|
38
43
|
end
|
|
39
44
|
|
|
40
45
|
|
|
41
46
|
def self.scrape_recipe_details(selected_recipe)
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
puts "************ scraping ***************"
|
|
48
|
+
|
|
44
49
|
|
|
45
50
|
doc = Nokogiri::HTML(open(selected_recipe.url))
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
selected_recipe.details = {
|
|
53
|
+
description: doc.css(".recipe-header__description p").text,
|
|
54
|
+
prep_time: doc.css(".recipe-details .recipe-details__text .recipe-details__cooking-time-prep").text,
|
|
55
|
+
cook_time: doc.css(".recipe-details .recipe-details__text .recipe-details__cooking-time-cook").text,
|
|
56
|
+
ingredients_list: [],
|
|
57
|
+
method_list: []
|
|
58
|
+
}
|
|
52
59
|
|
|
60
|
+
|
|
53
61
|
|
|
54
62
|
doc.css(".recipe-content").each do |recipe|
|
|
55
63
|
recipe.css(".ingredients-list li").each do |ingredient|
|
|
56
64
|
ingredients = ingredient.attr("content")
|
|
57
65
|
|
|
58
|
-
ingredients_list << ingredients
|
|
59
|
-
|
|
66
|
+
selected_recipe.details[:ingredients_list] << ingredients
|
|
67
|
+
|
|
68
|
+
|
|
60
69
|
end
|
|
70
|
+
|
|
61
71
|
recipe.css(".method__list li").each do |method|
|
|
62
72
|
method_actions = method.css("p").text
|
|
63
73
|
|
|
64
|
-
method_list << method_actions
|
|
74
|
+
selected_recipe.details[:method_list] << method_actions
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
#binding.pry
|
|
65
79
|
|
|
66
80
|
end
|
|
67
81
|
|
|
68
|
-
puts "Ingredients:\n\t"
|
|
69
|
-
puts ingredients_list.collect {|item| "#{item}"}
|
|
70
|
-
puts "\nMethod:\n\t"
|
|
71
|
-
puts method_list.map.with_index {|method, index| "#{index+1}. #{method}\n\t"}
|
|
72
82
|
|
|
73
83
|
end
|
|
74
|
-
|
|
84
|
+
|
|
75
85
|
end
|
|
76
86
|
|
|
77
87
|
end
|
data/lib/meal_finder/version.rb
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: meal_finder
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-07-
|
|
11
|
+
date: 2019-07-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -79,6 +79,7 @@ files:
|
|
|
79
79
|
- lib/meal_finder/scraper.rb
|
|
80
80
|
- lib/meal_finder/version.rb
|
|
81
81
|
- meal_finder-0.1.0.gem
|
|
82
|
+
- meal_finder-0.1.1.gem
|
|
82
83
|
- meal_finder.gemspec
|
|
83
84
|
homepage: https://github.com/jenniferanndcb/mealfinder
|
|
84
85
|
licenses:
|