nutrition_facts 0.7.0 → 0.8.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/lib/nutrition_facts/cli.rb +9 -2
- data/lib/nutrition_facts/item.rb +4 -2
- data/lib/nutrition_facts/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 051c404a01d0b641b7bc51261222a5ea1c1558ee
|
4
|
+
data.tar.gz: c0d1671d2114dc1e7b853d858426aca7f09c8007
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98580bf36402ecf548a7a35aff490028ebd22fa71f356789d2ad97a2c1fa2162eb7ccc543d264fe95a8e66aa9c3c1011a165fb184d455b0f26665b9ee5563cf7
|
7
|
+
data.tar.gz: 7a7c8a8696063cb3eb18e4dee7bcb9df6e0d71c0617ea75da168d26398abe6869a38f70c473cbe3103a5f87f06110978a7a19372bd191e9dd2c50bca2ada4591
|
data/lib/nutrition_facts/cli.rb
CHANGED
@@ -90,15 +90,22 @@ class NutritionFacts::CLI
|
|
90
90
|
puts ''
|
91
91
|
puts food_item_data.item_name.to_s
|
92
92
|
puts '---'
|
93
|
+
puts "Serving Size: #{food_item_data.nf_serving_size_qty} #{food_item_data.nf_serving_size_unit}"
|
94
|
+
puts "Serving Weight: #{food_item_data.nf_serving_weight_grams}g"
|
93
95
|
puts "Calories: #{food_item_data.nf_calories} kcal"
|
96
|
+
puts "Calories from fat: #{food_item_data.nf_calories_from_fat} kcal"
|
94
97
|
puts "Total Fat: #{food_item_data.nf_total_fat}g"
|
98
|
+
puts "Saturated Fat: #{food_item_data.nf_saturated_fat}g"
|
99
|
+
puts "Cholesterol: #{food_item_data.nf_cholesterol}mg"
|
95
100
|
puts "Protein: #{food_item_data.nf_protein}g"
|
96
|
-
puts "
|
101
|
+
puts "Total Carbohydrates: #{food_item_data.nf_total_carbohydrate}g"
|
97
102
|
puts "Sugar: #{food_item_data.nf_sugars}g"
|
103
|
+
puts "Dietary Fiber: #{food_item_data.nf_dietary_fiber}g"
|
98
104
|
puts "Sodium: #{food_item_data.nf_sodium}mg"
|
99
105
|
puts "Vitamin C: #{food_item_data.nf_vitamin_c_dv}%"
|
100
106
|
puts "Vitamin A: #{food_item_data.nf_vitamin_a_dv}%"
|
101
|
-
puts "
|
107
|
+
puts "Calcium: #{food_item_data.nf_calcium_dv}%"
|
108
|
+
puts "Iron: #{food_item_data.nf_iron_dv}%"
|
102
109
|
loop_or_quit
|
103
110
|
end
|
104
111
|
end
|
data/lib/nutrition_facts/item.rb
CHANGED
@@ -4,7 +4,9 @@ class NutritionFacts::Item
|
|
4
4
|
:nf_total_carbohydrate, :nf_dietary_fiber, :nf_sugars,
|
5
5
|
:nf_protein, :nf_serving_size_qty, :nf_serving_size_unit,
|
6
6
|
:nf_serving_weight_grams, :nf_sodium, :nf_vitamin_c_dv,
|
7
|
-
:nf_vitamin_a_dv
|
7
|
+
:nf_vitamin_a_dv, :nf_calories_from_fat, :nf_saturated_fat,
|
8
|
+
:nf_cholesterol, :nf_calcium_dv, :nf_iron_dv,
|
9
|
+
:nf_serving_size_qty, :nf_serving_size_unit
|
8
10
|
|
9
11
|
@@all = []
|
10
12
|
|
@@ -15,7 +17,7 @@ class NutritionFacts::Item
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def self.find_by_name(name)
|
18
|
-
uri = URI.parse("https://api.nutritionix.com/v1_1/search/#{name}?results=0%3A9&cal_min=0&cal_max=50000&fields=item_name%2Cnf_calories%2Cnf_total_fat%2Cnf_total_carbohydrate%2Cnf_dietary_fiber%2Cnf_sugars%2Cnf_protein%2Cnf_serving_weight_grams%2Cnf_sodium%2Cnf_vitamin_a_dv%2Cnf_vitamin_c_dv&appId=da276553&appKey=f501b79647768ba684af20428a44ef59")
|
20
|
+
uri = URI.parse("https://api.nutritionix.com/v1_1/search/#{name}?results=0%3A9&cal_min=0&cal_max=50000&fields=item_name%2Cnf_calories%2Cnf_total_fat%2Cnf_total_carbohydrate%2Cnf_dietary_fiber%2Cnf_sugars%2Cnf_protein%2Cnf_serving_weight_grams%2Cnf_cholesterol%2Cnf_saturated_fat%2Cnf_calories_from_fat%2Cnf_sodium%2Cnf_calcium_dv%2Cnf_iron_dv%2Cnf_vitamin_a_dv%2Cnf_vitamin_c_dv%2Cnf_serving_size_qty%2Cnf_serving_size_unit&appId=da276553&appKey=f501b79647768ba684af20428a44ef59")
|
19
21
|
|
20
22
|
response = Net::HTTP.get_response(uri)
|
21
23
|
|