recipe-finder-cli-gem 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/.DS_Store +0 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.md +21 -0
- data/README.md +25 -0
- data/Rakefile +6 -0
- data/bin/.DS_Store +0 -0
- data/bin/console +7 -0
- data/bin/recipe-finder +4 -0
- data/bin/setup +7 -0
- data/lib/.DS_Store +0 -0
- data/lib/finder/cli.rb +98 -0
- data/lib/finder/dish.rb +51 -0
- data/lib/finder/scraper.rb +22 -0
- data/lib/finder/version.rb +3 -0
- data/lib/recipe_finder.rb +10 -0
- data/spec.md +6 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4aef27a66e74852d8205de59a91fba38b5ae8123a3573d9c643356f2f58dd442
|
4
|
+
data.tar.gz: b45fb961077f61781b0dfaeb8416f62f72e82a9e4ad999342b0f3216edd43603
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3036db70b1e8d7ca6d5415929bca944724702844d0844b5bba865b9e8897d6dd0889ae943c56523b8be0c84ce8ec59e8de9aae7d0346fb32050d77ec37c0ace7
|
7
|
+
data.tar.gz: 864695c0a888a0a22d0039d59be8d3780e3ba9f30afb5ee5fb038ef4be6a958c8ccf53b011b81a6d9aa31670de4b171fbcccbc4b61a7a8da5839438f037daf8a
|
data/.DS_Store
ADDED
Binary file
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
aws-sdk-v1 (1.67.0)
|
5
|
+
json (~> 1.4)
|
6
|
+
nokogiri (~> 1)
|
7
|
+
coderay (1.1.2)
|
8
|
+
json (1.8.6)
|
9
|
+
method_source (0.9.0)
|
10
|
+
mini_portile2 (2.3.0)
|
11
|
+
nokogiri (1.8.2)
|
12
|
+
mini_portile2 (~> 2.3.0)
|
13
|
+
open-uri-s3 (1.6.0)
|
14
|
+
aws-sdk-v1
|
15
|
+
pry (0.11.3)
|
16
|
+
coderay (~> 1.1.0)
|
17
|
+
method_source (~> 0.9.0)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
nokogiri
|
24
|
+
open-uri-s3
|
25
|
+
pry
|
26
|
+
|
27
|
+
BUNDLED WITH
|
28
|
+
1.16.1
|
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Lisa Lee
|
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/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Recipe::Finder::CLI::Gem
|
2
|
+
|
3
|
+
## About
|
4
|
+
|
5
|
+
This is a command-line interface gem for quickly searching recipes from your command-line. This gem scrapes from AllRecipes.com to get a list of the most popular recipes from the results page. The user of this gem can look for any kind of food style or ingredient to find relevant recipes. Once the list of recipe results have been returned, the user can also select a recipe for a more detailed view, looking at in-depth information relating to the recipe's ingredients, instructions, and cooking time. Once they're done with one category, the user can then look for different categories, or exit the gem altogether.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Download this gem from https://github.com/snickers495/food_finder
|
10
|
+
|
11
|
+
## Development
|
12
|
+
|
13
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
14
|
+
|
15
|
+
To run the development version of the CLI run `bin/recipe-finder`.
|
16
|
+
|
17
|
+
## Contributing
|
18
|
+
|
19
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/snickers495/food_finder. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
20
|
+
|
21
|
+
|
22
|
+
## License
|
23
|
+
|
24
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
25
|
+
You can view the license [here](https://github.com/snickers495/food_finder/blob/master/LICENSE.md).
|
data/Rakefile
ADDED
data/bin/.DS_Store
ADDED
Binary file
|
data/bin/console
ADDED
data/bin/recipe-finder
ADDED
data/bin/setup
ADDED
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/finder/cli.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
class RecipeFinder::CLI
|
2
|
+
|
3
|
+
def call
|
4
|
+
puts "Welcome to Find Anything! Where you can quickly FindAnything you want near you"
|
5
|
+
start
|
6
|
+
end
|
7
|
+
|
8
|
+
def start
|
9
|
+
puts ""
|
10
|
+
puts "What are you looking for?"
|
11
|
+
search_item = gets.strip
|
12
|
+
RecipeFinder::Scraper.new.make_items(search_item)
|
13
|
+
show_list("first")
|
14
|
+
end
|
15
|
+
|
16
|
+
def print_items(itemsArray)
|
17
|
+
itemsArray.each do |dish|
|
18
|
+
puts ""
|
19
|
+
puts "#{RecipeFinder::Dish.all.index(dish) + 1}.----------- #{dish.name} -----------"
|
20
|
+
puts ""
|
21
|
+
puts "Stars: #{dish.stars.to_f.round(2)}"
|
22
|
+
puts "Description: #{dish.description}"
|
23
|
+
puts "URL: #{dish.url}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def print_item(dish)
|
28
|
+
puts ""
|
29
|
+
puts "----------- #{dish.name} -----------"
|
30
|
+
puts ""
|
31
|
+
puts "Stars: #{dish.stars.to_f.round(2)}"
|
32
|
+
puts "Description: #{dish.description}"
|
33
|
+
puts "URL: #{dish.url}"
|
34
|
+
puts ""
|
35
|
+
puts "Ingredients: #{dish.ingredients.join(", ")}"
|
36
|
+
puts ""
|
37
|
+
puts "Prep Time: #{dish.time[0].slice(2, dish.time[0].length)}"
|
38
|
+
puts "Cook Time: #{dish.time[1].slice(2, dish.time[1].length)}"
|
39
|
+
puts "Ready in: #{dish.time[2].slice(2, dish.time[2].length)}"
|
40
|
+
puts ""
|
41
|
+
puts "Instructions:"
|
42
|
+
dish.instructions.each do |ele|
|
43
|
+
puts ""
|
44
|
+
puts "#{ele}"
|
45
|
+
end
|
46
|
+
puts "To go back, type 'back'. To exit, type 'exit'"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def show_list(num)
|
51
|
+
five = RecipeFinder::Dish.show(num)
|
52
|
+
print_items(five)
|
53
|
+
puts "Would you like to see more info about one of these? Enter its number, or no."
|
54
|
+
more_info = gets.strip
|
55
|
+
if more_info != "no"
|
56
|
+
index = more_info.to_i
|
57
|
+
specific_item = RecipeFinder::Dish.find(index)
|
58
|
+
RecipeFinder::Scraper.new.more_info(specific_item)
|
59
|
+
print_item(specific_item)
|
60
|
+
next_action = gets.strip
|
61
|
+
if next_action == "exit"
|
62
|
+
ending
|
63
|
+
else
|
64
|
+
show_list(num)
|
65
|
+
end
|
66
|
+
else
|
67
|
+
if (num == "first")
|
68
|
+
puts "Wants to see more search results? Enter yes or no."
|
69
|
+
more_results = gets.strip
|
70
|
+
if more_results != "no"
|
71
|
+
show_list("next")
|
72
|
+
else
|
73
|
+
repeat_end
|
74
|
+
end
|
75
|
+
else
|
76
|
+
repeat_end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def repeat_end
|
82
|
+
puts "Would you like to search for something else? Enter yes or no."
|
83
|
+
restart_input = gets.strip
|
84
|
+
if restart_input == "yes"
|
85
|
+
RecipeFinder::Dish.reset
|
86
|
+
start
|
87
|
+
else
|
88
|
+
ending
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
def ending
|
94
|
+
puts ""
|
95
|
+
puts "Thank you for using this gem!"
|
96
|
+
puts "Hope you use RecipeFinder again."
|
97
|
+
exit
|
98
|
+
end
|
data/lib/finder/dish.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
class RecipeFinder::Dish
|
2
|
+
attr_accessor :name, :stars, :description, :url, :ingredients, :instructions, :time
|
3
|
+
|
4
|
+
@@all = []
|
5
|
+
|
6
|
+
def self.new_from_index_page(search_terms)
|
7
|
+
self.new(
|
8
|
+
search_terms.css(".grid-col__h3.grid-col__h3--recipe-grid a").text.strip,
|
9
|
+
search_terms.at_css(".grid-col__ratings span")["data-ratingstars"],
|
10
|
+
search_terms.css(".rec-card__description").text,
|
11
|
+
search_terms.at_css(".grid-col__h3.grid-col__h3--recipe-grid a")["href"]
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(name, stars=nil, description, url)
|
16
|
+
@name = name
|
17
|
+
@stars = stars
|
18
|
+
@description = description
|
19
|
+
@url = url
|
20
|
+
@@all << self
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.all
|
24
|
+
@@all
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.find(id)
|
28
|
+
self.all[id - 1]
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.reset
|
32
|
+
@@all = []
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_info(page)
|
36
|
+
self.ingredients = []
|
37
|
+
self.instructions = []
|
38
|
+
self.time = []
|
39
|
+
page.css(".recipe-ingred_txt.added")[0..-3].each {|ele| self.ingredients << ele.text}
|
40
|
+
page.css(".recipe-directions__list--item").each {|ele| self.instructions << ele.text}
|
41
|
+
page.css(".prepTime__item time").each {|ele| self.time << ele["datetime"]}
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.show(place)
|
45
|
+
if place == "first"
|
46
|
+
self.all[0..9]
|
47
|
+
elsif place == "next"
|
48
|
+
self.all[10..(self.all.length-1)]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class RecipeFinder::Scraper
|
2
|
+
|
3
|
+
def get_page(search_item)
|
4
|
+
url = "http://allrecipes.com/search/results/?wt="+ search_item + "&sort=re&page=1"
|
5
|
+
Nokogiri::HTML(open(url))
|
6
|
+
end
|
7
|
+
|
8
|
+
def scrape_items_index(search_item)
|
9
|
+
recipes = self.get_page(search_item).css(".grid-col--fixed-tiles:not(.grid-ad)")
|
10
|
+
recipes.select{|ele| ele.at_css(".grid-col__ratings span")}
|
11
|
+
end
|
12
|
+
|
13
|
+
def make_items(search_item)
|
14
|
+
scrape_items_index(search_item).each do |item|
|
15
|
+
RecipeFinder::Dish.new_from_index_page(item)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def more_info(dish)
|
20
|
+
dish.add_info(Nokogiri::HTML(open(dish.url)))
|
21
|
+
end
|
22
|
+
end
|
data/spec.md
ADDED
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: recipe-finder-cli-gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lisa Lee
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-23 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: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
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: '0'
|
48
|
+
type: :development
|
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: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
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: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: RecipeFinder allows users to find recipe scraped from AllRecipes. This
|
112
|
+
gem can quickly gather information on any dish or style, offering instructions,
|
113
|
+
ingredients, ratings, and time required for each dish.
|
114
|
+
email:
|
115
|
+
- lisa_lee@alumni.email
|
116
|
+
executables:
|
117
|
+
- setup
|
118
|
+
- recipe-finder
|
119
|
+
extensions: []
|
120
|
+
extra_rdoc_files: []
|
121
|
+
files:
|
122
|
+
- ".DS_Store"
|
123
|
+
- Gemfile
|
124
|
+
- Gemfile.lock
|
125
|
+
- LICENSE.md
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- bin/.DS_Store
|
129
|
+
- bin/console
|
130
|
+
- bin/recipe-finder
|
131
|
+
- bin/setup
|
132
|
+
- lib/.DS_Store
|
133
|
+
- lib/finder/cli.rb
|
134
|
+
- lib/finder/dish.rb
|
135
|
+
- lib/finder/scraper.rb
|
136
|
+
- lib/finder/version.rb
|
137
|
+
- lib/recipe_finder.rb
|
138
|
+
- spec.md
|
139
|
+
homepage:
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
- lib/recipe_finder
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 2.7.3
|
161
|
+
signing_key:
|
162
|
+
specification_version: 4
|
163
|
+
summary: Find recipes for any food you like using the console. Quickly find recipes
|
164
|
+
for certain ingredients or styles with indepth information provided.
|
165
|
+
test_files: []
|