just-the-recipe 0.8.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63f604274dbc6fe5a52f6fd282504004ec38789d372eab2d9e43cb4ce241488e
4
- data.tar.gz: 884670ff3ea3ada5961883b9e9244842c4babf8a85f77fee72acc46f98e3570e
3
+ metadata.gz: bb79f03d347799387c574b7f113c84487a15b5b60ac4ec608a8b12266d97cae1
4
+ data.tar.gz: 860281d233fc35e9d24fc93e3025e22654e17906a8e3d7446cd9464d126488dc
5
5
  SHA512:
6
- metadata.gz: 85ed08a56d918a4517dfad4eae136f934c65799ed046412abc5c768b71c44b5591e3f41502adb1ad9b4092188eb35daac76dd4ac974233e51f2bbeb9d9eb3c2c
7
- data.tar.gz: be930def30c30da9c0104e247d3389f5a241925329f4a024e1327982aa9d4e2f73d24ade2b9fa885287706cf5f37c3c2901b9f2ce372f66343588a5fb130b046
6
+ metadata.gz: 90b3770b96f0ef788d630594738de8713fd64e1fbc1c0c434642c7f30a3a7447c6304dd1fb5adaf18c440ba6453f26b801ec65675a115ec6d1fc2f92e12b1dd4
7
+ data.tar.gz: 28549e2bf2c4978b750efe1750d059c1704ee6fe96310ab5834fd542c5b590b8c31c04650ddece24d2414642e577badf3743c2e686f346e9afe4156f28deb4f1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- just-the-recipe (0.8.0)
4
+ just-the-recipe (0.13.0)
5
5
  dotenv
6
6
  nokogiri
7
7
  open-uri
data/README.md CHANGED
@@ -1,33 +1,56 @@
1
- # Just::The::Recipe
1
+ # Just The Recipe
2
2
 
