food_ideas 0.1.0
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/NOTES.md +37 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/food-ideas +5 -0
- data/bin/setup +8 -0
- data/food_ideas.gemspec +35 -0
- data/lib/food_ideas.rb +5 -0
- data/lib/food_ideas/cli.rb +215 -0
- data/lib/food_ideas/recipe.rb +18 -0
- data/lib/food_ideas/scraper.rb +57 -0
- data/lib/food_ideas/string_colors.rb +28 -0
- data/lib/food_ideas/version.rb +3 -0
- metadata +106 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 86e12a66f6e2a4a022f53b68e562abe35ad492c8
|
|
4
|
+
data.tar.gz: 2cc5bb1687c6a91829bef9e8a009c4bb2586cf9c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9213ef8fae281978708b8994699ca29f915ad4e5f12d86dfcd2a92f2de0b85d646e2dc4b8385f5da0cee8092e2512bafcf120020f92aa25bbcdf871b93b8dbeb
|
|
7
|
+
data.tar.gz: 3099b9eb2f962694bcefd8d4918cfb1650cb73171a86b576e83f8d4c3a6acaba20b18338c3875d98720651d436e62790b7bb59e4451999fc5f04b0c0b8106d9c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at williammena1991@gmail.com. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 WilliamMena
|
|
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,37 @@
|
|
|
1
|
+
Ideas
|
|
2
|
+
|
|
3
|
+
Original idea was to list items in your fridge and have the program find recipes for you to try.
|
|
4
|
+
Current Idea is have a user list up to 5 ingrediants and the computer will list the first 3(maybe 5) recipes
|
|
5
|
+
on the site. For now 1 site, maybe two.
|
|
6
|
+
Features in the far future will be have the program create a food schedule for you depending on eating
|
|
7
|
+
5 times a day or 3 big meals. Can be schedule for the day or for the week but that's a bit more complicated.
|
|
8
|
+
I want my CLI to show 3 or 5 recipe ideas listed form 1-5 and if none are good, press option 5 or 6
|
|
9
|
+
to show what's next on the list. Another 5. Currently food network give's 10 recipes on their search results.
|
|
10
|
+
|
|
11
|
+
Name
|
|
12
|
+
Cooking time
|
|
13
|
+
Description if available
|
|
14
|
+
Serving Size
|
|
15
|
+
|
|
16
|
+
CLI INTERFACE
|
|
17
|
+
Hello, welcome to this gem
|
|
18
|
+
Can you please list up to 5 ingrediants?
|
|
19
|
+
Shows 5 numbered recipe names - Serving size - Cooking time
|
|
20
|
+
Enter the number for the recipe you would like for a description and recipe
|
|
21
|
+
Type list for the original list of 5 or Enter to re enter a new list of up to 5 ingrediants
|
|
22
|
+
Goodbye, thank you for using this gem
|
|
23
|
+
|
|
24
|
+
http://www.foodnetwork.com/search/search-results.recipes.html?searchTerm=garlic+cilantro+ground+eggs&form=global&_charset_=UTF-8
|
|
25
|
+
When adding items into the search bar in foodnetwork.com it goes in between the searchTerm= and &form=
|
|
26
|
+
So for every item the user inputs, we can enter a plus inbetween each item
|
|
27
|
+
|
|
28
|
+
http://allrecipes.com/search/results/?ingincl=chicken,mango,cilantro&sort=re
|
|
29
|
+
each item downcased in between ingincl= and &sort=re
|
|
30
|
+
|
|
31
|
+
PROBLEMS
|
|
32
|
+
Have to find solution for when the website returns no results. When no results, it
|
|
33
|
+
only shows one recipe with different/similar ingredients.
|
|
34
|
+
http://www.foodnetwork.com/search/search-results.recipes.html?searchTerm=egg+cheeeeee&form=global&_charset_=UTF-8
|
|
35
|
+
Can use the "showing 1 recipe result for" number inside to determine when to say "Sorry, no results for this. Can you enter another set of ingredients"
|
|
36
|
+
|
|
37
|
+
Can impliment in the code when no results are found and it reroutes to another search.
|
data/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# FoodIdeas
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/food_ideas`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'food_ideas'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install food_ideas
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
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]/food_ideas. 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
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "food_ideas"
|
|
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
|
data/bin/food-ideas
ADDED
data/bin/setup
ADDED
data/food_ideas.gemspec
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'food_ideas/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "food_ideas"
|
|
8
|
+
spec.version = FoodIdeas::VERSION
|
|
9
|
+
spec.authors = ["WilliamMena"]
|
|
10
|
+
spec.email = ["williammena1991@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "My gem purpose is to give you ideas on what to eat when you're undecisive."
|
|
13
|
+
spec.description = "You mention up to 5 ingredients and it will give you back 5 recipes(more recipes soon)."
|
|
14
|
+
spec.homepage = "https://github.com/WilliamMena/food-idea"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
|
19
|
+
|
|
20
|
+
# if spec.respond_to?(:metadata)
|
|
21
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
22
|
+
# else
|
|
23
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
24
|
+
# end
|
|
25
|
+
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
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", "~> 1.11"
|
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
34
|
+
# spec.add_runtime_dependency 'nokogiri', '~> 1.6', '>= 1.6.8'
|
|
35
|
+
end
|
data/lib/food_ideas.rb
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
class CLI
|
|
2
|
+
|
|
3
|
+
require 'pry'
|
|
4
|
+
require 'nokogiri'
|
|
5
|
+
require 'open-uri'
|
|
6
|
+
|
|
7
|
+
@@all_recipes = []
|
|
8
|
+
@@ingredients = []
|
|
9
|
+
|
|
10
|
+
def greet
|
|
11
|
+
puts "Welcome to my gem".bold
|
|
12
|
+
puts "Instructions, blah blah"
|
|
13
|
+
user_ingredients
|
|
14
|
+
ingredients_again
|
|
15
|
+
goodbye
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def user_ingredients
|
|
19
|
+
puts "Please enter up to #{5.to_s.bold} ingredients for the recipe search. Each ingredient one at a time"
|
|
20
|
+
puts "Type #{"'go'".cyan} when no more ingredients"
|
|
21
|
+
puts "\n"
|
|
22
|
+
x = 0
|
|
23
|
+
input = nil
|
|
24
|
+
while input != "exit"
|
|
25
|
+
x += 1
|
|
26
|
+
print "#{x}. "
|
|
27
|
+
input = gets.strip.downcase
|
|
28
|
+
if x >= 5
|
|
29
|
+
puts "This may take a few seconds. Please wait.".bold
|
|
30
|
+
show_recipes
|
|
31
|
+
break
|
|
32
|
+
end
|
|
33
|
+
case input
|
|
34
|
+
when "go"
|
|
35
|
+
puts "This may take a few seconds. Please wait.".bold
|
|
36
|
+
show_recipes
|
|
37
|
+
break
|
|
38
|
+
#search for the recipe
|
|
39
|
+
when "exit"
|
|
40
|
+
#can ask if the user is sure s/he wants to exit the program
|
|
41
|
+
break
|
|
42
|
+
else
|
|
43
|
+
ingredients << input
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def show_recipes
|
|
49
|
+
#system("open #{recipe.url}") Opens the recipes url
|
|
50
|
+
Scraper.new.scrape_food_network
|
|
51
|
+
puts_recipe
|
|
52
|
+
|
|
53
|
+
input = nil
|
|
54
|
+
while input != "exit"
|
|
55
|
+
puts "\n"
|
|
56
|
+
input = gets.strip.downcase
|
|
57
|
+
case input
|
|
58
|
+
when "1"
|
|
59
|
+
puts "#{Recipe.all[0].name}".bold
|
|
60
|
+
puts "Cook time: #{Recipe.all[0].time}"#add servings afterwards seperated with a -
|
|
61
|
+
puts "#{Recipe.all[0].description}"
|
|
62
|
+
puts "\n"
|
|
63
|
+
puts "Type #{"'url'".cyan} to open recipe. #{"'list'".cyan} to view all recipes again. Another number from the list to view another recipe or #{"'exit'".cyan} to exit."
|
|
64
|
+
current_view = 1
|
|
65
|
+
when "2"
|
|
66
|
+
puts "#{Recipe.all[1].name}".bold
|
|
67
|
+
puts "Cook time: #{Recipe.all[1].time}"
|
|
68
|
+
puts "#{Recipe.all[1].description}"
|
|
69
|
+
puts "\n"
|
|
70
|
+
puts "Type #{"'url'".cyan} to open recipe. #{"'list'".cyan} to view all recipes again. Another number from the list to view another recipe or #{"'exit'".cyan} to exit."
|
|
71
|
+
current_view = 2
|
|
72
|
+
when "3"
|
|
73
|
+
puts "#{Recipe.all[2].name}".bold
|
|
74
|
+
puts "Cook time: #{Recipe.all[2].time}"
|
|
75
|
+
puts "#{Recipe.all[2].description}"
|
|
76
|
+
puts "\n"
|
|
77
|
+
puts "Type #{"'url'".cyan} to open recipe. #{"'list'".cyan} to view all recipes again. Another number from the list to view another recipe or #{"'exit'".cyan} to exit."
|
|
78
|
+
current_view = 3
|
|
79
|
+
when "4"
|
|
80
|
+
puts "#{Recipe.all[3].name}".bold
|
|
81
|
+
puts "Cook time: #{Recipe.all[3].time}"
|
|
82
|
+
puts "#{Recipe.all[3].description}"
|
|
83
|
+
puts "\n"
|
|
84
|
+
puts "Type #{"'url'".cyan} to open recipe. #{"'list'".cyan} to view all recipes again. Another number from the list to view another recipe or #{"'exit'".cyan} to exit."
|
|
85
|
+
current_view = 4
|
|
86
|
+
when "5"
|
|
87
|
+
puts "#{Recipe.all[4].name}".bold
|
|
88
|
+
puts "Cook time: #{Recipe.all[4].time}"
|
|
89
|
+
puts "#{Recipe.all[4].description}"
|
|
90
|
+
puts "\n"
|
|
91
|
+
puts "Type #{"'url'".cyan} to open recipe. #{"'list'".cyan} to view all recipes again. Another number from the list to view another recipe or #{"'exit'".cyan} to exit."
|
|
92
|
+
current_view = 5
|
|
93
|
+
when "6"
|
|
94
|
+
puts "next recipes, only 5 for now though, sorry. Work in progress"
|
|
95
|
+
when "list"
|
|
96
|
+
puts_recipe
|
|
97
|
+
when "url"
|
|
98
|
+
system("open #{Recipe.all[current_view-1].url}")
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
#3or5 at a time. Option for showing more recipes.
|
|
102
|
+
#puts out each recipe on it's seperate line and gives the option
|
|
103
|
+
#to enter a number 1-6. 1-5 Will be food options. 6 will be next 5
|
|
104
|
+
#Exit to get out of the program as a whole.
|
|
105
|
+
#List at any point to show the first 5 again.
|
|
106
|
+
#1-5 will give details about the recipe.
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def ingredients
|
|
110
|
+
@@ingredients
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def clear
|
|
114
|
+
@@ingredients.clear
|
|
115
|
+
Recipe.clear
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def self.ingredients
|
|
119
|
+
@@ingredients
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def ingredients_again
|
|
123
|
+
|
|
124
|
+
input = nil
|
|
125
|
+
while input != "n"
|
|
126
|
+
puts "Would you like to enter another set of ingredients? (y/n)"
|
|
127
|
+
input = gets.strip.downcase
|
|
128
|
+
case input
|
|
129
|
+
when "y"
|
|
130
|
+
#the second time around the code breaks
|
|
131
|
+
clear
|
|
132
|
+
user_ingredients
|
|
133
|
+
ingredients_again
|
|
134
|
+
break
|
|
135
|
+
else
|
|
136
|
+
"I'm not sure what you want. Type 'y' for yes, 'n' for no"
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def goodbye
|
|
142
|
+
puts "Thanks for using my gem"
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def puts_recipe
|
|
146
|
+
puts "\n"
|
|
147
|
+
if Recipe.all.length == 0
|
|
148
|
+
puts "There are no recipes for your ingredients. Please EXIT and enter a new set of ingredients.".bold
|
|
149
|
+
else
|
|
150
|
+
puts "YOUR RECIPES".bold
|
|
151
|
+
Recipe.all.each.with_index do |r, i|
|
|
152
|
+
if i+1 <= 5
|
|
153
|
+
puts "#{i+1}. #{Recipe.all[i].name}"
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
# puts "1. #{Recipe.all[0].name}"
|
|
158
|
+
# puts "2. #{Recipe.all[1].name}"
|
|
159
|
+
# puts "3. #{Recipe.all[2].name}"
|
|
160
|
+
# puts "4. #{Recipe.all[3].name}"
|
|
161
|
+
# puts "5. #{Recipe.all[4].name}"
|
|
162
|
+
if Recipe.all.length > 0
|
|
163
|
+
puts "Which recipe would you like more information on? Enter the number"
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class Blog
|
|
171
|
+
require 'nokogiri'
|
|
172
|
+
require 'open-uri'
|
|
173
|
+
def greeting
|
|
174
|
+
"Hey, my name is William Mena and welcome to my blog!"
|
|
175
|
+
ask_topic
|
|
176
|
+
rant
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def ask_topic
|
|
180
|
+
#topics will vary. Enter more questions.
|
|
181
|
+
puts "Why did you join software development?"
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def rant
|
|
185
|
+
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class Recipe
|
|
2
|
+
|
|
3
|
+
attr_accessor :name, :time, :servings, :recipe_ingredients, :directions, :url, :description
|
|
4
|
+
|
|
5
|
+
@@all_recipes = []
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
@@all_recipes << self
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.clear
|
|
12
|
+
@@all_recipes.clear
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.all
|
|
16
|
+
@@all_recipes
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require 'pry'
|
|
3
|
+
require 'nokogiri'
|
|
4
|
+
class Scraper
|
|
5
|
+
attr_accessor :url_middle, :url_begin, :url_end
|
|
6
|
+
attr_reader :food_network_url
|
|
7
|
+
#http://www.foodnetwork.com/search/search-results.recipes.html?searchTerm=garlic+cilantro+ground+waffles&form=global&_charset_=UTF-8
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def scrape_food_network
|
|
12
|
+
@url_begin = "http://www.foodnetwork.com/search/search-results.recipes.html?searchTerm="
|
|
13
|
+
@url_end = "&form=global&_charset_=UTF-8"
|
|
14
|
+
doc = Nokogiri::HTML(open(url_full))
|
|
15
|
+
doc.css("article.recipe").each do |r|
|
|
16
|
+
recipe = Recipe.new
|
|
17
|
+
recipe.name = r.css("h6").text.strip
|
|
18
|
+
recipe.time = r.css("dd").text
|
|
19
|
+
recipe.url = food_network_url+r.css("h6 a").attr("href").value
|
|
20
|
+
recipe_doc = Nokogiri::HTML(open(recipe.url))
|
|
21
|
+
recipe.description = recipe_doc.css("p.quotation").text.strip.delete "[]"
|
|
22
|
+
if recipe.description.empty?
|
|
23
|
+
recipe.description = "Sorry, no description available."
|
|
24
|
+
end
|
|
25
|
+
# recipe.name = doc.css("article.recipe").first.css("h6").text.strip
|
|
26
|
+
# recipe.time = doc.css("article.recipe").first.css("dd").text
|
|
27
|
+
# recipe.url = food_network_url+doc.css("article.recipe").first.css("h6 a").attr("href").value
|
|
28
|
+
# recipe.description = recipe_doc.css("p.quotation").text.strip.delete "[]"
|
|
29
|
+
end
|
|
30
|
+
#doc.css("article.recipe").first.css("h6").text.strip == NAME
|
|
31
|
+
#doc.css("article.recipe").first.css("dd").text == Cooking Time
|
|
32
|
+
#doc.css("article.recipe").first.css("h6 a").attr("href").value == URL
|
|
33
|
+
#can be used to guide to link info and it's where I need to retrieve description and serving size
|
|
34
|
+
#have to join with original site name
|
|
35
|
+
#recipe_url = food_network_url+doc.css("article.recipe").first.css("h6 a").attr("href").value == recipes URL
|
|
36
|
+
#recipe_doc = Nokogiri::HTML(open(recipe.url))
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.ingredients
|
|
40
|
+
CLI.ingredients
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def url_full
|
|
44
|
+
@url_middle = Scraper.ingredients.join("+")
|
|
45
|
+
full = @url_begin+@url_middle+@url_end
|
|
46
|
+
full
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def food_network_url
|
|
50
|
+
"http://www.foodnetwork.com"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class String
|
|
2
|
+
def black; "\e[30m#{self}\e[0m" end
|
|
3
|
+
def red; "\e[31m#{self}\e[0m" end
|
|
4
|
+
def green; "\e[32m#{self}\e[0m" end
|
|
5
|
+
def brown; "\e[33m#{self}\e[0m" end
|
|
6
|
+
def blue; "\e[34m#{self}\e[0m" end
|
|
7
|
+
def magenta; "\e[35m#{self}\e[0m" end
|
|
8
|
+
def cyan; "\e[36m#{self}\e[0m" end
|
|
9
|
+
def gray; "\e[37m#{self}\e[0m" end
|
|
10
|
+
|
|
11
|
+
def bg_black; "\e[40m#{self}\e[0m" end
|
|
12
|
+
def bg_red; "\e[41m#{self}\e[0m" end
|
|
13
|
+
def bg_green; "\e[42m#{self}\e[0m" end
|
|
14
|
+
def bg_brown; "\e[43m#{self}\e[0m" end
|
|
15
|
+
def bg_blue; "\e[44m#{self}\e[0m" end
|
|
16
|
+
def bg_magenta; "\e[45m#{self}\e[0m" end
|
|
17
|
+
def bg_cyan; "\e[46m#{self}\e[0m" end
|
|
18
|
+
def bg_gray; "\e[47m#{self}\e[0m" end
|
|
19
|
+
|
|
20
|
+
def bold; "\e[1m#{self}\e[22m" end
|
|
21
|
+
def italic; "\e[3m#{self}\e[23m" end
|
|
22
|
+
def underline; "\e[4m#{self}\e[24m" end
|
|
23
|
+
def blink; "\e[5m#{self}\e[25m" end
|
|
24
|
+
def reverse_color; "\e[7m#{self}\e[27m" end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Thanks to Ivan Black
|
|
28
|
+
# http://stackoverflow.com/questions/1489183/colorized-ruby-output
|
metadata
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: food_ideas
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- WilliamMena
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-06-15 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.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
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: You mention up to 5 ingredients and it will give you back 5 recipes(more
|
|
56
|
+
recipes soon).
|
|
57
|
+
email:
|
|
58
|
+
- williammena1991@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/food-ideas
|
|
74
|
+
- bin/setup
|
|
75
|
+
- food_ideas.gemspec
|
|
76
|
+
- lib/food_ideas.rb
|
|
77
|
+
- lib/food_ideas/cli.rb
|
|
78
|
+
- lib/food_ideas/recipe.rb
|
|
79
|
+
- lib/food_ideas/scraper.rb
|
|
80
|
+
- lib/food_ideas/string_colors.rb
|
|
81
|
+
- lib/food_ideas/version.rb
|
|
82
|
+
homepage: https://github.com/WilliamMena/food-idea
|
|
83
|
+
licenses:
|
|
84
|
+
- MIT
|
|
85
|
+
metadata: {}
|
|
86
|
+
post_install_message:
|
|
87
|
+
rdoc_options: []
|
|
88
|
+
require_paths:
|
|
89
|
+
- lib
|
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
requirements: []
|
|
101
|
+
rubyforge_project:
|
|
102
|
+
rubygems_version: 2.4.5.1
|
|
103
|
+
signing_key:
|
|
104
|
+
specification_version: 4
|
|
105
|
+
summary: My gem purpose is to give you ideas on what to eat when you're undecisive.
|
|
106
|
+
test_files: []
|