just-the-recipe 0.7.0 → 0.12.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: c9630aec266f08d9d58d7496be1386ca8b0e298cec9beeef1fcb4b608ceeb96f
4
- data.tar.gz: 739fe2c46d8d15d5c8d15d84106f2dad5fecac321e7c7d48f8b8ceb982e82801
3
+ metadata.gz: 99ab498a5f34d65079847365b89e0e38293b0b2bac06d4dcdc0719c13e29df0b
4
+ data.tar.gz: 1eed4b063efaa5e3fd02bbf0358a9014eb8383f808ef020f0181c80ff6856d00
5
5
  SHA512:
6
- metadata.gz: 60779d8f45c4e053db12688db40a014029ac3824bd45a90203e5c1d4d15c6645c063735e39225f03fec1cec7fe059a584d228fc6a0a1a21e559df11f7fc50f41
7
- data.tar.gz: e024954f91b3279ee6643344d5613c558c2bb1af3f0bb69519335f626efc076e562a4318a5fa2a0ae519518db00b462113003c3701a8f85c406e6d09cd474937
6
+ metadata.gz: c0ff391778cbf299a19561579da616dc3c0817a32c37ad8a39b59324f1d45bf00157aa14b3d3ab20bd597285c7c9b90b587e1fb81365f5bbbe8ea790f90385d1
7
+ data.tar.gz: 5e5a0919f35194d45029c56be070cf2aa2dd556df6fd017073392805d7357e29847b944015eb24d8734958be5bf6430e4d83f4bb8cb8627d58de4311f69e3eef
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- just-the-recipe (0.7.0)
4
+ just-the-recipe (0.12.0)
5
5
  dotenv
6
6
  nokogiri
7
7
  open-uri
data/README.md CHANGED
@@ -1,33 +1,51 @@
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
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
- Or install it yourself as:
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
- $ gem install just-the-recipe
28
+ Run the app by running the bin file `just-the-recipe`.
29
+
30
+ $ ruby bin/just-the-recipe
17
31
 
18
- ## Usage
32
+ Alternatively, you can call the `JustTheRecipe::CLI.new.call` method.
19
33
 
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:
34
+ # Supported Websites
21
35
 
22
- APP_ID = {{APP ID}}
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
- 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.
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
- ## Contributing
49
+ # Contributing
32
50
 
33
51
  Bug reports and pull requests are welcome on GitHub at https://github.com/george-dilthey/just-the-recipe.
@@ -6,12 +6,11 @@ require 'JSON'
6
6
  require 'net/http'
7
7
  require 'tty-prompt'
8
8
 
9
- require './lib/just-the-recipe/version.rb'
10
- require './lib/just-the-recipe/cli.rb'
11
- require './lib/just-the-recipe/cookbook.rb'
12
- require './lib/just-the-recipe/recipe.rb'
13
- require './lib/just-the-recipe/scraper.rb'
14
- require './lib/just-the-recipe/searcher.rb'
15
- require 'bundler/setup'
9
+ require_relative 'just-the-recipe/version'
10
+ require_relative 'just-the-recipe/cli'
11
+ require_relative 'just-the-recipe/cookbook'
12
+ require_relative 'just-the-recipe/recipe'
13
+ require_relative 'just-the-recipe/scraper'
14
+ require_relative 'just-the-recipe/searcher'
16
15
 
17
16
 
@@ -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,6 +1,3 @@
1
- require 'pry'
2
- require './lib/just-the-recipe.rb'
3
-
4
1
  class JustTheRecipe::Cookbook
5
2
 
6
3
  attr_accessor :name
@@ -42,20 +39,16 @@ class JustTheRecipe::Cookbook
42
39
  end
43
40
 
44
41
  def self.list_cookbooks
45
- cookbooks = []
46
- @@all.each{|i| cookbooks << i.name}
47
- cookbooks
42
+ @@all.map{|i| i.name}
48
43
  end
49
44
 
50
45
  def return_cookbook
51
- File.read("#{self.name}.txt")
46
+ File.read("#{@name}.txt")
52
47
  end
53
48
 
54
- def self.delete(name)
55
- if find_by_name(name)
56
- @@all.delete(find_by_name(name))
57
- File.delete("#{name}.txt")
58
- end
49
+ def delete_cookbook
50
+ @@all.delete(self)
51
+ File.delete("#{@name}.txt")
59
52
  end
60
53
  end
61
54
 
@@ -1,6 +1,3 @@
1
- require 'pry'
2
- require './lib/just-the-recipe.rb'
3
-
4
1
  class JustTheRecipe::Recipe
5
2
 
6
3
  attr_accessor :title, :description, :ingredients, :steps, :url, :cookbook
@@ -48,25 +45,7 @@ class JustTheRecipe::Recipe
48
45
  self.cookbook.write_recipe_to_cookbook(self)
49
46
  end
50
47
 
51
- def self.display_cookbook
52
- if @@all.length > 0
53
- @@all.each {|r|
54
- r.display_recipe
55
- }
56
- else
57
- puts "You don't have anything in your cookbook!"
58
- end
59
- end
60
-
61
- # def save_to_cookbook(cookbook_name)
62
- # File.write("#{cookbook_name}.txt", self.return_recipe, mode: "a")
63
- # end
64
-
65
48
  end
