ndb-ruby 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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +11 -0
  3. data/.gitignore +9 -0
  4. data/.rubocop.yml +1055 -0
  5. data/.travis.yml +4 -0
  6. data/CODE_OF_CONDUCT.md +13 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +80 -0
  10. data/Rakefile +4 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +7 -0
  13. data/lib/ndb-ruby.rb +41 -0
  14. data/lib/ndb/food_report.rb +13 -0
  15. data/lib/ndb/list.rb +21 -0
  16. data/lib/ndb/nutrient_report.rb +21 -0
  17. data/lib/ndb/search.rb +24 -0
  18. data/lib/ndb/version.rb +3 -0
  19. data/ndb-ruby.gemspec +32 -0
  20. data/spec/fixtures/vcr_cassettes/food_report_ndbno.yml +766 -0
  21. data/spec/fixtures/vcr_cassettes/food_report_type.yml +1278 -0
  22. data/spec/fixtures/vcr_cassettes/list_max.yml +574 -0
  23. data/spec/fixtures/vcr_cassettes/list_offset.yml +324 -0
  24. data/spec/fixtures/vcr_cassettes/list_sort.yml +324 -0
  25. data/spec/fixtures/vcr_cassettes/list_type.yml +324 -0
  26. data/spec/fixtures/vcr_cassettes/nutrient_report_food_group.yml +829 -0
  27. data/spec/fixtures/vcr_cassettes/nutrient_report_max.yml +1576 -0
  28. data/spec/fixtures/vcr_cassettes/nutrient_report_ndbno.yml +89 -0
  29. data/spec/fixtures/vcr_cassettes/nutrient_report_nutrients.yml +824 -0
  30. data/spec/fixtures/vcr_cassettes/nutrient_report_offset.yml +824 -0
  31. data/spec/fixtures/vcr_cassettes/nutrient_report_subset.yml +826 -0
  32. data/spec/fixtures/vcr_cassettes/search_all_foods.yml +375 -0
  33. data/spec/fixtures/vcr_cassettes/search_food_group.yml +375 -0
  34. data/spec/fixtures/vcr_cassettes/search_max_rows.yml +675 -0
  35. data/spec/fixtures/vcr_cassettes/search_query.yml +375 -0
  36. data/spec/fixtures/vcr_cassettes/search_sort_name.yml +213 -0
  37. data/spec/ndb/food_report_spec.rb +19 -0
  38. data/spec/ndb/list_spec.rb +33 -0
  39. data/spec/ndb/nutrient_report_spec.rb +49 -0
  40. data/spec/ndb/search_spec.rb +59 -0
  41. data/spec/ndb_spec.rb +13 -0
  42. data/spec/spec_helper.rb +21 -0
  43. metadata +211 -0
