find_recipe 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 +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/find-recipe +5 -0
- data/bin/setup +8 -0
- data/find_recipe.gemspec +41 -0
- data/lib/find_recipe.rb +15 -0
- data/lib/find_recipe/cli.rb +127 -0
- data/lib/find_recipe/recipe.rb +57 -0
- data/lib/find_recipe/scraper.rb +60 -0
- data/lib/find_recipe/version.rb +3 -0
- data/planning_notes.md +31 -0
- data/spec.md +14 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 18e9f6c1e1dc8b7c5323f2799d65320a07f07941
|
4
|
+
data.tar.gz: 152d2441751d34a2a573ad35272267ea1239b36f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fa77a12b522dff5aa252c4f4fbafc73f7e7c1d0c4e478506a7f41e0af1f155da99a61d29275c3c864204dd7f8f1db64329f9f34268e4a5bbe869ac2a6d94f3ad
|
7
|
+
data.tar.gz: '057578a1bf966c2880ec426f040823e07c1139af2a034cacfc3f2dbf5c535a9e61154a08dc4b6f02d5d2f2ca9b713346022988c339ed4d4f979a5e2cc54f5f02'
|
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 forby.1@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) 2018 Felice Forby
|
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,43 @@
|
|
1
|
+
# FindRecipe
|
2
|
+
|
3
|
+
This CLI gem helps you get some cooking inspiration directly from your command line! Find a recipe by looking at a list of trending recipes from Cookpad or search with a keyword such as a dish name or ingredient name.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'find_recipe'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install find_recipe
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Type the below and follow the on screen prompts.
|
24
|
+
|
25
|
+
$ find-recipe
|
26
|
+
|
27
|
+
You will be asked whether you want to see the trending recipes list or whether you want to search with a keyword. If you choose to search, enter a dish name or ingredient name to see a list of recipes based on your input.
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
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.
|
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/morinoko/find_recipe. Or if you have some feature ideas, let me know and I'll see what I can do :) 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.
|
38
|
+
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
43
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "find_recipe"
|
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/find-recipe
ADDED
data/bin/setup
ADDED
data/find_recipe.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'find_recipe/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "find_recipe"
|
8
|
+
spec.version = FindRecipe::VERSION
|
9
|
+
spec.authors = ["Felice Forby"]
|
10
|
+
spec.email = ["feliceforby@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{This CLI app lets you find a recipe from a trending recipe list or with a search word.}
|
13
|
+
spec.description = %q{This CLI app lets you find a recipe from a trending recipe list or with a search word. Recipes are sourced from Cookpad's English recipe page. Have fun and eat well!}
|
14
|
+
spec.homepage = "https://github.com/morinoko/find-recipe-cli-app"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_development_dependency "pry", "~> 0.10.3"
|
37
|
+
|
38
|
+
spec.add_dependency "nokogiri", "~> 1.8", ">= 1.8.2"
|
39
|
+
spec.add_dependency "colorize", "~> 0.8.1"
|
40
|
+
|
41
|
+
end
|
data/lib/find_recipe.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Loads the needed files.
|
2
|
+
require 'open-uri'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'colorize'
|
5
|
+
# Uncomment below if you need to use pry for debugging, etc.
|
6
|
+
# require 'pry'
|
7
|
+
|
8
|
+
require_relative "find_recipe/version"
|
9
|
+
|
10
|
+
module FindRecipe
|
11
|
+
end
|
12
|
+
|
13
|
+
require_relative "find_recipe/cli"
|
14
|
+
require_relative "find_recipe/recipe"
|
15
|
+
require_relative "find_recipe/scraper"
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# This Class acts as the CLI Controller
|
2
|
+
class FindRecipe::CLI
|
3
|
+
|
4
|
+
def call
|
5
|
+
search_options
|
6
|
+
end
|
7
|
+
|
8
|
+
def search_options
|
9
|
+
puts ""
|
10
|
+
puts "Welcome!".red
|
11
|
+
puts "How do you want to get started?"
|
12
|
+
puts ""
|
13
|
+
puts "1.".blue + " See trending recipes"
|
14
|
+
puts "2.".blue + " Search for a recipe"
|
15
|
+
puts ""
|
16
|
+
puts "Enter 1 or 2, or exit"
|
17
|
+
|
18
|
+
input = gets.strip.downcase
|
19
|
+
|
20
|
+
if input == "1"
|
21
|
+
|
22
|
+
# Scrapes recipes only once to save loading time
|
23
|
+
if !@trending_recipes
|
24
|
+
puts "Please wait a moment for the recipes to be loaded..."
|
25
|
+
@trending_recipes = FindRecipe::Recipe.create_recipes
|
26
|
+
end
|
27
|
+
trending_recipes
|
28
|
+
elsif input == "2"
|
29
|
+
|
30
|
+
# Scrape recipes only if a search hasn't been done yet or if user restarts
|
31
|
+
if !@searched_recipes || @searched_recipes.length == 0
|
32
|
+
puts "What is the dish or ingredient you want to search for?"
|
33
|
+
input = gets.strip.downcase
|
34
|
+
puts "Please wait a moment for the recipes to be loaded..."
|
35
|
+
|
36
|
+
# If search keyword has spaces, it's necessary to replace them with %20 so the URL works
|
37
|
+
@searched_recipes = FindRecipe::Recipe.create_recipes( input.gsub( " ", "%20" ) )
|
38
|
+
end
|
39
|
+
choose_searched_recipes
|
40
|
+
elsif input == "exit"
|
41
|
+
exit_program
|
42
|
+
else
|
43
|
+
puts "Not sure what you mean..."
|
44
|
+
search_options
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def trending_recipes
|
50
|
+
puts "\n\n"
|
51
|
+
@trending_recipes.each.with_index( 1 ) do |recipe, index|
|
52
|
+
puts "#{index}.".green + " #{recipe.name}"
|
53
|
+
end
|
54
|
+
|
55
|
+
puts ""
|
56
|
+
puts "Choose a recipe number or type 'back'"
|
57
|
+
|
58
|
+
input = gets.strip.downcase
|
59
|
+
|
60
|
+
if input.to_i > 0 && input.to_i <= @trending_recipes.count
|
61
|
+
@trending_recipes[ input.to_i - 1 ].get_details
|
62
|
+
elsif input == "back"
|
63
|
+
search_options
|
64
|
+
else
|
65
|
+
puts "Not sure what you mean..."
|
66
|
+
puts ""
|
67
|
+
trending_recipes
|
68
|
+
end
|
69
|
+
|
70
|
+
puts "Do you want to see the list again, restart, or exit?"
|
71
|
+
puts "Enter list, restart, or exit"
|
72
|
+
input = gets.strip.downcase
|
73
|
+
|
74
|
+
if input == "list"
|
75
|
+
trending_recipes
|
76
|
+
elsif input == "restart"
|
77
|
+
search_options
|
78
|
+
elsif input == "exit"
|
79
|
+
exit_program
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
def choose_searched_recipes
|
85
|
+
puts "\n\n"
|
86
|
+
puts "Search Results:".yellow
|
87
|
+
puts ""
|
88
|
+
@searched_recipes.each.with_index( 1 ) do |recipe, index|
|
89
|
+
puts "#{index}.".green + " #{recipe.name}"
|
90
|
+
end
|
91
|
+
|
92
|
+
puts ""
|
93
|
+
puts "Choose a recipe number or type 'restart'"
|
94
|
+
|
95
|
+
input = gets.strip.downcase
|
96
|
+
|
97
|
+
if input.to_i > 0 && input.to_i <= @searched_recipes.count
|
98
|
+
@searched_recipes[ input.to_i - 1 ].get_details
|
99
|
+
elsif input == "restart"
|
100
|
+
@searched_recipes.clear
|
101
|
+
search_options
|
102
|
+
else
|
103
|
+
puts "Not sure what you mean..."
|
104
|
+
choose_searched_recipes
|
105
|
+
end
|
106
|
+
|
107
|
+
puts "Do you want to see the list again, restart, or exit?"
|
108
|
+
puts "Enter list, restart, or exit"
|
109
|
+
input = gets.strip.downcase
|
110
|
+
|
111
|
+
if input == "list"
|
112
|
+
choose_searched_recipes
|
113
|
+
elsif input == "restart"
|
114
|
+
@searched_recipes.clear
|
115
|
+
search_options
|
116
|
+
elsif input == "exit"
|
117
|
+
exit_program
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
def exit_program
|
123
|
+
puts "See you next time!"
|
124
|
+
exit
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class FindRecipe::Recipe
|
2
|
+
attr_accessor :name, :description, :ingredients, :steps, :url
|
3
|
+
|
4
|
+
# Passes in data from scraper when recipe is created
|
5
|
+
def initialize( recipe_hash )
|
6
|
+
recipe_hash.each do |attribute, value|
|
7
|
+
self.send( ("#{attribute}=" ), value)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Create recipes based off an array of recipe data hashes output by the scraper
|
12
|
+
def self.create_recipes( keyword = nil )
|
13
|
+
if keyword
|
14
|
+
recipe_array = FindRecipe::Scraper.scrape_search_page( keyword )
|
15
|
+
else
|
16
|
+
recipe_array = FindRecipe::Scraper.scrape_trending_recipes_page
|
17
|
+
end
|
18
|
+
|
19
|
+
recipes = recipe_array.collect do |recipe|
|
20
|
+
self.new( recipe )
|
21
|
+
end
|
22
|
+
|
23
|
+
# Add remaining attributes from each individual recipe page
|
24
|
+
recipes.each do |recipe|
|
25
|
+
additional_recipe_data = FindRecipe::Scraper.scrape_individual_recipe_data( recipe.url )
|
26
|
+
recipe.add_additional_recipe_data( additional_recipe_data )
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_additional_recipe_data( data_hash )
|
31
|
+
data_hash.each do |attribute, value|
|
32
|
+
self.send( ("#{attribute}="), value )
|
33
|
+
end
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_details
|
38
|
+
puts "\n\n"
|
39
|
+
puts "Details for #{@name}:"
|
40
|
+
puts "\n\n"
|
41
|
+
puts "Description:".green
|
42
|
+
puts @description
|
43
|
+
puts "\n\n"
|
44
|
+
puts "Ingredients:".green
|
45
|
+
@ingredients.each do |ingredient|
|
46
|
+
puts ingredient
|
47
|
+
end
|
48
|
+
puts "\n\n"
|
49
|
+
puts "Steps:".green
|
50
|
+
@steps.each.with_index( 1 ) do |step, step_number|
|
51
|
+
puts "#{step_number}.".blue + " #{step}"
|
52
|
+
end
|
53
|
+
puts "\n\n"
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class FindRecipe::Scraper
|
2
|
+
ROOT_URL = "https://cookpad.com"
|
3
|
+
|
4
|
+
def self.scrape_trending_recipes_page
|
5
|
+
recipe_page = self.get_trending_recipes_page
|
6
|
+
|
7
|
+
recipe_cards = recipe_page.css( ".card.feed__card" )
|
8
|
+
recipe_cards.collect do |card|
|
9
|
+
recipe = {
|
10
|
+
name: card.css( "h2.recipe-title" ).text.strip,
|
11
|
+
url: ROOT_URL + card.css( "a.link-unstyled" ).attribute( "href" ).value
|
12
|
+
}
|
13
|
+
end.uniq
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.scrape_search_page( keyword )
|
17
|
+
recipe_page = self.get_recipe_page_from_keyword( keyword )
|
18
|
+
|
19
|
+
recipe_cards = recipe_page.css( "li.wide-card" )
|
20
|
+
recipe_cards.collect do |card|
|
21
|
+
recipe = {
|
22
|
+
name: card.css( "h2.recipe-title span" ).text.strip,
|
23
|
+
url: ROOT_URL + card.css( "a.media" ).attribute( "href" ).value
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.scrape_individual_recipe_data( recipe_url )
|
29
|
+
recipe_data = {}
|
30
|
+
|
31
|
+
recipe_page = self.get_individual_recipe_page( recipe_url )
|
32
|
+
recipe_data[:description] = recipe_page.at( "meta[itemprop='description']" )['content']
|
33
|
+
|
34
|
+
# Gets ingredients as an array of each ingredient
|
35
|
+
recipe_data[:ingredients] = recipe_page.css( ".ingredient__details" ).collect{ |ingredient| ingredient.text.strip }
|
36
|
+
|
37
|
+
# Gets steps as an array of each step
|
38
|
+
recipe_data[:steps] = recipe_page.css( ".step .prose" ).collect{ |step| step.text.strip }
|
39
|
+
|
40
|
+
recipe_data
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.get_trending_recipes_page
|
44
|
+
url = ROOT_URL + "/uk/trending"
|
45
|
+
open_url( url )
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.get_recipe_page_from_keyword( keyword )
|
49
|
+
url = ROOT_URL + "/uk/search/#{keyword}"
|
50
|
+
open_url( url )
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.get_individual_recipe_page( recipe_url )
|
54
|
+
open_url( recipe_url )
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.open_url( url )
|
58
|
+
Nokogiri::HTML( open( url ) )
|
59
|
+
end
|
60
|
+
end
|
data/planning_notes.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
CLI Planning Notes
|
2
|
+
|
3
|
+
These are the original notes outlining the functionality/specs of this app.
|
4
|
+
|
5
|
+
|
6
|
+
User types "find-recipe" in the command line
|
7
|
+
|
8
|
+
Ask how the user wants to see the recipes:
|
9
|
+
|
10
|
+
How do you want to get your cooking inspiration?
|
11
|
+
1. See trending recipes
|
12
|
+
2. Search for a recipe
|
13
|
+
|
14
|
+
> Trending recipes gets recipe titles from a trending recipes or popular recipes page.
|
15
|
+
|
16
|
+
> Search gets recipes using a keyword input by the user; for example, an ingredient or dish name.
|
17
|
+
|
18
|
+
After choosing either option, the app will provide a list of recipe names from which the user can choose to see more details about.
|
19
|
+
|
20
|
+
1. Spaghetti with Meatballs
|
21
|
+
2. Creamy mushroom pasta
|
22
|
+
3. Lasagna
|
23
|
+
4. ....
|
24
|
+
|
25
|
+
Ask user to choose a recipe or start over.
|
26
|
+
|
27
|
+
If the user chooses a number, which will then list that recipe's details: description, ingredients, and steps.
|
28
|
+
|
29
|
+
Ask whether the user wants to go back to the list, start over, or exit.
|
30
|
+
|
31
|
+
Other: Typing "exit" at any time during the program will stop it.
|
data/spec.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Specifications for the CLI Assessment
|
2
|
+
|
3
|
+
## Specs:
|
4
|
+
- [x] Have a CLI for interfacing with the application
|
5
|
+
The FindRecipe CLI app allows users to find recipes in two ways: Looking at a list of trending recipes or by seeing a list of recipes based on a user-input search word. The command line interface walks the user through the process by first asking them how they want to find a recipe, then displays a list of recipe titles accordingly. Users can choose a recipe from the list to view its details, including the ingredients and steps. After viewing a recipes, users can then choose to go back to the list if they want to see a different recipe, start over from the beginning, or exit the program.
|
6
|
+
|
7
|
+
The CLI logic is separated into its own class and within it, each search option is handled by a separate function. The CLI makes use of the Recipe class to create recipes based on how the user wants to search.
|
8
|
+
|
9
|
+
- [x] Pull data from an external source
|
10
|
+
FindRecipe uses Nokogiri and Open-URI to scrape recipe data from Cookpad's English website. If the user chooses to see trending recipes, the app gets the recipes from the Trending page. If they choose to search with a keyword, then the app uses a search page based on the keyword.
|
11
|
+
|
12
|
+
|
13
|
+
- [x] Implement both list and detail views
|
14
|
+
When the user chooses a search option, first, a numbered list of recipe titles is displayed. By choosing a number, the details of that recipes are shown including the description, ingredients, and cooking steps.
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: find_recipe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Felice Forby
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-27 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.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.10.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.10.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.8'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.8.2
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.8'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.8.2
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: colorize
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.8.1
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.8.1
|
103
|
+
description: This CLI app lets you find a recipe from a trending recipe list or with
|
104
|
+
a search word. Recipes are sourced from Cookpad's English recipe page. Have fun
|
105
|
+
and eat well!
|
106
|
+
email:
|
107
|
+
- feliceforby@gmail.com
|
108
|
+
executables: []
|
109
|
+
extensions: []
|
110
|
+
extra_rdoc_files: []
|
111
|
+
files:
|
112
|
+
- ".gitignore"
|
113
|
+
- ".rspec"
|
114
|
+
- ".travis.yml"
|
115
|
+
- CODE_OF_CONDUCT.md
|
116
|
+
- Gemfile
|
117
|
+
- LICENSE.txt
|
118
|
+
- README.md
|
119
|
+
- Rakefile
|
120
|
+
- bin/console
|
121
|
+
- bin/find-recipe
|
122
|
+
- bin/setup
|
123
|
+
- find_recipe.gemspec
|
124
|
+
- lib/find_recipe.rb
|
125
|
+
- lib/find_recipe/cli.rb
|
126
|
+
- lib/find_recipe/recipe.rb
|
127
|
+
- lib/find_recipe/scraper.rb
|
128
|
+
- lib/find_recipe/version.rb
|
129
|
+
- planning_notes.md
|
130
|
+
- spec.md
|
131
|
+
homepage: https://github.com/morinoko/find-recipe-cli-app
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata:
|
135
|
+
allowed_push_host: https://rubygems.org
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.6.11
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: This CLI app lets you find a recipe from a trending recipe list or with a
|
156
|
+
search word.
|
157
|
+
test_files: []
|