66
49
 
67
- # new_recipe = JustTheRecipe::Recipe.new('cookies', 'delicious cookies', ['chocolate chips', 'flour'],['make cookie batter', 'cook cookies'], "www.google.com")
68
- # new_recipe.add_to_cookbook("George's Cookbook")
69
- # binding.pry
70
-
71
50
 
72
51
 
@@ -1,7 +1,3 @@
1
- require 'pry'
2
-
3
- require './lib/just-the-recipe.rb'
4
-
5
1
  class JustTheRecipe::Scraper
6
2
 
7
3
  attr_accessor :url
@@ -16,6 +12,7 @@ class JustTheRecipe::Scraper
16
12
  schema.key?("name") ? title = schema["name"] : nil
17
13
  schema.key?("description") ? description = schema["description"] : nil
18
14
  schema.key?("recipeIngredient") ? ingredients = schema["recipeIngredient"] : ingredients = []
15
+
19
16
  if schema.key?("recipeInstructions")
20
17
  if schema["recipeInstructions"][0].class == Hash && schema["recipeInstructions"][0].key?("itemListElement")
21
18
  steps = schema["recipeInstructions"].map {|section| section["itemListElement"].map {|instruction| instruction["text"].gsub("\n","")}}.flatten
@@ -29,6 +26,7 @@ class JustTheRecipe::Scraper
29
26
  else
30
27
  steps = []
31
28
  end
29
+
32
30
  create_new_recipe(title,description,ingredients,steps, @url)
33
31
  end
34
32
 
@@ -69,20 +67,8 @@ class JustTheRecipe::Scraper
69
67
  rescue
70
68
  false
71
69
  end
72
-
73
70
  end
74
71
 
75
72
  end
76
73
 
77
- # veg = JustTheRecipe::Scraper.new('https://www.vegrecipesofindia.com/eggless-chocolate-chip-muffins-recipe/').get_recipe_by_schema.display_recipe
78
- # all_recipe = JustTheRecipe::Scraper.new('https://www.allrecipes.com/recipe/10813/best-chocolate-chip-cookies/').get_recipe_by_schema.display_recipe
79
- # serious = JustTheRecipe::Scraper.new('https://www.seriouseats.com/recipes/2021/03/orecchiette-con-le-cime-di-rapa.html').get_recipe_by_schema.display_recipe
80
- # get = JustTheRecipe::Scraper.new('https://getmecooking.com/recipes/gambas-al-ajillo-con-setas/').get_recipe_by_schema.display_recipe
81
- # big = JustTheRecipe::Scraper.new('https://blog.bigoven.com/category/bigoven-tips/page/15/').get_recipe_by_schema.display_recipe
82
- # martha = JustTheRecipe::Scraper.new('https://www.marthastewart.com/1511143/potato-galettes').get_recipe_by_schema.display_recipe
83
- # food52 = JustTheRecipe::Scraper.new('https://food52.com/recipes/2250-potatoe-chipotle-tacos').get_recipe_by_schema.display_recipe
84
- # chowhound = JustTheRecipe::Scraper.new('https://www.chowhound.com/recipes/tomato-pie-31670').get_recipe_by_schema.display_recipe
85
- # food52part2 = JustTheRecipe::Scraper.new('https://food52.com/recipes/10168-sugar-pie').get_recipe_by_schema.display_recipe
86
- # all_recipe.display_recipe
87
-
88
74
 
@@ -1,19 +1,17 @@
1
- require 'pry'
2
-
3
- require './lib/just-the-recipe.rb'
4
-
5
1
  class JustTheRecipe::Searcher
6
2
 
7
3
  def initialize(search_term)
8
4
  @search_term = search_term
9
5
  end
10
6
 
7
+
8
+
11
9
  def api_get
12
10
  begin
13
11
  base = 'https://api.edamam.com/search'
14
12
  q = @search_term
15
- app_id = ENV["APP_ID"]
16
- app_key = ENV["APP_KEY"]
13
+ app_id = JustTheRecipe.app_id
14
+ app_key = JustTheRecipe.app_key
17
15
 
18
16
  url = "#{base}?q=#{q}&app_id=#{app_id}&app_key=#{app_key}"
19
17
  uri = URI.parse(url)
@@ -33,7 +31,7 @@ class JustTheRecipe::Searcher
33
31
  end
34
32
  scrape_recipe(good_url)
35
33
  rescue
36
- 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."
37
35
  end
38
36
 
39
37
  end
@@ -42,7 +40,4 @@ class JustTheRecipe::Searcher
42
40
  JustTheRecipe::Scraper.new(url).get_recipe_by_schema
43
41
  end
44
42
 
45
- end
46
-
47
-
48
- # JustTheRecipe::Searcher.new('pie').api_get
43
+ end
@@ -1,3 +1,19 @@
1
1
  module JustTheRecipe
2
- VERSION = "0.7.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.7.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
@@ -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')