Healthy_hunger_api 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +21 -15
- data/Healthy_hunger_api.gemspec +2 -4
- data/README.md +8 -0
- data/bin/Healthy_hunger_api +1 -0
- data/lib/Healthy_hunger_api/api.rb +19 -1
- data/lib/Healthy_hunger_api/cli.rb +49 -13
- data/lib/Healthy_hunger_api/meals.rb +17 -23
- data/lib/Healthy_hunger_api/recipes.rb +56 -0
- data/lib/Healthy_hunger_api/version.rb +1 -1
- data/lib/Healthy_hunger_api.rb +1 -0
- metadata +7 -22
- data/Healthy_hunger_api-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 667d3aee60e71bac20a793ab7c3e4b182974d2f5e1cdafee3b2ae322494aa953
|
4
|
+
data.tar.gz: d0baba8adad9782077d91ed22385011f242a6ad342b2dbc36262bd7b101ab817
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 871251c2248a73b3d6b3e108126429162260248007c593b19715749b6e524ab7f8d2c15689f771e654bc0e9184fc8dfd00bba4404d42c1f97b0625771ad13d21
|
7
|
+
data.tar.gz: 3291505bcf6559dbaf346c1105687f463bff7061ee7771fac7ac8c68183bcee37e775b94e9720ca94ddd005352f983098d9990b9786130923560373d21c7f85c
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,34 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
Healthy_hunger_api (0.
|
4
|
+
Healthy_hunger_api (0.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
coderay (1.1.3)
|
10
|
+
diff-lcs (1.5.0)
|
11
|
+
method_source (1.0.0)
|
12
|
+
pry (0.14.2)
|
13
|
+
coderay (~> 1.1)
|
14
|
+
method_source (~> 1.0)
|
15
|
+
rake (12.3.3)
|
16
|
+
rspec (3.12.0)
|
17
|
+
rspec-core (~> 3.12.0)
|
18
|
+
rspec-expectations (~> 3.12.0)
|
19
|
+
rspec-mocks (~> 3.12.0)
|
20
|
+
rspec-core (3.12.1)
|
21
|
+
rspec-support (~> 3.12.0)
|
22
|
+
rspec-expectations (3.12.2)
|
18
23
|
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.
|
20
|
-
rspec-mocks (3.
|
24
|
+
rspec-support (~> 3.12.0)
|
25
|
+
rspec-mocks (3.12.3)
|
21
26
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.
|
23
|
-
rspec-support (3.
|
27
|
+
rspec-support (~> 3.12.0)
|
28
|
+
rspec-support (3.12.0)
|
24
29
|
|
25
30
|
PLATFORMS
|
26
31
|
ruby
|
27
32
|
|
28
33
|
DEPENDENCIES
|
29
34
|
Healthy_hunger_api!
|
35
|
+
pry
|
30
36
|
rake (~> 12.0)
|
31
37
|
rspec (~> 3.0)
|
32
38
|
|
33
39
|
BUNDLED WITH
|
34
|
-
2.
|
40
|
+
2.2.31
|
data/Healthy_hunger_api.gemspec
CHANGED
@@ -23,9 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
25
|
end
|
26
|
-
|
27
|
-
spec.executables =
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
|
-
|
30
|
-
spec.add_development_dependency "rake", "~> 12.3.3"
|
31
29
|
end
|
data/README.md
CHANGED
@@ -19,7 +19,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
19
19
|
|
20
20
|
## Contributing
|
21
21
|
|
22
|
+
<<<<<<< HEAD
|
23
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/Healthy_hunger_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/Healthy_hunger_api/blob/master/CODE_OF_CONDUCT.md).
|
24
|
+
=======
|
22
25
|
Bug reports and pull requests are welcome on GitHub at https://github.com/lsuman83/Healthy_hunger_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/lsuman83/Healthy_hunger_api/blob/master/CODE_OF_CONDUCT.md).
|
26
|
+
>>>>>>> fb9e34adcc5e25b3acab3cf63ba24a0de499c96f
|
23
27
|
|
24
28
|
|
25
29
|
## License
|
@@ -28,4 +32,8 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
28
32
|
|
29
33
|
## Code of Conduct
|
30
34
|
|
35
|
+
<<<<<<< HEAD
|
36
|
+
Everyone interacting in the HealthyHungerApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/Healthy_hunger_api/blob/master/CODE_OF_CONDUCT.md).
|
37
|
+
=======
|
31
38
|
Everyone interacting in the HealthyHungerApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/lsuman83/Healthy_hunger_api/blob/master/CODE_OF_CONDUCT.md).
|
39
|
+
>>>>>>> fb9e34adcc5e25b3acab3cf63ba24a0de499c96f
|
data/bin/Healthy_hunger_api
CHANGED
@@ -5,7 +5,6 @@ require 'json'
|
|
5
5
|
|
6
6
|
|
7
7
|
module HealthyHungerApi
|
8
|
-
|
9
8
|
class API #class that is accessing the api from the url
|
10
9
|
|
11
10
|
def self.api_key #class method used to help hide the api key by reading it from a
|
@@ -63,6 +62,25 @@ module HealthyHungerApi
|
|
63
62
|
|
64
63
|
|
65
64
|
|
65
|
+
request = Net::HTTP::Get.new(url)
|
66
|
+
request["x-rapidapi-host"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'
|
67
|
+
request["x-rapidapi-key"] = api_key
|
68
|
+
response = http.request(request)
|
69
|
+
JSON.parse(response.read_body) if response.is_a?(Net::HTTPSuccess)
|
70
|
+
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.get_recipes(recipe_id)
|
75
|
+
|
76
|
+
url = URI("https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{recipe_id}/information")
|
77
|
+
|
78
|
+
http = Net::HTTP.new(url.host, url.port)
|
79
|
+
http.use_ssl = true
|
80
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
81
|
+
|
82
|
+
|
83
|
+
|
66
84
|
request = Net::HTTP::Get.new(url)
|
67
85
|
request["x-rapidapi-host"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'
|
68
86
|
request["x-rapidapi-key"] = api_key
|
@@ -1,16 +1,19 @@
|
|
1
1
|
module HealthyHungerApi
|
2
2
|
|
3
|
-
class CLI
|
3
|
+
class CLI #class that runs the CLI. It outputs options to the screen and receives input from a user to help access othe classes
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
|
7
7
|
@input = "" #initializes all input instances to an empty string
|
8
|
-
|
8
|
+
@all = []
|
9
9
|
end
|
10
10
|
|
11
11
|
def start #instance method that starts the program and calls other instance methods used to access info for the app
|
12
12
|
|
13
|
-
puts "
|
13
|
+
puts "What is your name?"
|
14
|
+
@input = gets.strip
|
15
|
+
puts ""
|
16
|
+
puts "\tWelcome to our Healthy Hunger CLI app, #{@input}!"
|
14
17
|
puts ""
|
15
18
|
puts "We are here to help you create a healthy meal plan for yourself. Let's get started!"
|
16
19
|
puts ""
|
@@ -31,18 +34,29 @@ module HealthyHungerApi
|
|
31
34
|
|
32
35
|
while @input != 'exit' #conditionals based on the validity of the choice returned by the ask_for_choice method
|
33
36
|
if valid?(@input)
|
34
|
-
if @menu_input == 'day'
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
#if @menu_input == 'day'
|
38
|
+
@meal_info = Meals.find_by_number(@input)
|
39
|
+
#calls the instance method that displays the meals by using the class method
|
40
|
+
#elsif @menu_input == 'week' #that is used to find the number that references the particular meal from the Meal class
|
41
|
+
# Meals.find_by_number(@input).display_meals_by_week
|
42
|
+
#end
|
43
|
+
|
44
|
+
set_recipes
|
45
|
+
|
46
|
+
puts ""
|
47
|
+
print_recipe
|
48
|
+
@meal_info.meals_summary
|
40
49
|
puts ""
|
41
50
|
puts "To see the description of another meal, type 'next'"
|
42
51
|
puts "otherwise type 'exit' to exit the app!"
|
43
52
|
|
44
53
|
@input = gets.strip
|
45
54
|
if @input == 'next' #conditional that is used to either exit the program or get more descriptions of meals
|
55
|
+
if @menu_input == 'day' #conditional statements used to call a method that displays the meals by day or by week
|
56
|
+
list_meals_by_day
|
57
|
+
elsif @menu_input == 'week'
|
58
|
+
list_meals_by_week
|
59
|
+
end
|
46
60
|
ask_for_choice
|
47
61
|
elsif @input != 'next' && @input != 'exit'
|
48
62
|
puts "Didn't recognize input. Please try again"
|
@@ -89,7 +103,7 @@ module HealthyHungerApi
|
|
89
103
|
|
90
104
|
def meal_calories #instance method that is getting a calorie input from user also making sure the
|
91
105
|
#value is within the parameters given
|
92
|
-
puts "What is your target Calorie intake? (400 - 3200)"
|
106
|
+
puts "What is your target daily Calorie intake? (400 - 3200)"
|
93
107
|
@meal_cal = gets.strip
|
94
108
|
|
95
109
|
puts ""
|
@@ -141,6 +155,7 @@ module HealthyHungerApi
|
|
141
155
|
#strings as values of the method
|
142
156
|
puts "List any allergies you may have. If you enter more than one, seperate them with a comma."
|
143
157
|
@allergy = gets.strip
|
158
|
+
|
144
159
|
if @allergy.to_i != 0 #checks to make sure that the value entered is not an integer
|
145
160
|
puts "Please enter an allergy, not a number."
|
146
161
|
puts ""
|
@@ -155,11 +170,29 @@ module HealthyHungerApi
|
|
155
170
|
|
156
171
|
end
|
157
172
|
|
173
|
+
def set_recipes
|
174
|
+
|
175
|
+
@meal_id = @meal_info.get_meal_id
|
176
|
+
Recipes.load_recipes(@meal_id)
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
def print_recipe
|
181
|
+
|
182
|
+
Recipes.recipe_ingredients
|
183
|
+
puts ""
|
184
|
+
Recipes.recipe_instructions
|
185
|
+
|
186
|
+
end
|
187
|
+
|
158
188
|
def list_meals_by_day #instance method that searches through all of the meal objects that have been
|
159
189
|
#created for a daily meal plan, iterates over the objects and prints out the name of the meal with its
|
160
190
|
#index number next to it
|
161
191
|
|
162
192
|
puts ""
|
193
|
+
puts "Here are your meals for the day:"
|
194
|
+
puts ""
|
195
|
+
|
163
196
|
Meals.all.each.with_index(1) do |meal, index|
|
164
197
|
puts "Meal ##{index}: #{meal.title}"
|
165
198
|
end
|
@@ -171,13 +204,16 @@ module HealthyHungerApi
|
|
171
204
|
#index number next to it. It also prints the meal number and which day of the week it is refering to
|
172
205
|
|
173
206
|
puts ""
|
207
|
+
puts "Here are your meals for the week:"
|
208
|
+
puts ""
|
209
|
+
|
174
210
|
daily_index = 0
|
211
|
+
|
175
212
|
Meals.all.each.with_index(1) do |meal, index|
|
176
|
-
meal_name = JSON.parse(meal.value)
|
177
213
|
if daily_index % 3 == 0
|
178
214
|
puts "Day ##{meal.day}:"
|
179
215
|
end
|
180
|
-
puts " Meal ##{meal.slot} (#{index}): #{
|
216
|
+
puts " Meal ##{meal.slot} (#{index}): #{meal.title}"
|
181
217
|
daily_index += 1
|
182
218
|
end
|
183
219
|
|
@@ -190,7 +226,7 @@ module HealthyHungerApi
|
|
190
226
|
puts ""
|
191
227
|
puts "Choose a meal number to see a description"
|
192
228
|
@input = gets.strip
|
193
|
-
|
229
|
+
|
194
230
|
end
|
195
231
|
|
196
232
|
def valid?(input) #instance method that returns as truthy or falsey based on whether the input that
|
@@ -38,55 +38,49 @@ module HealthyHungerApi
|
|
38
38
|
|
39
39
|
end
|
40
40
|
|
41
|
-
attr_accessor
|
42
|
-
|
41
|
+
attr_accessor :id, :title, :readyInMinutes, :servings, :sumnary, :day, :slot, :value #creates getter and setter methods for each
|
42
|
+
#hash key received from the api meal hash
|
43
43
|
|
44
44
|
def initialize(attributes = {}) #initializes new instances of each meal
|
45
45
|
attributes.each do |attribute_name, attribute_value| #iterates over each has assigning each key as an attribute name
|
46
|
-
if
|
46
|
+
if (attribute_name == "value")
|
47
|
+
initialize(JSON.parse(attribute_value))
|
48
|
+
elsif self.respond_to?("#{attribute_name}=") #and each key value as the attribute value using the send method
|
47
49
|
self.send("#{attribute_name}=", attribute_value)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
54
|
|
53
|
-
|
54
|
-
#value key and grab the values that are within the "id" symbol
|
55
|
-
API.get_summary(JSON.parse(self.value)["id"])
|
56
|
-
|
57
|
-
end
|
55
|
+
|
58
56
|
|
59
57
|
|
60
|
-
def
|
58
|
+
def summaries #instance method that uses the id key from the return value of the class method
|
61
59
|
#get_summary of the API class to get the summary of each meal for a daily meal plan
|
62
60
|
|
63
61
|
@summaries ||= API.get_summary(self.id)
|
64
62
|
|
65
63
|
end
|
66
64
|
|
67
|
-
|
65
|
+
|
68
66
|
|
69
|
-
|
67
|
+
def get_meal_id
|
70
68
|
|
71
|
-
|
69
|
+
self.id
|
72
70
|
|
71
|
+
end
|
73
72
|
|
74
|
-
def
|
73
|
+
def meals_summary #instance method that uses the "summary" string to access the value from that hash symbol
|
75
74
|
#and replace each of the symbols found through the regex passed into the .gsub method
|
76
75
|
#with an empty space
|
77
|
-
|
78
|
-
puts
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
def display_meals_by_week#instance method that uses the "summary" string to access the value from that hash symbol
|
83
|
-
#and replace each of the symbols found through the regex passed into the .gsub method
|
84
|
-
#with an empty space
|
85
|
-
|
86
|
-
puts weekly_summaries["summary"].gsub(/<\/?[a-z]+>/, "").gsub(/<a href="[a-zA-Z0-9\/:\.\-\+]+">/, "")
|
76
|
+
puts ""
|
77
|
+
puts "Summary:"
|
78
|
+
puts summaries["summary"].gsub(/<\/?[a-z]+>/, "").gsub(/<a href="[a-zA-Z0-9\/:\.\-\+]+">/, "")
|
79
|
+
|
87
80
|
|
88
81
|
end
|
89
82
|
|
83
|
+
|
90
84
|
end
|
91
85
|
|
92
86
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module HealthyHungerApi
|
2
|
+
|
3
|
+
class Recipes
|
4
|
+
|
5
|
+
@@all = []
|
6
|
+
|
7
|
+
def self.all
|
8
|
+
|
9
|
+
@@all ||= load_recipes
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.load_recipes(id)
|
14
|
+
|
15
|
+
@recipes = API.get_recipes(id)
|
16
|
+
@@all = self.create_new_recipe(@recipes)
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.create_new_recipe(recipes)
|
21
|
+
|
22
|
+
recipes.map do |recipe_hash|
|
23
|
+
self.new(recipe_hash)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_accessor :extended_ingredients, :instructions
|
29
|
+
|
30
|
+
def initialize (attributes = {})
|
31
|
+
|
32
|
+
attributes.each do |attribute_name, attribute_value|
|
33
|
+
self.send("#{attribute_name}=", attribute_value) if self.respond_to?("#{attribute_name}=")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.recipe_instructions
|
39
|
+
|
40
|
+
puts "Instructions:"
|
41
|
+
puts @recipes["instructions"].gsub(/<\/?[a-z]+>/, "").gsub(/<a href="[a-zA-Z0-9\/:\.\-\+]+">/, "")
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.recipe_ingredients
|
46
|
+
|
47
|
+
puts "Ingredients:"
|
48
|
+
@recipes["extendedIngredients"].each do | ingredient |
|
49
|
+
puts "#{ingredient["amount"]} - #{ingredient["unit"]} #{ingredient["name"]}".gsub(/<\/?[a-z]+>/, "").gsub(/<a href="[a-zA-Z0-9\/:\.\-\+]+">/, "")
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/lib/Healthy_hunger_api.rb
CHANGED
@@ -2,6 +2,7 @@ require_relative "Healthy_hunger_api/version" #gives access to the version file
|
|
2
2
|
require_relative "Healthy_hunger_api/meals" #gives access to the meals file in the Healthy_hunger_api folder
|
3
3
|
require_relative "Healthy_hunger_api/api" #gives access to the api file in the Healthy_hunger_api folder
|
4
4
|
require_relative "Healthy_hunger_api/cli" #gives access to the cli file in the Healthy_hunger_api folder
|
5
|
+
require_relative "Healthy_hunger_api/recipes"
|
5
6
|
|
6
7
|
module HealthyHungerApi
|
7
8
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,35 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Healthy_hunger_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Bordelon
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 12.3.3
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 12.3.3
|
11
|
+
date: 2023-02-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: CLI program for getting a List of created meals and providing a summary
|
28
14
|
from Recipe-Food-Nutrition API
|
29
15
|
email:
|
30
16
|
- sean.j.bordelon@gmail.com
|
31
|
-
executables:
|
32
|
-
- Healthy_hunger_api
|
17
|
+
executables: []
|
33
18
|
extensions: []
|
34
19
|
extra_rdoc_files: []
|
35
20
|
files:
|
@@ -39,7 +24,6 @@ files:
|
|
39
24
|
- CODE_OF_CONDUCT.md
|
40
25
|
- Gemfile
|
41
26
|
- Gemfile.lock
|
42
|
-
- Healthy_hunger_api-0.1.0.gem
|
43
27
|
- Healthy_hunger_api.gemspec
|
44
28
|
- LICENSE.txt
|
45
29
|
- README.md
|
@@ -51,6 +35,7 @@ files:
|
|
51
35
|
- lib/Healthy_hunger_api/api.rb
|
52
36
|
- lib/Healthy_hunger_api/cli.rb
|
53
37
|
- lib/Healthy_hunger_api/meals.rb
|
38
|
+
- lib/Healthy_hunger_api/recipes.rb
|
54
39
|
- lib/Healthy_hunger_api/version.rb
|
55
40
|
homepage: https://github.com/lsuman83/Healthy_hunger_api
|
56
41
|
licenses:
|
@@ -73,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
58
|
- !ruby/object:Gem::Version
|
74
59
|
version: '0'
|
75
60
|
requirements: []
|
76
|
-
rubygems_version: 3.0.
|
61
|
+
rubygems_version: 3.0.1
|
77
62
|
signing_key:
|
78
63
|
specification_version: 4
|
79
64
|
summary: Displays a List of created meals from Recipe-Food-Nutrition API
|
Binary file
|