riperecipes 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 +12 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +17 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +45 -0
- data/LICENSE.txt +21 -0
- data/README.md +38 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/riperecipe +6 -0
- data/bin/setup +8 -0
- data/lib/riperecipes/cli.rb +95 -0
- data/lib/riperecipes/recipe.rb +209 -0
- data/lib/riperecipes/version.rb +3 -0
- data/lib/riperecipes.rb +11 -0
- data/riperecipes.gemspec +44 -0
- metadata +118 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1788c10dadfb2c569fc08c9e7eabb1209c5a98c7b5825f803cb9f1a7f7f2cd11
|
|
4
|
+
data.tar.gz: 4b4044082a20cefe562138604c5e3e45b4d7c10d1b945cb8d0f6c9c7e6a74b5e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5001da1819724d9b03807d5ffba0be19be5065ec536c9278726e72977768f72f01c75bd07e33370ea045f8caf56797bcc61e782f0e252d45fa8907ffa855abe8
|
|
7
|
+
data.tar.gz: af3120ca5f219ebe30d8aad2571e4298eae4e53cc200027053fabdc41af87dfa3d340e654e0ad38bb28a40a5a71c9aaff035a06a58ba9571236039c48ff0ac41
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Added
|
|
2
|
+
This section if for new features
|
|
3
|
+
|
|
4
|
+
Changed
|
|
5
|
+
This section keeps track of changes in existing functionality
|
|
6
|
+
|
|
7
|
+
Depreciated
|
|
8
|
+
This section is for soon-to-be removed features
|
|
9
|
+
|
|
10
|
+
Removed
|
|
11
|
+
This section is for removed features
|
|
12
|
+
|
|
13
|
+
Fixed
|
|
14
|
+
This section is for any bug fixes
|
|
15
|
+
|
|
16
|
+
Security
|
|
17
|
+
This section is here just in case there are vulnerabilities
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
riperecipes (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
coderay (1.1.2)
|
|
10
|
+
diff-lcs (1.3)
|
|
11
|
+
method_source (0.9.2)
|
|
12
|
+
mini_portile2 (2.4.0)
|
|
13
|
+
nokogiri (1.10.3)
|
|
14
|
+
mini_portile2 (~> 2.4.0)
|
|
15
|
+
pry (0.12.2)
|
|
16
|
+
coderay (~> 1.1.0)
|
|
17
|
+
method_source (~> 0.9.0)
|
|
18
|
+
rake (10.5.0)
|
|
19
|
+
rspec (3.8.0)
|
|
20
|
+
rspec-core (~> 3.8.0)
|
|
21
|
+
rspec-expectations (~> 3.8.0)
|
|
22
|
+
rspec-mocks (~> 3.8.0)
|
|
23
|
+
rspec-core (3.8.0)
|
|
24
|
+
rspec-support (~> 3.8.0)
|
|
25
|
+
rspec-expectations (3.8.3)
|
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
27
|
+
rspec-support (~> 3.8.0)
|
|
28
|
+
rspec-mocks (3.8.0)
|
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
30
|
+
rspec-support (~> 3.8.0)
|
|
31
|
+
rspec-support (3.8.0)
|
|
32
|
+
|
|
33
|
+
PLATFORMS
|
|
34
|
+
ruby
|
|
35
|
+
|
|
36
|
+
DEPENDENCIES
|
|
37
|
+
bundler (~> 2.0)
|
|
38
|
+
nokogiri
|
|
39
|
+
pry
|
|
40
|
+
rake (~> 10.0)
|
|
41
|
+
riperecipes!
|
|
42
|
+
rspec
|
|
43
|
+
|
|
44
|
+
BUNDLED WITH
|
|
45
|
+
2.0.1
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 arpethel
|
|
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,38 @@
|
|
|
1
|
+
# Riperecipes
|
|
2
|
+
|
|
3
|
+
riperecipes is a simple CLI gem to get recipe ingredients from AllRecipes.com for select meals. This gem pulls
|
|
4
|
+
data from the "Most Made Today" section of five different cuisines: Asian, Indian, Italian, Mexican and Southern.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'riperecipes'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And then execute:
|
|
15
|
+
|
|
16
|
+
$ bundle
|
|
17
|
+
|
|
18
|
+
Or install it yourself as:
|
|
19
|
+
|
|
20
|
+
$ gem install riperecipes
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
This gem provides a Command Line Interface (CLI) to an external data source (allrecipes.com).
|
|
25
|
+
|
|
26
|
+
## Development
|
|
27
|
+
|
|
28
|
+
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.
|
|
29
|
+
|
|
30
|
+
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).
|
|
31
|
+
|
|
32
|
+
## Contributing
|
|
33
|
+
|
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/arpethel/riperecipes.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "riperecipes"
|
|
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/riperecipe
ADDED
data/bin/setup
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# CLI Controller
|
|
2
|
+
class Riperecipes::CLI
|
|
3
|
+
|
|
4
|
+
def call
|
|
5
|
+
list
|
|
6
|
+
menu
|
|
7
|
+
goodbye
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list
|
|
11
|
+
puts " "
|
|
12
|
+
puts "Welcome to Ripe Recipes!"
|
|
13
|
+
puts "This tool provides you with cuisine suggestions for today!"
|
|
14
|
+
puts " "
|
|
15
|
+
@recipe = Riperecipes::Recipe.today
|
|
16
|
+
@recipe.each.with_index(1) do |cuisines, i|
|
|
17
|
+
puts "#{i}. #{cuisines.cuisine} - #{cuisines.name} - Ready In: #{cuisines.ready_time}"
|
|
18
|
+
end
|
|
19
|
+
puts " "
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def menu
|
|
23
|
+
|
|
24
|
+
puts "For a particular cuisine, enter 'Asian', 'Indian', 'Italian', 'Mexican', or 'Southern'."
|
|
25
|
+
puts "You can also type 'quit', to quit."
|
|
26
|
+
puts "Which cuisine would you like to explore today?"
|
|
27
|
+
# @recipe = Riperecipes::Recipe.today
|
|
28
|
+
input = nil
|
|
29
|
+
while input != 'quit'
|
|
30
|
+
# puts " "
|
|
31
|
+
# puts "Welcome to Ripe Recipes!"
|
|
32
|
+
# puts "This tool provides you with cuisine suggestions for today!"
|
|
33
|
+
# puts " "
|
|
34
|
+
puts "For another cuisine, enter 'Asian', 'Indian', 'Italian', 'Mexican', or 'Southern'."
|
|
35
|
+
puts "Or, type 'quit', to quit."
|
|
36
|
+
# puts "Which cuisine would you like to explore today?"
|
|
37
|
+
|
|
38
|
+
input = gets.strip
|
|
39
|
+
|
|
40
|
+
case input
|
|
41
|
+
when 'Asian'
|
|
42
|
+
asian = @recipe[0]
|
|
43
|
+
puts " "
|
|
44
|
+
puts "-------------------------------------------"
|
|
45
|
+
puts "#{asian.cuisine} - #{asian.name} - Ready In: #{asian.ready_time} #{asian.list_of_ingredients}"
|
|
46
|
+
puts " "
|
|
47
|
+
puts asian.directions
|
|
48
|
+
puts "-------------------------------------------"
|
|
49
|
+
puts " "
|
|
50
|
+
when 'Indian'
|
|
51
|
+
indian = @recipe[1]
|
|
52
|
+
puts " "
|
|
53
|
+
puts "-------------------------------------------"
|
|
54
|
+
puts "#{indian.cuisine} - #{indian.name} - Ready In: #{indian.ready_time} #{indian.list_of_ingredients}"
|
|
55
|
+
puts " "
|
|
56
|
+
puts indian.directions
|
|
57
|
+
puts "-------------------------------------------"
|
|
58
|
+
puts " "
|
|
59
|
+
when 'Italian'
|
|
60
|
+
italian = @recipe[2]
|
|
61
|
+
puts " "
|
|
62
|
+
puts "-------------------------------------------"
|
|
63
|
+
puts "#{italian.cuisine} - #{italian.name} - Ready In: #{italian.ready_time} #{italian.list_of_ingredients}"
|
|
64
|
+
puts " "
|
|
65
|
+
puts italian.directions
|
|
66
|
+
puts "-------------------------------------------"
|
|
67
|
+
puts " "
|
|
68
|
+
when 'Mexican'
|
|
69
|
+
mexican = @recipe[3]
|
|
70
|
+
puts " "
|
|
71
|
+
puts "-------------------------------------------"
|
|
72
|
+
puts "#{mexican.cuisine} - #{mexican.name} - Ready In: #{mexican.ready_time} #{mexican.list_of_ingredients}"
|
|
73
|
+
puts " "
|
|
74
|
+
puts mexican.directions
|
|
75
|
+
puts "-------------------------------------------"
|
|
76
|
+
puts " "
|
|
77
|
+
when 'Southern'
|
|
78
|
+
southern = @recipe[4]
|
|
79
|
+
puts " "
|
|
80
|
+
puts "-------------------------------------------"
|
|
81
|
+
puts "#{southern.cuisine} - #{southern.name} - Ready In: #{southern.ready_time} #{southern.list_of_ingredients}"
|
|
82
|
+
puts " "
|
|
83
|
+
puts southern.directions
|
|
84
|
+
puts "-------------------------------------------"
|
|
85
|
+
puts " "
|
|
86
|
+
else
|
|
87
|
+
puts "Please enter a known selection. Otherwise type 'quit' to quit."
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def goodbye
|
|
93
|
+
puts "Thanks for stopping by! Goodbye!"
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
class Riperecipes::Recipe
|
|
2
|
+
attr_accessor :name, :list_of_ingredients, :url, :directions, :cuisine, :ready_time
|
|
3
|
+
|
|
4
|
+
def self.today
|
|
5
|
+
self.scrape_recipes
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.scrape_recipes
|
|
9
|
+
all_recipes = []
|
|
10
|
+
|
|
11
|
+
all_recipes << self.scrape_asian
|
|
12
|
+
all_recipes << self.scrape_indian
|
|
13
|
+
all_recipes << self.scrape_italian
|
|
14
|
+
all_recipes << self.scrape_mexican
|
|
15
|
+
all_recipes << self.scrape_southern
|
|
16
|
+
|
|
17
|
+
all_recipes
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.scrape_asian
|
|
21
|
+
doc_asian_name = Nokogiri::HTML(open("https://www.allrecipes.com/recipes/227/world-cuisine/asian/"))
|
|
22
|
+
|
|
23
|
+
asian_recipe = self.new
|
|
24
|
+
asian_recipe.cuisine = "Asian"
|
|
25
|
+
asian_recipe.name = doc_asian_name.search("h3")[12].text
|
|
26
|
+
|
|
27
|
+
doc_asian_ingredients = Nokogiri::HTML(open("https://www.allrecipes.com/recipe/128601/my-favorite-sesame-noodles/?internalSource=streams&referringId=227&referringContentType=Recipe%20Hub&clickId=st_recipes_mades"))
|
|
28
|
+
|
|
29
|
+
asian_recipe.ready_time = doc_asian_ingredients.search("span.ready-in-time").text
|
|
30
|
+
asian_directions = doc_asian_ingredients.search("span.recipe-directions__list--item").text.split
|
|
31
|
+
asian_recipe.directions = asian_directions.join(" ")
|
|
32
|
+
|
|
33
|
+
ingredient_items = []
|
|
34
|
+
|
|
35
|
+
# First Colomn of Ingredients
|
|
36
|
+
asian_ingredients_1 = []
|
|
37
|
+
asian_ingredients_1 << doc_asian_ingredients.search("#lst_ingredients_1 span.recipe-ingred_txt")
|
|
38
|
+
asian_ingredients_1.each do |item|
|
|
39
|
+
item.each do |each_item|
|
|
40
|
+
ingredient_items << each_item.text
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Second Colomn of Ingredients
|
|
45
|
+
asian_ingredients_2 = []
|
|
46
|
+
asian_ingredients_2 << doc_asian_ingredients.search("#lst_ingredients_2 span.recipe-ingred_txt")
|
|
47
|
+
asian_ingredients_2.each do |item|
|
|
48
|
+
item.each do |each_item|
|
|
49
|
+
ingredient_items << each_item.text
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
asian_recipe.list_of_ingredients = "\n***Ingredients***\n* #{ingredient_items[0...-1].join(" \n* ")}\n"
|
|
54
|
+
|
|
55
|
+
asian_recipe
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.scrape_indian
|
|
59
|
+
doc_indian_name = Nokogiri::HTML(open("https://www.allrecipes.com/recipes/233/world-cuisine/asian/indian/"))
|
|
60
|
+
|
|
61
|
+
indian_recipe = self.new
|
|
62
|
+
indian_recipe.cuisine = "Indian"
|
|
63
|
+
indian_recipe.name = doc_indian_name.search("h3")[12].text
|
|
64
|
+
|
|
65
|
+
doc_indian_ingredients = Nokogiri::HTML(open("https://www.allrecipes.com/recipe/228293/curry-stand-chicken-tikka-masala-sauce/?internalSource=streams&referringId=233&referringContentType=Recipe%20Hub&clickId=st_recipes_mades"))
|
|
66
|
+
|
|
67
|
+
indian_recipe.ready_time = doc_indian_ingredients.search("span.ready-in-time").text
|
|
68
|
+
indian_directions = doc_indian_ingredients.search("span.recipe-directions__list--item").text.split
|
|
69
|
+
indian_recipe.directions = indian_directions.join(" ")
|
|
70
|
+
|
|
71
|
+
ingredient_items = []
|
|
72
|
+
|
|
73
|
+
# First Colomn of Ingredients
|
|
74
|
+
indian_ingredients_1 = []
|
|
75
|
+
indian_ingredients_1 << doc_indian_ingredients.search("#lst_ingredients_1 span.recipe-ingred_txt")
|
|
76
|
+
indian_ingredients_1.each do |item|
|
|
77
|
+
item.each do |each_item|
|
|
78
|
+
ingredient_items << each_item.text
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Second Colomn of Ingredients
|
|
83
|
+
indian_ingredients_2 = []
|
|
84
|
+
indian_ingredients_2 << doc_indian_ingredients.search("#lst_ingredients_2 span.recipe-ingred_txt")
|
|
85
|
+
indian_ingredients_2.each do |item|
|
|
86
|
+
item.each do |each_item|
|
|
87
|
+
ingredient_items << each_item.text
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
indian_recipe.list_of_ingredients = "\n***Ingredients***\n* #{ingredient_items[0...-1].join(" \n* ")}\n"
|
|
92
|
+
|
|
93
|
+
indian_recipe
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def self.scrape_italian
|
|
97
|
+
doc_italian_name = Nokogiri::HTML(open("https://www.allrecipes.com/recipes/723/world-cuisine/european/italian/"))
|
|
98
|
+
|
|
99
|
+
italian_recipe = self.new
|
|
100
|
+
italian_recipe.cuisine = "Italian"
|
|
101
|
+
italian_recipe.name = doc_italian_name.search("h3")[12].text
|
|
102
|
+
|
|
103
|
+
doc_italian_ingredients = Nokogiri::HTML(open("https://www.allrecipes.com/recipe/23600/worlds-best-lasagna/?internalSource=streams&referringId=723&referringContentType=Recipe%20Hub&clickId=st_recipes_mades"))
|
|
104
|
+
|
|
105
|
+
italian_recipe.ready_time = doc_italian_ingredients.search("span.ready-in-time").text
|
|
106
|
+
italian_directions = doc_italian_ingredients.search("span.recipe-directions__list--item").text.split
|
|
107
|
+
italian_recipe.directions = italian_directions.join(" ")
|
|
108
|
+
|
|
109
|
+
ingredient_items = []
|
|
110
|
+
|
|
111
|
+
# First Colomn of Ingredients
|
|
112
|
+
italian_ingredients_1 = []
|
|
113
|
+
italian_ingredients_1 << doc_italian_ingredients.search("#lst_ingredients_1 span.recipe-ingred_txt")
|
|
114
|
+
italian_ingredients_1.each do |item|
|
|
115
|
+
item.each do |each_item|
|
|
116
|
+
ingredient_items << each_item.text
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Second Colomn of Ingredients
|
|
121
|
+
italian_ingredients_2 = []
|
|
122
|
+
italian_ingredients_2 << doc_italian_ingredients.search("#lst_ingredients_2 span.recipe-ingred_txt")
|
|
123
|
+
italian_ingredients_2.each do |item|
|
|
124
|
+
item.each do |each_item|
|
|
125
|
+
ingredient_items << each_item.text
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
italian_recipe.list_of_ingredients = "\n***Ingredients***\n* #{ingredient_items[0...-1].join(" \n* ")}\n"
|
|
130
|
+
|
|
131
|
+
italian_recipe
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def self.scrape_mexican
|
|
135
|
+
doc_mexican_name = Nokogiri::HTML(open("https://www.allrecipes.com/recipes/728/world-cuisine/latin-american/mexican/"))
|
|
136
|
+
|
|
137
|
+
mexican_recipe = self.new
|
|
138
|
+
mexican_recipe.cuisine = "Mexican"
|
|
139
|
+
mexican_recipe.name = doc_mexican_name.search("h3")[12].text
|
|
140
|
+
|
|
141
|
+
doc_mexican_ingredients = Nokogiri::HTML(open("https://www.allrecipes.com/recipe/217911/salsa-chicken-meatloaf/?internalSource=streams&referringId=728&referringContentType=Recipe%20Hub&clickId=st_recipes_mades"))
|
|
142
|
+
|
|
143
|
+
mexican_recipe.ready_time = doc_mexican_ingredients.search("span.ready-in-time").text
|
|
144
|
+
mexican_directions = doc_mexican_ingredients.search("span.recipe-directions__list--item").text.split
|
|
145
|
+
mexican_recipe.directions = mexican_directions.join(" ")
|
|
146
|
+
|
|
147
|
+
ingredient_items = []
|
|
148
|
+
|
|
149
|
+
# First Colomn of Ingredients
|
|
150
|
+
mexican_ingredients_1 = []
|
|
151
|
+
mexican_ingredients_1 << doc_mexican_ingredients.search("#lst_ingredients_1 span.recipe-ingred_txt")
|
|
152
|
+
mexican_ingredients_1.each do |item|
|
|
153
|
+
item.each do |each_item|
|
|
154
|
+
ingredient_items << each_item.text
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Second Colomn of Ingredients
|
|
159
|
+
mexican_ingredients_2 = []
|
|
160
|
+
mexican_ingredients_2 << doc_mexican_ingredients.search("#lst_ingredients_2 span.recipe-ingred_txt")
|
|
161
|
+
mexican_ingredients_2.each do |item|
|
|
162
|
+
item.each do |each_item|
|
|
163
|
+
ingredient_items << each_item.text
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
mexican_recipe.list_of_ingredients = "\n***Ingredients***\n* #{ingredient_items[0...-1].join(" \n* ")}\n"
|
|
168
|
+
|
|
169
|
+
mexican_recipe
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def self.scrape_southern
|
|
173
|
+
doc_southern_name = Nokogiri::HTML(open("https://www.allrecipes.com/recipes/15876/us-recipes/southern/"))
|
|
174
|
+
|
|
175
|
+
southern_recipe = self.new
|
|
176
|
+
southern_recipe.cuisine = "Southern"
|
|
177
|
+
southern_recipe.name = doc_southern_name.search("h3")[12].text
|
|
178
|
+
|
|
179
|
+
doc_southern_ingredients = Nokogiri::HTML(open("https://www.allrecipes.com/recipe/73634/colleens-slow-cooker-jambalaya/?internalSource=streams&referringId=15876&referringContentType=Recipe%20Hub&clickId=st_recipes_mades"))
|
|
180
|
+
|
|
181
|
+
southern_recipe.ready_time = doc_southern_ingredients.search("span.ready-in-time").text
|
|
182
|
+
southern_directions = doc_southern_ingredients.search("span.recipe-directions__list--item").text.split
|
|
183
|
+
southern_recipe.directions = southern_directions.join(" ")
|
|
184
|
+
|
|
185
|
+
ingredient_items = []
|
|
186
|
+
|
|
187
|
+
# First Colomn of Ingredients
|
|
188
|
+
southern_ingredients_1 = []
|
|
189
|
+
southern_ingredients_1 << doc_southern_ingredients.search("#lst_ingredients_1 span.recipe-ingred_txt")
|
|
190
|
+
southern_ingredients_1.each do |item|
|
|
191
|
+
item.each do |each_item|
|
|
192
|
+
ingredient_items << each_item.text
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Second Colomn of Ingredients
|
|
197
|
+
southern_ingredients_2 = []
|
|
198
|
+
southern_ingredients_2 << doc_southern_ingredients.search("#lst_ingredients_2 span.recipe-ingred_txt")
|
|
199
|
+
southern_ingredients_2.each do |item|
|
|
200
|
+
item.each do |each_item|
|
|
201
|
+
ingredient_items << each_item.text
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
southern_recipe.list_of_ingredients = "\n***Ingredients***\n* #{ingredient_items[0...-1].join(" \n* ")}\n"
|
|
206
|
+
|
|
207
|
+
southern_recipe
|
|
208
|
+
end
|
|
209
|
+
end
|
data/lib/riperecipes.rb
ADDED
data/riperecipes.gemspec
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "riperecipes/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "riperecipes"
|
|
8
|
+
spec.version = Riperecipes::VERSION
|
|
9
|
+
spec.authors = ["arpethel"]
|
|
10
|
+
spec.email = ["arpethel@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Collects recipes for certain cuisines.}
|
|
13
|
+
spec.description = "RipeRecipes is a simple CLI gem to get recipe ingredients from AllRecipes.com for your favorite meals."
|
|
14
|
+
spec.homepage = "https://github.com/arpethel/riperecipes/tree/master/riperecipes"
|
|
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"] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
|
+
|
|
22
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
|
23
|
+
# spec.metadata["source_code_uri"] = "https://github.com/arpethel/riperecipes.git"
|
|
24
|
+
# spec.metadata["changelog_uri"] = "https://github.com/arpethel/riperecipes/blob/master/riperecipes/CHANGELOG.md"
|
|
25
|
+
# else
|
|
26
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
|
27
|
+
# "public gem pushes."
|
|
28
|
+
# end
|
|
29
|
+
|
|
30
|
+
# # Specify which files should be added to the gem when it is released.
|
|
31
|
+
# # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
34
|
+
end
|
|
35
|
+
spec.bindir = "exe"
|
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
37
|
+
spec.require_paths = ["lib"]
|
|
38
|
+
|
|
39
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
42
|
+
spec.add_development_dependency "nokogiri"
|
|
43
|
+
|
|
44
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: riperecipes
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- arpethel
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-05-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
|
+
- !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
|
+
description: RipeRecipes is a simple CLI gem to get recipe ingredients from AllRecipes.com
|
|
70
|
+
for your favorite meals.
|
|
71
|
+
email:
|
|
72
|
+
- arpethel@gmail.com
|
|
73
|
+
executables: []
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- ".gitignore"
|
|
78
|
+
- ".rspec"
|
|
79
|
+
- ".travis.yml"
|
|
80
|
+
- CHANGELOG.md
|
|
81
|
+
- Gemfile
|
|
82
|
+
- Gemfile.lock
|
|
83
|
+
- LICENSE.txt
|
|
84
|
+
- README.md
|
|
85
|
+
- Rakefile
|
|
86
|
+
- bin/console
|
|
87
|
+
- bin/riperecipe
|
|
88
|
+
- bin/setup
|
|
89
|
+
- lib/riperecipes.rb
|
|
90
|
+
- lib/riperecipes/cli.rb
|
|
91
|
+
- lib/riperecipes/recipe.rb
|
|
92
|
+
- lib/riperecipes/version.rb
|
|
93
|
+
- riperecipes.gemspec
|
|
94
|
+
homepage: https://github.com/arpethel/riperecipes/tree/master/riperecipes
|
|
95
|
+
licenses:
|
|
96
|
+
- MIT
|
|
97
|
+
metadata: {}
|
|
98
|
+
post_install_message:
|
|
99
|
+
rdoc_options: []
|
|
100
|
+
require_paths:
|
|
101
|
+
- lib
|
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
|
+
requirements:
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: '0'
|
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - ">="
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '0'
|
|
112
|
+
requirements: []
|
|
113
|
+
rubyforge_project:
|
|
114
|
+
rubygems_version: 2.7.6
|
|
115
|
+
signing_key:
|
|
116
|
+
specification_version: 4
|
|
117
|
+
summary: Collects recipes for certain cuisines.
|
|
118
|
+
test_files: []
|