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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f80947a4105f6a1fe69c69cefa0078a7f5ec7a1
4
- data.tar.gz: 67b9fcf1ab48fb00d669a2ebed397a40d0df61d0
3
+ metadata.gz: 0f331ec36a73e6e6a52c714f18f3dc4db0d23e14
4
+ data.tar.gz: 247966ec9ae912565a68c1e6aa09476f782c798f
5
5
  SHA512:
6
- metadata.gz: 186f1bcecf3f770b04e04d19ad953b6a50eabe9424cd06afe1d68d790b886fc8e14fe36a6b54940cdcdb060d76b5c21f81f469416f956e6d4cec98fefe47d855
7
- data.tar.gz: 5209bf4e66d66ba21401c9ed86040cd2f9ab65acc3ccc1fd79665ca69521a340329e1e7485389eae73aa440751e9fd7c7fa285e6f31ed2c8228776d25437f391
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"}, ...
@@ -7,8 +7,10 @@ module UsdaNdb
7
7
  }
8
8
  address = UsdaNdb.configuration.endpoint_base
9
9
  params = defaults.merge(params)
10
- json = RestClient.get "#{address}/#{endpoint}", params: params
11
- JSON.parse(json)
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
@@ -1,3 +1,3 @@
1
1
  module UsdaNdb
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usda_ndb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - aTeapot