just-the-recipe 0.1.0 → 0.6.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 +15 -1
- data/README.md +1 -2
- data/bin/console +1 -1
- data/bin/just-the-recipe +1 -1
- data/just-the-recipe.gemspec +5 -4
- data/lib/{environment.rb → just-the-recipe.rb} +1 -0
- data/lib/just-the-recipe/authenticate.rb +11 -0
- data/lib/just-the-recipe/cli.rb +105 -82
- data/lib/just-the-recipe/cookbook.rb +4 -2
- data/lib/just-the-recipe/recipe.rb +2 -2
- data/lib/just-the-recipe/scraper.rb +1 -1
- data/lib/just-the-recipe/searcher.rb +1 -2
- data/lib/just-the-recipe/version.rb +1 -1
- metadata +23 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f762feff2c616419e85ce6ddf071c889643531c3f90b3934d06b5356f9e4282
|
4
|
+
data.tar.gz: e3ecdd69fc59b935137748d66afec24371466c6bc336c166ff917c45daab569d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dcc649793cdac6c6a99e4e04243954c9869da5c809f85ccc8f2e71c0e204fd43e72a8e052db17ca51f719d9d0c6229af239c1436b23d219e74212c36eba3431
|
7
|
+
data.tar.gz: 3a87384a00dbfc2742d37323f1f1cd745a09bd53440cf0dfd34c408775cb28a8991148513d703caef5da5f67e9298ab58dc288b2824476cf724b62fd5b0f2549
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
just-the-recipe (0.
|
4
|
+
just-the-recipe (0.6.0)
|
5
5
|
dotenv
|
6
6
|
nokogiri
|
7
7
|
open-uri
|
8
|
+
tty-prompt
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
@@ -13,8 +14,21 @@ GEM
|
|
13
14
|
nokogiri (1.11.2-x86_64-darwin)
|
14
15
|
racc (~> 1.4)
|
15
16
|
open-uri (0.1.0)
|
17
|
+
pastel (0.8.0)
|
18
|
+
tty-color (~> 0.5)
|
16
19
|
racc (1.5.2)
|
17
20
|
rake (13.0.3)
|
21
|
+
tty-color (0.6.0)
|
22
|
+
tty-cursor (0.7.1)
|
23
|
+
tty-prompt (0.23.0)
|
24
|
+
pastel (~> 0.8)
|
25
|
+
tty-reader (~> 0.8)
|
26
|
+
tty-reader (0.9.0)
|
27
|
+
tty-cursor (~> 0.7)
|
28
|
+
tty-screen (~> 0.8)
|
29
|
+
wisper (~> 2.0)
|
30
|
+
tty-screen (0.8.1)
|
31
|
+
wisper (2.0.1)
|
18
32
|
|
19
33
|
PLATFORMS
|
20
34
|
x86_64-darwin-20
|
data/README.md
CHANGED
data/bin/console
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "bundler/setup"
|
5
|
-
require
|
5
|
+
require './lib/just-the-recipe.rb'
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
data/bin/just-the-recipe
CHANGED
data/just-the-recipe.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "./lib/
|
3
|
+
require "./lib/just-the-recipe.rb"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "just-the-recipe"
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
17
17
|
|
18
|
-
spec.metadata["homepage_uri"] =
|
18
|
+
spec.metadata["homepage_uri"] = "https://github.com/george-dilthey/just-the-recipe"
|
19
19
|
spec.metadata["source_code_uri"] = "https://github.com/george-dilthey/just-the-recipe"
|
20
20
|
spec.metadata["changelog_uri"] = "https://github.com/george-dilthey/just-the-recipe"
|
21
21
|
|
@@ -24,14 +24,15 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
25
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
26
26
|
end
|
27
|
-
spec.bindir = "
|
28
|
-
spec.executables = spec.files.grep(%r{\
|
27
|
+
spec.bindir = "bin"
|
28
|
+
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
31
|
# Uncomment to register a new dependency of your gem
|
32
32
|
spec.add_dependency "open-uri"
|
33
33
|
spec.add_dependency "dotenv"
|
34
34
|
spec.add_dependency "nokogiri"
|
35
|
+
spec.add_dependency "tty-prompt"
|
35
36
|
|
36
37
|
# For more information and examples about making a new gem, checkout our
|
37
38
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/lib/just-the-recipe/cli.rb
CHANGED
@@ -1,69 +1,35 @@
|
|
1
|
-
|
1
|
+
require './lib/just-the-recipe.rb'
|
2
2
|
|
3
3
|
class JustTheRecipe::CLI
|
4
4
|
|
5
5
|
def call
|
6
6
|
JustTheRecipe::Cookbook.create_from_files
|
7
7
|
puts "Welcome to Just the Recipe! What would you like to do?"
|
8
|
-
|
9
|
-
choose_option
|
10
|
-
goodbye
|
8
|
+
main_menu
|
11
9
|
end
|
12
10
|
|
13
|
-
def
|
14
|
-
|
15
|
-
puts "
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
while input != "exit"
|
23
|
-
input = gets.chomp
|
24
|
-
if input == "1"
|
25
|
-
search
|
26
|
-
elsif input == "2"
|
27
|
-
scrape_url
|
28
|
-
elsif input == "3"
|
29
|
-
cookbook_menu
|
30
|
-
elsif input == "exit"
|
31
|
-
break
|
32
|
-
elsif input == "options"
|
33
|
-
list_options
|
34
|
-
else
|
35
|
-
puts "Whoops! Choose a number 1-3, type options to view your options again, or type exit."
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def scrape_url
|
41
|
-
puts "Enter your url:"
|
42
|
-
url = gets.chomp
|
43
|
-
if JustTheRecipe::Scraper.new(url).valid_url?
|
44
|
-
recipe = JustTheRecipe::Scraper.new(url).get_recipe_by_schema
|
45
|
-
recipe.display_recipe
|
46
|
-
add_recipe(recipe)
|
47
|
-
list_options
|
48
|
-
else
|
49
|
-
puts ""
|
50
|
-
puts "Sorry, it doesn't look like we can get the recipe from that URL. Try something else."
|
51
|
-
list_options
|
11
|
+
def main_menu
|
12
|
+
prompt = TTY::Prompt.new
|
13
|
+
puts "\n"
|
14
|
+
menu_choice = prompt.select("Choose an option") do |menu|
|
15
|
+
menu.choice name: "Search for a new recipe.", value: 1
|
16
|
+
menu.choice name: "Get a recipe from a URL.", value: 2
|
17
|
+
menu.choice name: "View your cookbooks.", value: 3
|
18
|
+
menu.choice name: "Create a new recipe manually.", value: 4
|
19
|
+
menu.choice name: "Exit", value: "exit"
|
52
20
|
end
|
53
|
-
end
|
54
21
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
puts "Sorry, you'll have to answer with either 'y' or 'n'."
|
22
|
+
case menu_choice
|
23
|
+
when 1
|
24
|
+
search
|
25
|
+
when 2
|
26
|
+
scrape_url
|
27
|
+
when 3
|
28
|
+
cookbook_menu
|
29
|
+
when 4
|
30
|
+
new_recipe
|
31
|
+
when "exit"
|
32
|
+
goodbye
|
67
33
|
end
|
68
34
|
end
|
69
35
|
|
@@ -74,44 +40,99 @@ class JustTheRecipe::CLI
|
|
74
40
|
if recipe.class == JustTheRecipe::Recipe
|
75
41
|
recipe.display_recipe
|
76
42
|
add_recipe(recipe)
|
77
|
-
list_options
|
78
43
|
else
|
79
|
-
|
44
|
+
main_menu
|
80
45
|
end
|
81
46
|
end
|
82
47
|
|
83
|
-
def
|
84
|
-
|
85
|
-
|
86
|
-
|
48
|
+
def scrape_url
|
49
|
+
puts "Enter your url:"
|
50
|
+
url = gets.chomp
|
51
|
+
if JustTheRecipe::Scraper.new(url).valid_url?
|
52
|
+
recipe = JustTheRecipe::Scraper.new(url).get_recipe_by_schema
|
53
|
+
recipe.display_recipe
|
54
|
+
add_recipe(recipe)
|
87
55
|
else
|
88
|
-
puts "
|
56
|
+
puts "\nSorry, it doesn't look like we can get the recipe from that URL. Try something else."
|
57
|
+
main_menu
|
89
58
|
end
|
90
|
-
|
59
|
+
end
|
91
60
|
|
61
|
+
def cookbook_menu
|
62
|
+
prompt = TTY::Prompt.new
|
63
|
+
|
64
|
+
cookbooks_create = JustTheRecipe::Cookbook.list_cookbooks << "Create a new cookbook." << "Delete a cookbook." << "Main Menu"
|
65
|
+
input = prompt.select("Choose a cookbook to view or create a new one.", cookbooks_create)
|
66
|
+
JustTheRecipe::Cookbook.list_cookbooks
|
67
|
+
|
92
68
|
if JustTheRecipe::Cookbook.find_by_name(input)
|
93
69
|
puts "Here's what's in the cookbook called #{input}:"
|
94
70
|
puts JustTheRecipe::Cookbook.find_by_name(input).return_cookbook
|
95
|
-
|
96
|
-
elsif input == "
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
puts "Which cookbook would you like to delete? WARNING: THIS CANNOT BE UNDONE!\n\n"
|
104
|
-
JustTheRecipe::Cookbook.list_cookbooks
|
105
|
-
delete_cookbook = gets.chomp
|
106
|
-
JustTheRecipe::Cookbook.delete(delete_cookbook)
|
71
|
+
main_menu
|
72
|
+
elsif input == "Create a new cookbook"
|
73
|
+
create_cookbook
|
74
|
+
main_menu
|
75
|
+
elsif input == "Delete a cookbook."
|
76
|
+
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)
|
107
79
|
puts "Ok, we deleted that cookbook."
|
108
|
-
|
109
|
-
elsif input == "
|
110
|
-
|
80
|
+
main_menu
|
81
|
+
elsif input == "Main Menu"
|
82
|
+
main_menu
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def new_recipe
|
87
|
+
puts "Ok, what would you like to call your new recipe?"
|
88
|
+
name = gets.chomp
|
89
|
+
|
90
|
+
puts "Add a short description of your recipe."
|
91
|
+
description = gets.chomp
|
92
|
+
|
93
|
+
puts "Add the recipe's ingredients, seperated by a comma. (Ex: 1/2 cup of flour, 2 tbsp sugar, 1 cup water)"
|
94
|
+
ingredients = gets.chomp.split(", ")
|
95
|
+
|
96
|
+
puts "Add the recipe's instructions, seperated by a comma. (Ex: Mix the ingredients, cook the recipe, enjoy!)"
|
97
|
+
steps = gets.chomp.split(", ")
|
98
|
+
|
99
|
+
puts "\nGreat! Here's your new recipe:"
|
100
|
+
manual_recipe = JustTheRecipe::Recipe.new(name, description, ingredients, steps)
|
101
|
+
manual_recipe.display_recipe
|
102
|
+
add_recipe(manual_recipe)
|
103
|
+
end
|
104
|
+
|
105
|
+
def create_cookbook
|
106
|
+
puts "Ok! What would you like to name your new cookbook?"
|
107
|
+
cookbook = gets.chomp
|
108
|
+
JustTheRecipe::Cookbook.new(cookbook)
|
109
|
+
puts "Great! We created a new cookbook for you."
|
110
|
+
cookbook
|
111
|
+
end
|
112
|
+
|
113
|
+
def add_recipe(recipe)
|
114
|
+
prompt = TTY::Prompt.new
|
115
|
+
puts "Would you like to add this recipe to a cookbook? It won't be saved otherwise. (y/n)"
|
116
|
+
input = gets.chomp
|
117
|
+
if input == "y"
|
118
|
+
|
119
|
+
cookbooks_create = JustTheRecipe::Cookbook.list_cookbooks << "Create a new cookbook."
|
120
|
+
cookbook = prompt.select("Ok! Choose a cookbook to add your recipe to, or create a new one.", cookbooks_create)
|
121
|
+
if cookbook == "Create a new cookbook."
|
122
|
+
recipe.add_to_cookbook(create_cookbook)
|
123
|
+
puts "We added this recipe to your new cookbook."
|
124
|
+
main_menu
|
125
|
+
else
|
126
|
+
recipe.add_to_cookbook(cookbook)
|
127
|
+
puts "We added this recipe to the cookbook called #{cookbook}"
|
128
|
+
main_menu
|
129
|
+
end
|
130
|
+
elsif input == "n"
|
131
|
+
puts "No problem. This recipe wasn't added to a cookbook."
|
132
|
+
main_menu
|
111
133
|
else
|
112
|
-
puts ""
|
113
|
-
|
114
|
-
list_cookbooks
|
134
|
+
puts "Sorry, you'll have to answer with either 'y' or 'n'."
|
135
|
+
main_menu
|
115
136
|
end
|
116
137
|
end
|
117
138
|
|
@@ -119,4 +140,6 @@ class JustTheRecipe::CLI
|
|
119
140
|
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!"
|
120
141
|
end
|
121
142
|
|
143
|
+
|
144
|
+
|
122
145
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'pry'
|
2
|
-
require './lib/
|
2
|
+
require './lib/just-the-recipe.rb'
|
3
3
|
|
4
4
|
class JustTheRecipe::Cookbook
|
5
5
|
|
@@ -42,7 +42,9 @@ class JustTheRecipe::Cookbook
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.list_cookbooks
|
45
|
-
|
45
|
+
cookbooks = []
|
46
|
+
@@all.each{|i| cookbooks << i.name}
|
47
|
+
cookbooks
|
46
48
|
end
|
47
49
|
|
48
50
|
def return_cookbook
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'pry'
|
2
|
-
require './lib/
|
2
|
+
require './lib/just-the-recipe.rb'
|
3
3
|
|
4
4
|
class JustTheRecipe::Recipe
|
5
5
|
|
@@ -7,7 +7,7 @@ class JustTheRecipe::Recipe
|
|
7
7
|
|
8
8
|
@@all = []
|
9
9
|
|
10
|
-
def initialize(title, description, ingredients, steps, url) # ingredients and steps are arrays
|
10
|
+
def initialize(title, description, ingredients, steps, url= "n/a") # ingredients and steps are arrays
|
11
11
|
@title = title
|
12
12
|
@description = description
|
13
13
|
@ingredients = ingredients
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'pry'
|
2
2
|
|
3
|
-
require './lib/
|
3
|
+
require './lib/just-the-recipe.rb'
|
4
4
|
|
5
5
|
class JustTheRecipe::Searcher
|
6
6
|
|
@@ -34,7 +34,6 @@ class JustTheRecipe::Searcher
|
|
34
34
|
scrape_recipe(good_url)
|
35
35
|
rescue
|
36
36
|
puts "Sorry we couldn't find a valid recipe with that search term."
|
37
|
-
puts e
|
38
37
|
end
|
39
38
|
|
40
39
|
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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Dilthey
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open-uri
|
@@ -52,10 +52,27 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tty-prompt
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: A small CLI application to search for recipes and create simple cookbooks.
|
56
70
|
email:
|
57
71
|
- george.dilthey@gmail.com
|
58
|
-
executables:
|
72
|
+
executables:
|
73
|
+
- console
|
74
|
+
- just-the-recipe
|
75
|
+
- setup
|
59
76
|
extensions: []
|
60
77
|
extra_rdoc_files: []
|
61
78
|
files:
|
@@ -69,7 +86,8 @@ files:
|
|
69
86
|
- bin/just-the-recipe
|
70
87
|
- bin/setup
|
71
88
|
- just-the-recipe.gemspec
|
72
|
-
- lib/
|
89
|
+
- lib/just-the-recipe.rb
|
90
|
+
- lib/just-the-recipe/authenticate.rb
|
73
91
|
- lib/just-the-recipe/cli.rb
|
74
92
|
- lib/just-the-recipe/cookbook.rb
|
75
93
|
- lib/just-the-recipe/recipe.rb
|