@@ -0,0 +1,574 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.nal.usda.gov/ndb/list?api_key=DEMO_KEY&format=JSON&lt=f&max=100&offset=0&sort=n
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Accept-Ranges:
22
+ - bytes
23
+ Access-Control-Allow-Credentials:
24
+ - 'true'
25
+ Access-Control-Allow-Headers:
26
+ - DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type
27
+ Access-Control-Allow-Methods:
28
+ - GET, POST, OPTIONS
29
+ Access-Control-Allow-Origin:
30
+ - "*"
31
+ Age:
32
+ - '0'
33
+ Content-Type:
34
+ - application/json;charset=UTF-8
35
+ Date:
36
+ - Sun, 27 Sep 2015 00:52:09 GMT
37
+ Location:
38
+ - ''
39
+ Server:
40
+ - nginx
41
+ Vary:
42
+ - Accept-Encoding
43
+ Via:
44
+ - 1.1 varnish-v4
45
+ X-Cache:
46
+ - MISS
47
+ X-Ratelimit-Limit:
48
+ - '1000'
49
+ X-Ratelimit-Remaining:
50
+ - '982'
51
+ X-Varnish:
52
+ - '41867636'
53
+ Transfer-Encoding:
54
+ - chunked
55
+ Connection:
56
+ - keep-alive
57
+ body:
58
+ encoding: ASCII-8BIT
59
+ string: |-
60
+ {
61
+ "list": {
62
+ "lt": "f",
63
+ "start": 0,
64
+ "end": 100,
65
+ "total": 100,
66
+ "sr": "27",
67
+ "sort": "n",
68
+ "item": [
69
+ {
70
+ "offset": 0,
71
+ "id": "09427",
72
+ "name": "Abiyuch, raw"
73
+ },
74
+ {
75
+ "offset": 1,
76
+ "id": "09002",
77
+ "name": "Acerola juice, raw"
78
+ },
79
+ {
80
+ "offset": 2,
81
+ "id": "09001",
82
+ "name": "Acerola, (west indian cherry), raw"
83
+ },
84
+ {
85
+ "offset": 3,
86
+ "id": "35182",
87
+ "name": "Acorn stew (Apache)"
88
+ },
89
+ {
90
+ "offset": 4,
91
+ "id": "35193",
92
+ "name": "Agave, cooked (Southwest)"
93
+ },
94
+ {
95
+ "offset": 5,
96
+ "id": "35194",
97
+ "name": "Agave, dried (Southwest)"
98
+ },
99
+ {
100
+ "offset": 6,
101
+ "id": "35192",
102
+ "name": "Agave, raw (Southwest)"
103
+ },
104
+ {
105
+ "offset": 7,
106
+ "id": "35225",
107
+ "name": "Agutuk, fish with shortening (Alaskan ice cream) (Alaska Native)"
108
+ },
109
+ {
110
+ "offset": 8,
111
+ "id": "35001",
112
+ "name": "Agutuk, fish/berry with seal oil (Alaskan ice cream) (Alaska Native)"
113
+ },
114
+ {
115
+ "offset": 9,
116
+ "id": "35003",
117
+ "name": "Agutuk, meat-caribou (Alaskan ice cream) (Alaska Native)"
118
+ },
119
+ {
120
+ "offset": 10,
121
+ "id": "14006",
122
+ "name": "Alcoholic beverage, beer, light"
123
+ },
124
+ {
125
+ "offset": 11,
126
+ "id": "14007",
127
+ "name": "Alcoholic beverage, beer, light, BUD LIGHT"
128
+ },
129
+ {
130
+ "offset": 12,
131
+ "id": "14005",
132
+ "name": "Alcoholic beverage, beer, light, BUDWEISER SELECT"
133
+ },
134
+ {
135
+ "offset": 13,
136
+ "id": "14013",
137
+ "name": "Alcoholic beverage, beer, light, MICHELOB ULTRA"
138
+ },
139
+ {
140
+ "offset": 14,
141
+ "id": "14003",
142
+ "name": "Alcoholic beverage, beer, regular, all"
143
+ },
144
+ {
145
+ "offset": 15,
146
+ "id": "14004",
147
+ "name": "Alcoholic beverage, beer, regular, BUDWEISER"
148
+ },
149
+ {
150
+ "offset": 16,
151
+ "id": "14034",
152
+ "name": "Alcoholic beverage, creme de menthe, 72 proof"
153
+ },
154
+ {
155
+ "offset": 17,
156
+ "id": "14009",
157
+ "name": "Alcoholic beverage, daiquiri, canned"
158
+ },
159
+ {
160
+ "offset": 18,
161
+ "id": "14010",
162
+ "name": "Alcoholic beverage, daiquiri, prepared-from-recipe"
163
+ },
164
+ {
165
+ "offset": 19,
166
+ "id": "14533",
167
+ "name": "Alcoholic beverage, distilled, all (gin, rum, vodka, whiskey) 100 proof"
168
+ },
169
+ {
170
+ "offset": 20,
171
+ "id": "14037",
172
+ "name": "Alcoholic beverage, distilled, all (gin, rum, vodka, whiskey) 80 proof"
173
+ },
174
+ {
175
+ "offset": 21,
176
+ "id": "14550",
177
+ "name": "Alcoholic beverage, distilled, all (gin, rum, vodka, whiskey) 86 proof"
178
+ },
179
+ {
180
+ "offset": 22,
181
+ "id": "14551",
182
+ "name": "Alcoholic beverage, distilled, all (gin, rum, vodka, whiskey) 90 proof"
183
+ },
184
+ {
185
+ "offset": 23,
186
+ "id": "14532",
187
+ "name": "Alcoholic beverage, distilled, all (gin, rum, vodka, whiskey) 94 proof"
188
+ },
189
+ {
190
+ "offset": 24,
191
+ "id": "14049",
192
+ "name": "Alcoholic beverage, distilled, gin, 90 proof"
193
+ },
194
+ {
195
+ "offset": 25,
196
+ "id": "14050",
197
+ "name": "Alcoholic beverage, distilled, rum, 80 proof"
198
+ },
199
+ {
200
+ "offset": 26,
201
+ "id": "14051",
202
+ "name": "Alcoholic beverage, distilled, vodka, 80 proof"
203
+ },
204
+ {
205
+ "offset": 27,
206
+ "id": "14052",
207
+ "name": "Alcoholic beverage, distilled, whiskey, 86 proof"
208
+ },
209
+ {
210
+ "offset": 28,
211
+ "id": "14415",
212
+ "name": "Alcoholic beverage, liqueur, coffee with cream, 34 proof"
213
+ },
214
+ {
215
+ "offset": 29,
216
+ "id": "14414",
217
+ "name": "Alcoholic beverage, liqueur, coffee, 53 proof"
218
+ },
219
+ {
220
+ "offset": 30,
221
+ "id": "14534",
222
+ "name": "Alcoholic beverage, liqueur, coffee, 63 proof"
223
+ },
224
+ {
225
+ "offset": 31,
226
+ "id": "14015",
227
+ "name": "Alcoholic beverage, pina colada, canned"
228
+ },
229
+ {
230
+ "offset": 32,
231
+ "id": "14017",
232
+ "name": "Alcoholic beverage, pina colada, prepared-from-recipe"
233
+ },
234
+ {
235
+ "offset": 33,
236
+ "id": "43479",
237
+ "name": "Alcoholic beverage, rice (sake)"
238
+ },
239
+ {
240
+ "offset": 34,
241
+ "id": "14019",
242
+ "name": "Alcoholic beverage, tequila sunrise, canned"
243
+ },
244
+ {
245
+ "offset": 35,
246
+ "id": "14027",
247
+ "name": "Alcoholic beverage, whiskey sour, canned"
248
+ },
249
+ {
250
+ "offset": 36,
251
+ "id": "14029",
252
+ "name": "Alcoholic beverage, whiskey sour, prepared from item 14028"
253
+ },
254
+ {
255
+ "offset": 37,
256
+ "id": "14025",
257
+ "name": "Alcoholic beverage, whiskey sour, prepared with water, whiskey and powder mix"
258
+ },
259
+ {
260
+ "offset": 38,
261
+ "id": "43154",
262
+ "name": "Alcoholic beverage, wine, cooking"
263
+ },
264
+ {
265
+ "offset": 39,
266
+ "id": "14536",
267
+ "name": "Alcoholic beverage, wine, dessert, dry"
268
+ },
269
+ {
270
+ "offset": 40,
271
+ "id": "14057",
272
+ "name": "Alcoholic beverage, wine, dessert, sweet"
273
+ },
274
+ {
275
+ "offset": 41,
276
+ "id": "43155",
277
+ "name": "Alcoholic beverage, wine, light"
278
+ },
279
+ {
280
+ "offset": 42,
281
+ "id": "14084",
282
+ "name": "Alcoholic beverage, wine, table, all"
283
+ },
284
+ {
285
+ "offset": 43,
286
+ "id": "14096",
287
+ "name": "Alcoholic beverage, wine, table, red"
288
+ },
289
+ {
290
+ "offset": 44,
291
+ "id": "14101",
292
+ "name": "Alcoholic Beverage, wine, table, red, Barbera"
293
+ },
294
+ {
295
+ "offset": 45,
296
+ "id": "14152",
297
+ "name": "Alcoholic Beverage, wine, table, red, Burgundy"
298
+ },
299
+ {
300
+ "offset": 46,
301
+ "id": "14098",
302
+ "name": "Alcoholic Beverage, wine, table, red, Cabernet Franc"
303
+ },
304
+ {
305
+ "offset": 47,
306
+ "id": "14097",
307
+ "name": "Alcoholic Beverage, wine, table, red, Cabernet Sauvignon"
308
+ },
309
+ {
310
+ "offset": 48,
311
+ "id": "14109",
312
+ "name": "Alcoholic Beverage, wine, table, red, Carignane"
313
+ },
314
+ {
315
+ "offset": 49,
316
+ "id": "14105",
317
+ "name": "Alcoholic Beverage, wine, table, red, Claret"
318
+ },
319
+ {
320
+ "offset": 50,
321
+ "id": "14158",
322
+ "name": "Alcoholic Beverage, wine, table, red, Gamay"
323
+ },
324
+ {
325
+ "offset": 51,
326
+ "id": "14107",
327
+ "name": "Alcoholic Beverage, wine, table, red, Lemberger"
328
+ },
329
+ {
330
+ "offset": 52,
331
+ "id": "14602",
332
+ "name": "Alcoholic Beverage, wine, table, red, Merlot"
333
+ },
334
+ {
335
+ "offset": 53,
336
+ "id": "14159",
337
+ "name": "Alcoholic Beverage, wine, table, red, Mouvedre"
338
+ },
339
+ {
340
+ "offset": 54,
341
+ "id": "14103",
342
+ "name": "Alcoholic Beverage, wine, table, red, Petite Sirah"
343
+ },
344
+ {
345
+ "offset": 55,
346
+ "id": "14099",
347
+ "name": "Alcoholic Beverage, wine, table, red, Pinot Noir"
348
+ },
349
+ {
350
+ "offset": 56,
351
+ "id": "14108",
352
+ "name": "Alcoholic Beverage, wine, table, red, Sangiovese"
353
+ },
354
+ {
355
+ "offset": 57,
356
+ "id": "14100",
357
+ "name": "Alcoholic Beverage, wine, table, red, Syrah"
358
+ },
359
+ {
360
+ "offset": 58,
361
+ "id": "14102",
362
+ "name": "Alcoholic Beverage, wine, table, red, Zinfandel"
363
+ },
364
+ {
365
+ "offset": 59,
366
+ "id": "14106",
367
+ "name": "Alcoholic beverage, wine, table, white"
368
+ },
369
+ {
370
+ "offset": 60,
371
+ "id": "14160",
372
+ "name": "Alcoholic beverage, wine, table, white, Chardonnay"
373
+ },
374
+ {
375
+ "offset": 61,
376
+ "id": "14116",
377
+ "name": "Alcoholic beverage, wine, table, white, Chenin Blanc"
378
+ },
379
+ {
380
+ "offset": 62,
381
+ "id": "14117",
382
+ "name": "Alcoholic beverage, wine, table, white, Fume Blanc"
383
+ },
384
+ {
385
+ "offset": 63,
386
+ "id": "14124",
387
+ "name": "Alcoholic beverage, wine, table, white, Gewurztraminer"
388
+ },
389
+ {
390
+ "offset": 64,
391
+ "id": "14135",
392
+ "name": "Alcoholic beverage, wine, table, white, late harvest"
393
+ },
394
+ {
395
+ "offset": 65,
396
+ "id": "14125",
397
+ "name": "Alcoholic beverage, wine, table, white, late harvest, Gewurztraminer"
398
+ },
399
+ {
400
+ "offset": 66,
401
+ "id": "14120",
402
+ "name": "Alcoholic beverage, wine, table, white, Muller Thurgau"
403
+ },
404
+ {
405
+ "offset": 67,
406
+ "id": "14140",
407
+ "name": "Alcoholic beverage, wine, table, white, Muscat"
408
+ },
409
+ {
410
+ "offset": 68,
411
+ "id": "14138",
412
+ "name": "Alcoholic beverage, wine, table, white, Pinot Blanc"
413
+ },
414
+ {
415
+ "offset": 69,
416
+ "id": "14113",
417
+ "name": "Alcoholic beverage, wine, table, white, Pinot Gris (Grigio)"
418
+ },
419
+ {
420
+ "offset": 70,
421
+ "id": "14132",
422
+ "name": "Alcoholic beverage, wine, table, white, Riesling"
423
+ },
424
+ {
425
+ "offset": 71,
426
+ "id": "14134",
427
+ "name": "Alcoholic beverage, wine, table, white, Sauvignon Blanc"
428
+ },
429
+ {
430
+ "offset": 72,
431
+ "id": "14126",
432
+ "name": "Alcoholic beverage, wine, table, white, Semillon"
433
+ },
434
+ {
435
+ "offset": 73,
436
+ "id": "11001",
437
+ "name": "Alfalfa seeds, sprouted, raw"
438
+ },
439
+ {
440
+ "offset": 74,
441
+ "id": "20002",
442
+ "name": "Amaranth grain, cooked"
443
+ },
444
+ {
445
+ "offset": 75,
446
+ "id": "20001",
447
+ "name": "Amaranth grain, uncooked"
448
+ },
449
+ {
450
+ "offset": 76,
451
+ "id": "11700",
452
+ "name": "Amaranth leaves, cooked, boiled, drained, with salt"
453
+ },
454
+ {
455
+ "offset": 77,
456
+ "id": "11004",
457
+ "name": "Amaranth leaves, cooked, boiled, drained, without salt"
458
+ },
459
+ {
460
+ "offset": 78,
461
+ "id": "11003",
462
+ "name": "Amaranth leaves, raw"
463
+ },
464
+ {
465
+ "offset": 79,
466
+ "id": "04609",
467
+ "name": "Animal fat, bacon grease"
468
+ },
469
+ {
470
+ "offset": 80,
471
+ "id": "09400",
472
+ "name": "Apple juice, canned or bottled, unsweetened, with added ascorbic acid"
473
+ },
474
+ {
475
+ "offset": 81,
476
+ "id": "09517",
477
+ "name": "Apple juice, canned or bottled, unsweetened, with added ascorbic acid, calcium, and potassium"
478
+ },
479
+ {
480
+ "offset": 82,
481
+ "id": "09016",
482
+ "name": "Apple juice, canned or bottled, unsweetened, without added ascorbic acid"
483
+ },
484
+ {
485
+ "offset": 83,
486
+ "id": "09018",
487
+ "name": "Apple juice, frozen concentrate, unsweetened, diluted with 3 volume water without added ascorbic acid"
488
+ },
489
+ {
490
+ "offset": 84,
491
+ "id": "09411",
492
+ "name": "Apple juice, frozen concentrate, unsweetened, diluted with 3 volume water, with added ascorbic acid"
493
+ },
494
+ {
495
+ "offset": 85,
496
+ "id": "09410",
497
+ "name": "Apple juice, frozen concentrate, unsweetened, undiluted, with added ascorbic acid"
498
+ },
499
+ {
500
+ "offset": 86,
501
+ "id": "09017",
502
+ "name": "Apple juice, frozen concentrate, unsweetened, undiluted, without added ascorbic acid"
503
+ },
504
+ {
505
+ "offset": 87,
506
+ "id": "36000",
507
+ "name": "APPLEBEE'S, 9 oz house sirloin steak"
508
+ },
509
+ {
510
+ "offset": 88,
511
+ "id": "36023",
512
+ "name": "APPLEBEE'S, chicken tenders platter"
513
+ },
514
+ {
515
+ "offset": 89,
516
+ "id": "36005",
517
+ "name": "APPLEBEE'S, chicken tenders, from kids' menu"
518
+ },
519
+ {
520
+ "offset": 90,
521
+ "id": "36019",
522
+ "name": "APPLEBEE'S, chili"
523
+ },
524
+ {
525
+ "offset": 91,
526
+ "id": "36021",
527
+ "name": "APPLEBEE'S, coleslaw"
528
+ },
529
+ {
530
+ "offset": 92,
531
+ "id": "36022",
532
+ "name": "APPLEBEE'S, crunchy onion rings"
533
+ },
534
+ {
535
+ "offset": 93,
536
+ "id": "36001",
537
+ "name": "APPLEBEE'S, Double Crunch Shrimp"
538
+ },
539
+ {
540
+ "offset": 94,
541
+ "id": "36018",
542
+ "name": "APPLEBEE'S, fish, hand battered"
543
+ },
544
+ {
545
+ "offset": 95,
546
+ "id": "36002",
547
+ "name": "APPLEBEE'S, french fries"
548
+ },
549
+ {
550
+ "offset": 96,
551
+ "id": "36003",
552
+ "name": "APPLEBEE'S, KRAFT, Macaroni & Cheese, from kid's menu"
553
+ },
554
+ {
555
+ "offset": 97,
556
+ "id": "36004",
557
+ "name": "APPLEBEE'S, mozzarella sticks"
558
+ },
559
+ {
560
+ "offset": 98,
561
+ "id": "09008",
562
+ "name": "Apples, canned, sweetened, sliced, drained, heated"
563
+ },
564
+ {
565
+ "offset": 99,
566
+ "id": "09007",
567
+ "name": "Apples, canned, sweetened, sliced, drained, unheated"
568
+ }
569
+ ]
570
+ }
571
+ }
572
+ http_version:
573
+ recorded_at: Sun, 27 Sep 2015 00:52:09 GMT
574
+ recorded_with: VCR 2.9.3