just-the-recipe 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.template +2 -0
- data/Gemfile.lock +15 -1
- data/just-the-recipe.gemspec +2 -1
- data/lib/environment.rb +3 -0
- data/lib/just-the-recipe/cli.rb +102 -81
- data/lib/just-the-recipe/cookbook.rb +3 -1
- data/lib/just-the-recipe/recipe.rb +1 -1
- data/lib/just-the-recipe/searcher.rb +0 -1
- data/lib/just-the-recipe/version.rb +1 -1
- data/notes.md +4 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7efe12a5ede8904f3753a7f8de9d370fb2e53db6652064e9af41572bba46b886
|
4
|
+
data.tar.gz: a815e1d1ab0b0c5b23e94c884537ec889fa614e81c6bbc1d0179cb10429036fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bd498673d49f389862ed7e4a3fc52baea5672d3025a52a22b7c7a1123e97bcd2359d3130d06c595259ea8a68c56d26a8543917e658664f01bf1e0f94203aebc
|
7
|
+
data.tar.gz: 1eae0d9e9bfdb55093c2a3bf8ed5ea8fe30ec803584014e94c6a2698365ab6704a24681dea954c9a15d892c30916b79641125fdaecc7193eb4826981719d354a
|
data/.env.template
ADDED
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.2.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/just-the-recipe.gemspec
CHANGED
@@ -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
|
|
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
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/environment.rb
CHANGED
data/lib/just-the-recipe/cli.rb
CHANGED
@@ -5,65 +5,31 @@ class JustTheRecipe::CLI
|
|
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
|
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"
|
37
20
|
end
|
38
|
-
end
|
39
21
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
list_options
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def add_recipe(recipe)
|
56
|
-
puts "Would you like to add this recipe to a cookbook? (y/n)"
|
57
|
-
input = gets.chomp
|
58
|
-
if input == "y"
|
59
|
-
puts "Ok! Which cookbook would you like to add this recipe to? Type an existing cookbook name, or type anything to create a new one!"
|
60
|
-
cookbook = gets.chomp
|
61
|
-
recipe.add_to_cookbook(cookbook)
|
62
|
-
puts "Great choice. We added this recipe to the cookbook called #{cookbook}"
|
63
|
-
elsif input == "n"
|
64
|
-
puts "No problem. This recipe wasn't added to a cookbook."
|
65
|
-
else
|
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
|
|
@@ -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
|
data/notes.md
ADDED
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Dilthey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
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,6 +52,20 @@ 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
|
@@ -60,6 +74,7 @@ extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
76
|
- ".DS_Store"
|
77
|
+
- ".env.template"
|
63
78
|
- ".gitignore"
|
64
79
|
- Gemfile
|
65
80
|
- Gemfile.lock
|
@@ -76,6 +91,7 @@ files:
|
|
76
91
|
- lib/just-the-recipe/scraper.rb
|
77
92
|
- lib/just-the-recipe/searcher.rb
|
78
93
|
- lib/just-the-recipe/version.rb
|
94
|
+
- notes.md
|
79
95
|
homepage: https://github.com/george-dilthey/just-the-recipe
|
80
96
|
licenses: []
|
81
97
|
metadata:
|