3
- ## Installation
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
- Add this line to your application's Gemfile:
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
- ```ruby gem 'just-the-recipe'
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
- And then execute:
9
+ # Installation
11
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 use bundle to install the dependencies:
12
+
13
+ $ git clone https://github.com/george-dilthey/just-the-recipe.git
12
14
  $ bundle install
13
15
 
14
- Or install it yourself as:
16
+ # Usage
17
+
18
+ ## API Access
19
+
20
+ 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:
21
+
22
+ APP_ID = {YOUR APP ID}
23
+ APP_KEY = {YOUR APP KEY}
24
+
25
+ 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.
26
+
27
+ ## Running the app
28
+
29
+ Run the app by running the bin file `just-the-recipe`.
30
+
31
+ $ bin/just-the-recipe
32
+
33
+ If you get a permission denied error, run this to give the bin file run permissions:
15
34
 
16
- $ gem install just-the-recipe
35
+ $ chmod +x bin/just-the-recipe
17
36
 
18
- ## Usage
37
+ Alternatively, you can call the `JustTheRecipe::CLI.new.call` method.
19
38
 
20
- 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 dotenv file and add these lines at the top:
39
+ # Supported Websites
21
40
 
22
- APP_ID = {{APP ID}}
23
- APP_KEY = {{APP KEY}}
41
+ 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
42
 
25
- ## Development
26
43
 
27
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+ * https://www.allrecipes.com
45
+ * https://food52.com
46
+ * https://www.seriouseats.com
47
+ * https://www.marthastewart.com
48
+ * https://www.chowhound.com
49
+ * https://getmecooking.com
50
+ * https://blog.bigoven.com
51
+ * https://www.vegrecipesofindia.com
28
52
 
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
53
 
31
- ## Contributing
54
+ # Contributing
32
55
 
33
56
  Bug reports and pull requests are welcome on GitHub at https://github.com/george-dilthey/just-the-recipe.
data/bin/just-the-recipe CHANGED
@@ -2,4 +2,4 @@
2
2
  require "bundler/setup"
3
3
  require './lib/just-the-recipe.rb'
4
4
 
5
- JustTheRecipe::CLI.new.call
5
+ JustTheRecipe::CLI.new.call
@@ -1,5 +1,3 @@
1
- require './lib/just-the-recipe.rb'
2
-
3
1
  class JustTheRecipe::CLI
4
2
 
5
3
  def call
@@ -69,13 +67,13 @@ class JustTheRecipe::CLI
69
67
  puts "Here's what's in the cookbook called #{input}:"
70
68
  puts JustTheRecipe::Cookbook.find_by_name(input).return_cookbook
71
69
  main_menu
72
- elsif input == "Create a new cookbook"
70
+ elsif input == "Create a new cookbook."
73
71
  create_cookbook
74
72
  main_menu
75
73
  elsif input == "Delete a cookbook."
76
74
  cookbooks_delete = JustTheRecipe::Cookbook.list_cookbooks << "Exit"
77
- delete = prompt.select("Which cookbook would you like to delete? WARNING: THIS CANNOT BE UNDONE!", cookbooks_create)
78
- JustTheRecipe::Cookbook.delete(delete)
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
79
77
  puts "Ok, we deleted that cookbook."
80
78
  main_menu
81
79
  elsif input == "Main Menu"
@@ -140,6 +138,4 @@ class JustTheRecipe::CLI
140
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!"
141
139
  end
142
140
 
143
-
144
-
145
141
  end
@@ -1,5 +1,3 @@
1
- require './lib/just-the-recipe.rb'
2
-
3
1
  class JustTheRecipe::Cookbook
4
2
 
5
3
  attr_accessor :name
@@ -41,22 +39,15 @@ class JustTheRecipe::Cookbook
41
39
  end
42
40
 
43
41
  def self.list_cookbooks
44
- cookbooks = []
45
- @@all.each{|i| cookbooks << i.name}
46
- cookbooks
42
+ @@all.map{|i| i.name}
47
43
  end
48
44
 
49
45
  def return_cookbook
50
- File.read("#{self.name}.txt")
46
+ File.read("#{@name}.txt")
51
47
  end
52
48
 
53
- def self.delete(name)
54
- if find_by_name(name)
55
- @@all.delete(find_by_name(name))
56
- File.delete("#{name}.txt")
57
- end
49
+ def delete_cookbook
50
+ @@all.delete(self)
51
+ File.delete("#{@name}.txt")
58
52
  end
59
53
  end
60
-
61
- # gd_cookbook = JustTheRecipe::Cookbook.new("George's Cookbook")
62
- # binding.pry
@@ -1,5 +1,3 @@
1
- require './lib/just-the-recipe.rb'
2
-
3
1
  class JustTheRecipe::Recipe
4
2
 
5
3
  attr_accessor :title, :description, :ingredients, :steps, :url, :cookbook
@@ -47,25 +45,7 @@ class JustTheRecipe::Recipe
47
45
  self.cookbook.write_recipe_to_cookbook(self)
48
46
  end
49
47
 
50
- def self.display_cookbook
51
- if @@all.length > 0
52
- @@all.each {|r|
53
- r.display_recipe
54
- }
55
- else
56
- puts "You don't have anything in your cookbook!"
57
- end
58
- end
59
-
60
- # def save_to_cookbook(cookbook_name)
61
- # File.write("#{cookbook_name}.txt", self.return_recipe, mode: "a")
62
- # end
63
-
64
48
  end
65
49
 
66
- # new_recipe = JustTheRecipe::Recipe.new('cookies', 'delicious cookies', ['chocolate chips', 'flour'],['make cookie batter', 'cook cookies'], "www.google.com")
67
- # new_recipe.add_to_cookbook("George's Cookbook")
68
- # binding.pry
69
-
70
50
 
71
51
 
@@ -1,5 +1,3 @@
1
- require './lib/just-the-recipe.rb'
2
-
3
1
  class JustTheRecipe::Scraper
4
2
 
5
3
  attr_accessor :url
@@ -14,6 +12,7 @@ class JustTheRecipe::Scraper
14
12
  schema.key?("name") ? title = schema["name"] : nil
15
13
  schema.key?("description") ? description = schema["description"] : nil
16
14
  schema.key?("recipeIngredient") ? ingredients = schema["recipeIngredient"] : ingredients = []
15
+
17
16
  if schema.key?("recipeInstructions")
18
17
  if schema["recipeInstructions"][0].class == Hash && schema["recipeInstructions"][0].key?("itemListElement")
19
18
  steps = schema["recipeInstructions"].map {|section| section["itemListElement"].map {|instruction| instruction["text"].gsub("\n","")}}.flatten
@@ -27,6 +26,7 @@ class JustTheRecipe::Scraper
27
26
  else
28
27
  steps = []
29
28
  end
29
+
30
30
  create_new_recipe(title,description,ingredients,steps, @url)
31
31
  end
32
32
 
@@ -67,20 +67,8 @@ class JustTheRecipe::Scraper
67
67
  rescue
68
68
  false
69
69
  end
70
-
71
70
  end
72
71
 
73
72
  end
74
73
 
75
- # veg = JustTheRecipe::Scraper.new('https://www.vegrecipesofindia.com/eggless-chocolate-chip-muffins-recipe/').get_recipe_by_schema.display_recipe
76
- # all_recipe = JustTheRecipe::Scraper.new('https://www.allrecipes.com/recipe/10813/best-chocolate-chip-cookies/').get_recipe_by_schema.display_recipe
77
- # serious = JustTheRecipe::Scraper.new('https://www.seriouseats.com/recipes/2021/03/orecchiette-con-le-cime-di-rapa.html').get_recipe_by_schema.display_recipe
78
- # get = JustTheRecipe::Scraper.new('https://getmecooking.com/recipes/gambas-al-ajillo-con-setas/').get_recipe_by_schema.display_recipe
79
- # big = JustTheRecipe::Scraper.new('https://blog.bigoven.com/category/bigoven-tips/page/15/').get_recipe_by_schema.display_recipe
80
- # martha = JustTheRecipe::Scraper.new('https://www.marthastewart.com/1511143/potato-galettes').get_recipe_by_schema.display_recipe
81
- # food52 = JustTheRecipe::Scraper.new('https://food52.com/recipes/2250-potatoe-chipotle-tacos').get_recipe_by_schema.display_recipe
82
- # chowhound = JustTheRecipe::Scraper.new('https://www.chowhound.com/recipes/tomato-pie-31670').get_recipe_by_schema.display_recipe
83
- # food52part2 = JustTheRecipe::Scraper.new('https://food52.com/recipes/10168-sugar-pie').get_recipe_by_schema.display_recipe
84
- # all_recipe.display_recipe
85
-
86
74
 
@@ -1,17 +1,17 @@
1
- require './lib/just-the-recipe.rb'
2
-
3
1
  class JustTheRecipe::Searcher
4
2
 
5
3
  def initialize(search_term)
6
4
  @search_term = search_term
7
5
  end
8
6
 
7
+
8
+
9
9
  def api_get
10
10
  begin
11
11
  base = 'https://api.edamam.com/search'
12
12
  q = @search_term
13
- app_id = ENV["APP_ID"]
14
- app_key = ENV["APP_KEY"]
13
+ app_id = JustTheRecipe.app_id
14
+ app_key = JustTheRecipe.app_key
15
15
 
16
16
  url = "#{base}?q=#{q}&app_id=#{app_id}&app_key=#{app_key}"
17
17
  uri = URI.parse(url)
@@ -31,7 +31,7 @@ class JustTheRecipe::Searcher
31
31
  end
32
32
  scrape_recipe(good_url)
33
33
  rescue
34
- puts "Sorry we couldn't find a valid recipe with that search term."
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."
35
35
  end
36
36
 
37
37
  end
@@ -40,7 +40,4 @@ class JustTheRecipe::Searcher
40
40
  JustTheRecipe::Scraper.new(url).get_recipe_by_schema
41
41
  end
42
42
 
43
- end
44
-
45
-
46
- # JustTheRecipe::Searcher.new('pie').api_get
43
+ end
@@ -1,3 +1,19 @@
1
1
  module JustTheRecipe
2
- VERSION = "0.8.0"
2
+ VERSION = "0.13.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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: just-the-recipe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Dilthey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-23 00:00:00.000000000 Z
11
+ date: 2021-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open-uri
@@ -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
@@ -1,11 +0,0 @@
1
-
2
- class Authenticate
3
-
4
- def initialize(app_id, app_key)
5
- @app_id, @app_key = app_id, app_key
6
- File.write(".env", "APP_ID = #{app_id.to_s}\nAPP_KEY = #{app_key.to_s}")
7
- end
8
-
9
- end
10
-
11
- Authenticate.new('6d8b7767', 'e1633ded1da9906633b79ec6c8525ac5')