just-the-recipe 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +34 -16
- data/lib/just-the-recipe.rb +0 -1
- data/lib/just-the-recipe/cli.rb +3 -5
- data/lib/just-the-recipe/cookbook.rb +5 -9
- data/lib/just-the-recipe/recipe.rb +0 -18
- data/lib/just-the-recipe/scraper.rb +2 -12
- data/lib/just-the-recipe/searcher.rb +6 -7
- data/lib/just-the-recipe/version.rb +17 -1
- metadata +1 -2
- data/lib/just-the-recipe/authenticate.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99ab498a5f34d65079847365b89e0e38293b0b2bac06d4dcdc0719c13e29df0b
|
4
|
+
data.tar.gz: 1eed4b063efaa5e3fd02bbf0358a9014eb8383f808ef020f0181c80ff6856d00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0ff391778cbf299a19561579da616dc3c0817a32c37ad8a39b59324f1d45bf00157aa14b3d3ab20bd597285c7c9b90b587e1fb81365f5bbbe8ea790f90385d1
|
7
|
+
data.tar.gz: 5e5a0919f35194d45029c56be070cf2aa2dd556df6fd017073392805d7357e29847b944015eb24d8734958be5bf6430e4d83f4bb8cb8627d58de4311f69e3eef
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,33 +1,51 @@
|
|
1
|
-
# Just
|
1
|
+
# Just The Recipe
|
2
2
|
|
3
|
-
|
3
|
+
This app allows you to search for recipes on the web, and add them to different cookbooks that you create. The cookbooks are saved as text files so that you can return to them when you're not using the app.
|
4
4
|
|
5
|
-
|
5
|
+
The app uses a combination of the Edamam API (to search for recipes) and a URL scraper that allows you to input recipe URLs so that you can strip out "Just the Recipe".
|
6
6
|
|
7
|
-
|
8
|
-
```
|
7
|
+
Your cookbooks are re-instantiated when you enter the app again so you can continue adding to them over time.
|
9
8
|
|
10
|
-
|
9
|
+
# Installation
|
10
|
+
|
11
|
+
Because we save your cookbooks as text files, its best to have this app live in its own repository. Clone down this git repository and then execute:
|
11
12
|
|
12
13
|
$ bundle install
|
13
14
|
|
14
|
-
|
15
|
+
# Usage
|
16
|
+
|
17
|
+
## API Access
|
18
|
+
|
19
|
+
To use this gem, you'll need to obtain a free APP ID and APP Key from https://www.edamam.com. Once you have these, create a `.env` file and add these lines at the top:
|
20
|
+
|
21
|
+
APP_ID = {YOUR APP ID}
|
22
|
+
APP_KEY = {YOUR APP KEY}
|
23
|
+
|
24
|
+
Alternatively, you can call `JustTheRecipe.authorize({YOUR APP ID}, {YOUR APP KEY})` before making any other calls, but this will need to be done every time you re-enter the app.
|
25
|
+
|
26
|
+
## Running the app
|
15
27
|
|
16
|
-
|
28
|
+
Run the app by running the bin file `just-the-recipe`.
|
29
|
+
|
30
|
+
$ ruby bin/just-the-recipe
|
17
31
|
|
18
|
-
|
32
|
+
Alternatively, you can call the `JustTheRecipe::CLI.new.call` method.
|
19
33
|
|
20
|
-
|
34
|
+
# Supported Websites
|
21
35
|
|
22
|
-
|
23
|
-
APP_KEY = {{APP KEY}}
|
36
|
+
Both the search function and the scrape function rely on scraping a website's [recipe schema](https://schema.org/Recipe). Any website that has properly implemented this schema should be scrapable, but these sites have been tested specifically.
|
24
37
|
|
25
|
-
## Development
|
26
38
|
|
27
|
-
|
39
|
+
* https://www.allrecipes.com
|
40
|
+
* https://food52.com
|
41
|
+
* https://www.seriouseats.com
|
42
|
+
* https://www.marthastewart.com
|
43
|
+
* https://www.chowhound.com
|
44
|
+
* https://getmecooking.com
|
45
|
+
* https://blog.bigoven.com
|
46
|
+
* https://www.vegrecipesofindia.com
|
28
47
|
|
29
|
-
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
48
|
|
31
|
-
|
49
|
+
# Contributing
|
32
50
|
|
33
51
|
Bug reports and pull requests are welcome on GitHub at https://github.com/george-dilthey/just-the-recipe.
|
data/lib/just-the-recipe.rb
CHANGED
data/lib/just-the-recipe/cli.rb
CHANGED
@@ -67,13 +67,13 @@ class JustTheRecipe::CLI
|
|
67
67
|
puts "Here's what's in the cookbook called #{input}:"
|
68
68
|
puts JustTheRecipe::Cookbook.find_by_name(input).return_cookbook
|
69
69
|
main_menu
|
70
|
-
elsif input == "Create a new cookbook"
|
70
|
+
elsif input == "Create a new cookbook."
|
71
71
|
create_cookbook
|
72
72
|
main_menu
|
73
73
|
elsif input == "Delete a cookbook."
|
74
74
|
cookbooks_delete = JustTheRecipe::Cookbook.list_cookbooks << "Exit"
|
75
|
-
|
76
|
-
JustTheRecipe::Cookbook.
|
75
|
+
name = prompt.select("Which cookbook would you like to delete? WARNING: THIS CANNOT BE UNDONE!", cookbooks_delete)
|
76
|
+
JustTheRecipe::Cookbook.find_by_name(name).delete_cookbook
|
77
77
|
puts "Ok, we deleted that cookbook."
|
78
78
|
main_menu
|
79
79
|
elsif input == "Main Menu"
|
@@ -138,6 +138,4 @@ class JustTheRecipe::CLI
|
|
138
138
|
puts "\n\nThanks for stopping by! If you created any cookbooks, they'll be saved as text files so that you can continue using them in the future. See you soon!"
|
139
139
|
end
|
140
140
|
|
141
|
-
|
142
|
-
|
143
141
|
end
|
@@ -39,20 +39,16 @@ class JustTheRecipe::Cookbook
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.list_cookbooks
|
42
|
-
|
43
|
-
@@all.each{|i| cookbooks << i.name}
|
44
|
-
cookbooks
|
42
|
+
@@all.map{|i| i.name}
|
45
43
|
end
|
46
44
|
|
47
45
|
def return_cookbook
|
48
|
-
File.read("#{
|
46
|
+
File.read("#{@name}.txt")
|
49
47
|
end
|
50
48
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
File.delete("#{name}.txt")
|
55
|
-
end
|
49
|
+
def delete_cookbook
|
50
|
+
@@all.delete(self)
|
51
|
+
File.delete("#{@name}.txt")
|
56
52
|
end
|
57
53
|
end
|
58
54
|
|
@@ -45,25 +45,7 @@ class JustTheRecipe::Recipe
|
|
45
45
|
self.cookbook.write_recipe_to_cookbook(self)
|
46
46
|
end
|
47
47
|
|
48
|
-
def self.display_cookbook
|
49
|
-
if @@all.length > 0
|
50
|
-
@@all.each {|r|
|
51
|
-
r.display_recipe
|
52
|
-
}
|
53
|
-
else
|
54
|
-
puts "You don't have anything in your cookbook!"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# def save_to_cookbook(cookbook_name)
|
59
|
-
# File.write("#{cookbook_name}.txt", self.return_recipe, mode: "a")
|
60
|
-
# end
|
61
|
-
|
62
48
|
end
|
63
49
|
|
64
|
-
# new_recipe = JustTheRecipe::Recipe.new('cookies', 'delicious cookies', ['chocolate chips', 'flour'],['make cookie batter', 'cook cookies'], "www.google.com")
|
65
|
-
# new_recipe.add_to_cookbook("George's Cookbook")
|
66
|
-
# binding.pry
|
67
|
-
|
68
50
|
|
69
51
|
|
@@ -12,6 +12,7 @@ class JustTheRecipe::Scraper
|
|
12
12
|
schema.key?("name") ? title = schema["name"] : nil
|
13
13
|
schema.key?("description") ? description = schema["description"] : nil
|
14
14
|
schema.key?("recipeIngredient") ? ingredients = schema["recipeIngredient"] : ingredients = []
|
15
|
+
|
15
16
|
if schema.key?("recipeInstructions")
|
16
17
|
if schema["recipeInstructions"][0].class == Hash && schema["recipeInstructions"][0].key?("itemListElement")
|
17
18
|
steps = schema["recipeInstructions"].map {|section| section["itemListElement"].map {|instruction| instruction["text"].gsub("\n","")}}.flatten
|
@@ -25,6 +26,7 @@ class JustTheRecipe::Scraper
|
|
25
26
|
else
|
26
27
|
steps = []
|
27
28
|
end
|
29
|
+
|
28
30
|
create_new_recipe(title,description,ingredients,steps, @url)
|
29
31
|
end
|
30
32
|
|
@@ -65,20 +67,8 @@ class JustTheRecipe::Scraper
|
|
65
67
|
rescue
|
66
68
|
false
|
67
69
|
end
|
68
|
-
|
69
70
|
end
|
70
71
|
|
71
72
|
end
|
72
73
|
|
73
|
-
# veg = JustTheRecipe::Scraper.new('https://www.vegrecipesofindia.com/eggless-chocolate-chip-muffins-recipe/').get_recipe_by_schema.display_recipe
|
74
|
-
# all_recipe = JustTheRecipe::Scraper.new('https://www.allrecipes.com/recipe/10813/best-chocolate-chip-cookies/').get_recipe_by_schema.display_recipe
|
75
|
-
# serious = JustTheRecipe::Scraper.new('https://www.seriouseats.com/recipes/2021/03/orecchiette-con-le-cime-di-rapa.html').get_recipe_by_schema.display_recipe
|
76
|
-
# get = JustTheRecipe::Scraper.new('https://getmecooking.com/recipes/gambas-al-ajillo-con-setas/').get_recipe_by_schema.display_recipe
|
77
|
-
# big = JustTheRecipe::Scraper.new('https://blog.bigoven.com/category/bigoven-tips/page/15/').get_recipe_by_schema.display_recipe
|
78
|
-
# martha = JustTheRecipe::Scraper.new('https://www.marthastewart.com/1511143/potato-galettes').get_recipe_by_schema.display_recipe
|
79
|
-
# food52 = JustTheRecipe::Scraper.new('https://food52.com/recipes/2250-potatoe-chipotle-tacos').get_recipe_by_schema.display_recipe
|
80
|
-
# chowhound = JustTheRecipe::Scraper.new('https://www.chowhound.com/recipes/tomato-pie-31670').get_recipe_by_schema.display_recipe
|
81
|
-
# food52part2 = JustTheRecipe::Scraper.new('https://food52.com/recipes/10168-sugar-pie').get_recipe_by_schema.display_recipe
|
82
|
-
# all_recipe.display_recipe
|
83
|
-
|
84
74
|
|
@@ -4,12 +4,14 @@ class JustTheRecipe::Searcher
|
|
4
4
|
@search_term = search_term
|
5
5
|
end
|
6
6
|
|
7
|
+
|
8
|
+
|
7
9
|
def api_get
|
8
10
|
begin
|
9
11
|
base = 'https://api.edamam.com/search'
|
10
12
|
q = @search_term
|
11
|
-
app_id =
|
12
|
-
app_key =
|
13
|
+
app_id = JustTheRecipe.app_id
|
14
|
+
app_key = JustTheRecipe.app_key
|
13
15
|
|
14
16
|
url = "#{base}?q=#{q}&app_id=#{app_id}&app_key=#{app_key}"
|
15
17
|
uri = URI.parse(url)
|
@@ -29,7 +31,7 @@ class JustTheRecipe::Searcher
|
|
29
31
|
end
|
30
32
|
scrape_recipe(good_url)
|
31
33
|
rescue
|
32
|
-
puts "
|
34
|
+
puts "\nSorry we couldn't find a valid recipe with that search term. Make sure you've added in your API credentials, or try a different search term."
|
33
35
|
end
|
34
36
|
|
35
37
|
end
|
@@ -38,7 +40,4 @@ class JustTheRecipe::Searcher
|
|
38
40
|
JustTheRecipe::Scraper.new(url).get_recipe_by_schema
|
39
41
|
end
|
40
42
|
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
# JustTheRecipe::Searcher.new('pie').api_get
|
43
|
+
end
|
@@ -1,3 +1,19 @@
|
|
1
1
|
module JustTheRecipe
|
2
|
-
VERSION = "0.
|
2
|
+
VERSION = "0.12.0"
|
3
|
+
|
4
|
+
@@app_id = ENV["APP_ID"]
|
5
|
+
@@app_key = ENV["APP_KEY"]
|
6
|
+
|
7
|
+
def self.authorize(app_id, app_key)
|
8
|
+
@@app_id = app_id
|
9
|
+
@@app_key = app_key
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.app_id
|
13
|
+
@@app_id
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.app_key
|
17
|
+
@@app_key
|
18
|
+
end
|
3
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: just-the-recipe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Dilthey
|
@@ -87,7 +87,6 @@ files:
|
|
87
87
|
- bin/setup
|
88
88
|
- just-the-recipe.gemspec
|
89
89
|
- lib/just-the-recipe.rb
|
90
|
-
- lib/just-the-recipe/authenticate.rb
|
91
90
|
- lib/just-the-recipe/cli.rb
|
92
91
|
- lib/just-the-recipe/cookbook.rb
|
93
92
|
- lib/just-the-recipe/recipe.rb
|