usda_ndb 0.2.0 → 0.2.1
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/README.md +4 -4
- data/lib/usda_ndb/client.rb +4 -2
- data/lib/usda_ndb/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: 0f331ec36a73e6e6a52c714f18f3dc4db0d23e14
|
|
4
|
+
data.tar.gz: 247966ec9ae912565a68c1e6aa09476f782c798f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d97853a58a883df2b99ddc9af87592ad4098d5ef3fc273a9e97f07c3b158513b89f9ccd5f00d33e514c030f1c2a8412e6371d8413983607bce21e55bfea61032
|
|
7
|
+
data.tar.gz: 7fc57e6e60e3a189c0d38cf1b3a4654d1b821ad02d8e787ed18ab6bf1b97ba1c4acfb9ab0893ed09740d69ba4f4290b0ca184fb24735dd9347a3d507ff38a2d0
|
data/README.md
CHANGED
|
@@ -37,14 +37,14 @@ end
|
|
|
37
37
|
Then you can use it.
|
|
38
38
|
|
|
39
39
|
```ruby
|
|
40
|
-
# to get nutrition data about product with concrete id(ndbno)
|
|
41
|
-
UsdaNdb.reports('01208')
|
|
42
|
-
# => {"report"=>{"sr"=>"28", "type"=>"Basic", "food"=>{"ndbno"=>"01208", "name"=>"Cheese, provolone, reduced fat", "nutrients"=>[{"nutrient_id"=>"255", "name"=>"Water", ...
|
|
43
|
-
|
|
44
40
|
# to search for products
|
|
45
41
|
UsdaNdb.search('apple raw')
|
|
46
42
|
# => {"list"=>{"q"=>"apple raw", "sr"=>"28", "ds"=>"any", "start"=>0, "end"=>22, "total"=>22, "group"=>"", "sort"=>"r", "item"=>[{"offset"=>0, "group"=>"Fruits and Fruit Juices", "name"=>"Apples, raw, with skin", "ndbno"=>"09003", "ds"=>"SR"}, ...
|
|
47
43
|
|
|
44
|
+
# to get nutrition data about product with concrete id(ndbno)
|
|
45
|
+
UsdaNdb.reports('09003')
|
|
46
|
+
# => {"report"=>{"sr"=>"28", "type"=>"Basic", "food"=>{"ndbno"=>"09003", "name"=>"Apples, raw, with skin", "ds"=>"Standard Reference", "ru"=>"g", "nutrients"=>[{"nutrient_id"=>"255", "name"=>"Water", ...
|
|
47
|
+
|
|
48
48
|
# to list products
|
|
49
49
|
UsdaNdb.list
|
|
50
50
|
# => {"list"=>{"lt"=>"f", "start"=>0, "end"=>50, "total"=>50, "sr"=>"28", "sort"=>"n", "item"=>[{"offset"=>0, "id"=>"09427", "name"=>"Abiyuch, raw"}, {"offset"=>1, "id"=>"09002", "name"=>"Acerola juice, raw"}, ...
|
data/lib/usda_ndb/client.rb
CHANGED
|
@@ -7,8 +7,10 @@ module UsdaNdb
|
|
|
7
7
|
}
|
|
8
8
|
address = UsdaNdb.configuration.endpoint_base
|
|
9
9
|
params = defaults.merge(params)
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
response = RestClient.get "#{address}/#{endpoint}", params: params
|
|
11
|
+
result = response.body
|
|
12
|
+
result = JSON.parse(result) if UsdaNdb.configuration.response_format == 'json'
|
|
13
|
+
result
|
|
12
14
|
end
|
|
13
15
|
end
|
|
14
16
|
end
|
data/lib/usda_ndb/version.rb
CHANGED