mat 0.0.2 → 0.0.3
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 +89 -1
- data/bin/mat +2 -17
- data/lib/mat.rb +1 -1
- data/lib/mat/cli.rb +26 -0
- data/lib/mat/version.rb +1 -1
- data/mat.gemspec +1 -1
- data/spec/fixtures/nutrient.json +302 -0
- data/spec/mat/api/config_spec.rb +40 -0
- data/spec/mat/cli_spec.rb +35 -0
- data/spec/mat/nutrient_spec.rb +35 -0
- data/spec/mat_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -1
- metadata +12 -6
- data/spec/fixtures/foodstuff/24_nutrient_carbohydrates.json +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fd6c2b0fb8fda922ff65602717a64bc5236002f
|
4
|
+
data.tar.gz: 055392b1f18446daf417c4ba2c844b94082f7feb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: badf4f8eaf1aa52286bfdde3bf8debcc816f33713c36689018287b1613f9d4e4a6f58bc0fbdcc3afc9688b0acc2e00e1ea5df31e9ef9e4383bd5ec4ea37b40c8
|
7
|
+
data.tar.gz: 3d4872e3e73e3a27604070b314ec29241629b55c14373e91c2815f7b9b6d55953481538a6b6c49b41e3ebb3253788b4a101241f88b7c4d202319559060ea702c
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ food = Mat.all('Köttfärs').first
|
|
31
31
|
# You can also pass a search query to the find method
|
32
32
|
food = Mat.find('Köttfärs')
|
33
33
|
|
34
|
-
# Get the `iron` value
|
34
|
+
# Get the `iron` value (method_missing is used to retrieve each nutrient)
|
35
35
|
food.iron #=> 1.09
|
36
36
|
|
37
37
|
# Find a specific food by its number
|
@@ -42,6 +42,94 @@ food.name #=> "Ister gris"
|
|
42
42
|
Mat.nutrients
|
43
43
|
```
|
44
44
|
|
45
|
+
### CLI
|
46
|
+
|
47
|
+
This gem comes with a simple command line interface.
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
# Finding foodstuff by its number
|
51
|
+
$ mat 55
|
52
|
+
{
|
53
|
+
"name": "Mimosasallad",
|
54
|
+
"number": 55,
|
55
|
+
"nutrientValues": {
|
56
|
+
"energyKj": 651,
|
57
|
+
"energyKcal": 156,
|
58
|
+
"protein": 2.4,
|
59
|
+
"fat": 12,
|
60
|
+
"carbohydrates": 8.9,
|
61
|
+
"fibres": 1.8,
|
62
|
+
"salt": 0.1,
|
63
|
+
"ash": 0.6,
|
64
|
+
"water": 74.2,
|
65
|
+
"alcohol": 0,
|
66
|
+
"monosaccharides": 3.3,
|
67
|
+
"disaccharides": 4.5,
|
68
|
+
"saccharose": 4.2,
|
69
|
+
"wholegrain": 0,
|
70
|
+
"saturatedFattyAcids": 3.8,
|
71
|
+
"fattyAcid40100": 0.5,
|
72
|
+
"fattyAcid120": 0.1,
|
73
|
+
"fattyAcid140": 0.5,
|
74
|
+
"fattyAcid160": 1.9,
|
75
|
+
"fattyAcid180": 0.7,
|
76
|
+
"fattyAcid200": 0,
|
77
|
+
"monounsaturatedFattyAcids": 2.6,
|
78
|
+
"fattyAcid161": 0.1,
|
79
|
+
"fattyAcid181": 2.5,
|
80
|
+
"sumPolyunsaturatedFattyAcids": 4.4,
|
81
|
+
"n6FattyAcids": 0.1,
|
82
|
+
"fattyAcid182": 3.9,
|
83
|
+
"fattyAcid204": 0,
|
84
|
+
"n3FattyAcids": 0,
|
85
|
+
"fattyAcid183": 0.5,
|
86
|
+
"longN3FattyAcids": 0,
|
87
|
+
"epa": 0,
|
88
|
+
"dpa": 0,
|
89
|
+
"dha": 0,
|
90
|
+
"transFattyAcids": 0.1,
|
91
|
+
"cholesterol": 50.3,
|
92
|
+
"retinolEquivalents": 76,
|
93
|
+
"retinol": 68,
|
94
|
+
"betacarotene": 92,
|
95
|
+
"vitaminD": 0.15,
|
96
|
+
"vitaminE": 1.24,
|
97
|
+
"vitaminK": 3,
|
98
|
+
"timamine": 0.09,
|
99
|
+
"riboflavin": 0.1,
|
100
|
+
"vitaminC": 12,
|
101
|
+
"niacin": 0.5,
|
102
|
+
"niacinEquivalents": 1,
|
103
|
+
"vitaminB6": 0.1,
|
104
|
+
"vitaminB12": 0.23,
|
105
|
+
"phosphorous": 55,
|
106
|
+
"folate": 23,
|
107
|
+
"iodine": 4,
|
108
|
+
"trash": 17,
|
109
|
+
"iron": 0.54,
|
110
|
+
"calcium": 31,
|
111
|
+
"potassium": 199,
|
112
|
+
"magnesium": 13,
|
113
|
+
"sodium": 45,
|
114
|
+
"selenium": 2.3,
|
115
|
+
"zink": 0.4
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
# You can also search for foodstuff
|
120
|
+
$ mat hasselnötter
|
121
|
+
[
|
122
|
+
{
|
123
|
+
"name": "Hasselnötter",
|
124
|
+
"number": 1558
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"name": "Mjölkchoklad m hackade hasselnötter Schweizernöt",
|
128
|
+
"number": 1848
|
129
|
+
}
|
130
|
+
]
|
131
|
+
```
|
132
|
+
|
45
133
|
## Contributing
|
46
134
|
|
47
135
|
1. Fork it
|
data/bin/mat
CHANGED
@@ -1,20 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
require 'json'
|
3
|
+
require_relative '../lib/mat/cli'
|
5
4
|
|
6
|
-
|
7
|
-
if query.match(/^\d+$/)
|
8
|
-
Mat.api.foodstuff(query)
|
9
|
-
else
|
10
|
-
Mat.api.foodstuffs(query)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def search(query)
|
15
|
-
puts JSON.pretty_generate get_data(query)
|
16
|
-
rescue Mat::HTTP::Exception
|
17
|
-
warn "Nothing found"
|
18
|
-
end
|
19
|
-
|
20
|
-
search(ARGV.first) if ARGV.any?
|
5
|
+
Mat::CLI.search(ARGV.first) if ARGV.any?
|
data/lib/mat.rb
CHANGED
data/lib/mat/cli.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../mat'
|
4
|
+
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module Mat
|
8
|
+
class CLI
|
9
|
+
class << self
|
10
|
+
def get_data(query)
|
11
|
+
if query.to_s.match(/^\d+$/)
|
12
|
+
Mat.api.foodstuff(query)
|
13
|
+
else
|
14
|
+
Mat.api.foodstuffs(query)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def search(query)
|
19
|
+
puts JSON.pretty_generate get_data(query)
|
20
|
+
rescue Mat::HTTP::Exception
|
21
|
+
warn "Nothing found"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
data/lib/mat/version.rb
CHANGED
data/mat.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
-
spec.add_development_dependency "minitest", "~>
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
26
26
|
spec.add_development_dependency "rake"
|
27
27
|
spec.add_development_dependency "pry"
|
28
28
|
end
|
@@ -0,0 +1,302 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"slug": "alcohol",
|
4
|
+
"name": "Alcohol",
|
5
|
+
"unit": "g"
|
6
|
+
},
|
7
|
+
{
|
8
|
+
"slug": "ash",
|
9
|
+
"name": "Ash",
|
10
|
+
"unit": "g"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"slug": "betacarotene",
|
14
|
+
"name": "Betacarotene",
|
15
|
+
"unit": "ug"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"slug": "calcium",
|
19
|
+
"name": "Calcium",
|
20
|
+
"unit": "mg"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"slug": "carbohydrates",
|
24
|
+
"name": "Carbohydrates",
|
25
|
+
"unit": "g"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"slug": "cholesterol",
|
29
|
+
"name": "Cholesterol",
|
30
|
+
"unit": "mg"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"slug": "dha",
|
34
|
+
"name": "DHA (fatty acid 22:6)",
|
35
|
+
"unit": "g"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"slug": "disaccharides",
|
39
|
+
"name": "Disaccharides",
|
40
|
+
"unit": "g"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"slug": "dpa",
|
44
|
+
"name": "DPA (fatty acid 22:5)",
|
45
|
+
"unit": "g"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"slug": "energyKcal",
|
49
|
+
"name": "Energy kCal",
|
50
|
+
"unit": "kcal"
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"slug": "energyKj",
|
54
|
+
"name": "Energy kJ",
|
55
|
+
"unit": "kj"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"slug": "epa",
|
59
|
+
"name": "EPA (fatty acid 20:5)",
|
60
|
+
"unit": "g"
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"slug": "fat",
|
64
|
+
"name": "Fat",
|
65
|
+
"unit": "g"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"slug": "fattyAcid120",
|
69
|
+
"name": "Fatty acid 12:0",
|
70
|
+
"unit": "g"
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"slug": "fattyAcid140",
|
74
|
+
"name": "Fatty acid 14:0",
|
75
|
+
"unit": "g"
|
76
|
+
},
|
77
|
+
{
|
78
|
+
"slug": "fattyAcid160",
|
79
|
+
"name": "Fatty acid 16:0",
|
80
|
+
"unit": "g"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"slug": "fattyAcid161",
|
84
|
+
"name": "Fatty acid 16:1",
|
85
|
+
"unit": "g"
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"slug": "fattyAcid180",
|
89
|
+
"name": "Fatty acid 18:0",
|
90
|
+
"unit": "g"
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"slug": "fattyAcid181",
|
94
|
+
"name": "Fatty acid 18:1",
|
95
|
+
"unit": "g"
|
96
|
+
},
|
97
|
+
{
|
98
|
+
"slug": "fattyAcid182",
|
99
|
+
"name": "Fatty acid 18:2",
|
100
|
+
"unit": "g"
|
101
|
+
},
|
102
|
+
{
|
103
|
+
"slug": "fattyAcid183",
|
104
|
+
"name": "Fatty acid 18:3",
|
105
|
+
"unit": "g"
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"slug": "fattyAcid200",
|
109
|
+
"name": "Fatty acid 20:0",
|
110
|
+
"unit": "g"
|
111
|
+
},
|
112
|
+
{
|
113
|
+
"slug": "fattyAcid204",
|
114
|
+
"name": "Fatty acid 20:4",
|
115
|
+
"unit": "g"
|
116
|
+
},
|
117
|
+
{
|
118
|
+
"slug": "fattyAcid40100",
|
119
|
+
"name": "Fatty acid 4:0-10:0",
|
120
|
+
"unit": "g"
|
121
|
+
},
|
122
|
+
{
|
123
|
+
"slug": "fibres",
|
124
|
+
"name": "Fibres",
|
125
|
+
"unit": "g"
|
126
|
+
},
|
127
|
+
{
|
128
|
+
"slug": "folate",
|
129
|
+
"name": "Folate",
|
130
|
+
"unit": "ug"
|
131
|
+
},
|
132
|
+
{
|
133
|
+
"slug": "iodine",
|
134
|
+
"name": "Iodine",
|
135
|
+
"unit": "ug"
|
136
|
+
},
|
137
|
+
{
|
138
|
+
"slug": "iron",
|
139
|
+
"name": "Iron",
|
140
|
+
"unit": "mg"
|
141
|
+
},
|
142
|
+
{
|
143
|
+
"slug": "longN3FattyAcids",
|
144
|
+
"name": "Sum long n-3 fatty acids",
|
145
|
+
"unit": "g"
|
146
|
+
},
|
147
|
+
{
|
148
|
+
"slug": "magnesium",
|
149
|
+
"name": "Magnesium",
|
150
|
+
"unit": "mg"
|
151
|
+
},
|
152
|
+
{
|
153
|
+
"slug": "monosaccharides",
|
154
|
+
"name": "Monosaccharides",
|
155
|
+
"unit": "g"
|
156
|
+
},
|
157
|
+
{
|
158
|
+
"slug": "monounsaturatedFattyAcids",
|
159
|
+
"name": "Sum monounsaturated fatty acids",
|
160
|
+
"unit": "g"
|
161
|
+
},
|
162
|
+
{
|
163
|
+
"slug": "n3FattyAcids",
|
164
|
+
"name": "Sum n-3 fatty acids",
|
165
|
+
"unit": "g"
|
166
|
+
},
|
167
|
+
{
|
168
|
+
"slug": "n6FattyAcids",
|
169
|
+
"name": "Sum n-6 fatty acids",
|
170
|
+
"unit": "g"
|
171
|
+
},
|
172
|
+
{
|
173
|
+
"slug": "niacin",
|
174
|
+
"name": "Niacin",
|
175
|
+
"unit": "mg"
|
176
|
+
},
|
177
|
+
{
|
178
|
+
"slug": "niacinEquivalents",
|
179
|
+
"name": "Niacin equivalents",
|
180
|
+
"unit": ""
|
181
|
+
},
|
182
|
+
{
|
183
|
+
"slug": "phosphorous",
|
184
|
+
"name": "Phosphorous",
|
185
|
+
"unit": "mg"
|
186
|
+
},
|
187
|
+
{
|
188
|
+
"slug": "potassium",
|
189
|
+
"name": "Potassium",
|
190
|
+
"unit": "mg"
|
191
|
+
},
|
192
|
+
{
|
193
|
+
"slug": "protein",
|
194
|
+
"name": "Protein",
|
195
|
+
"unit": "g"
|
196
|
+
},
|
197
|
+
{
|
198
|
+
"slug": "retinol",
|
199
|
+
"name": "Retinol",
|
200
|
+
"unit": "ug"
|
201
|
+
},
|
202
|
+
{
|
203
|
+
"slug": "retinolEquivalents",
|
204
|
+
"name": "Retinol equivalents",
|
205
|
+
"unit": ""
|
206
|
+
},
|
207
|
+
{
|
208
|
+
"slug": "riboflavin",
|
209
|
+
"name": "Riboflavin",
|
210
|
+
"unit": "mg"
|
211
|
+
},
|
212
|
+
{
|
213
|
+
"slug": "saccharose",
|
214
|
+
"name": "Saccharose",
|
215
|
+
"unit": "g"
|
216
|
+
},
|
217
|
+
{
|
218
|
+
"slug": "salt",
|
219
|
+
"name": "Salt",
|
220
|
+
"unit": "g"
|
221
|
+
},
|
222
|
+
{
|
223
|
+
"slug": "saturatedFattyAcids",
|
224
|
+
"name": "Sum saturated fatty acids",
|
225
|
+
"unit": "g"
|
226
|
+
},
|
227
|
+
{
|
228
|
+
"slug": "selenium",
|
229
|
+
"name": "Selenium",
|
230
|
+
"unit": "ug"
|
231
|
+
},
|
232
|
+
{
|
233
|
+
"slug": "sodium",
|
234
|
+
"name": "Sodium",
|
235
|
+
"unit": "gm"
|
236
|
+
},
|
237
|
+
{
|
238
|
+
"slug": "sumPolyunsaturatedFattyAcids",
|
239
|
+
"name": "Sum polyunsaturated fatty acids",
|
240
|
+
"unit": "g"
|
241
|
+
},
|
242
|
+
{
|
243
|
+
"slug": "timamine",
|
244
|
+
"name": "Timamine",
|
245
|
+
"unit": "mg"
|
246
|
+
},
|
247
|
+
{
|
248
|
+
"slug": "transFattyAcids",
|
249
|
+
"name": "Sum trans fatty acids",
|
250
|
+
"unit": "g"
|
251
|
+
},
|
252
|
+
{
|
253
|
+
"slug": "trash",
|
254
|
+
"name": "trash",
|
255
|
+
"unit": "percentage"
|
256
|
+
},
|
257
|
+
{
|
258
|
+
"slug": "vitaminB12",
|
259
|
+
"name": "Vitamin B12",
|
260
|
+
"unit": "ug"
|
261
|
+
},
|
262
|
+
{
|
263
|
+
"slug": "vitaminB6",
|
264
|
+
"name": "Vitamin B6",
|
265
|
+
"unit": "mg"
|
266
|
+
},
|
267
|
+
{
|
268
|
+
"slug": "vitaminC",
|
269
|
+
"name": "Vitamin C",
|
270
|
+
"unit": "mg"
|
271
|
+
},
|
272
|
+
{
|
273
|
+
"slug": "vitaminD",
|
274
|
+
"name": "Vitamin D",
|
275
|
+
"unit": "ug"
|
276
|
+
},
|
277
|
+
{
|
278
|
+
"slug": "vitaminE",
|
279
|
+
"name": "Vitamin E",
|
280
|
+
"unit": "mg"
|
281
|
+
},
|
282
|
+
{
|
283
|
+
"slug": "vitaminK",
|
284
|
+
"name": "Vitamin K",
|
285
|
+
"unit": "ug"
|
286
|
+
},
|
287
|
+
{
|
288
|
+
"slug": "water",
|
289
|
+
"name": "Water",
|
290
|
+
"unit": "g"
|
291
|
+
},
|
292
|
+
{
|
293
|
+
"slug": "wholegrain",
|
294
|
+
"name": "Wholegrain sum",
|
295
|
+
"unit": "g"
|
296
|
+
},
|
297
|
+
{
|
298
|
+
"slug": "zink",
|
299
|
+
"name": "Zink",
|
300
|
+
"unit": "mg"
|
301
|
+
}
|
302
|
+
]
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../../spec_helper'
|
4
|
+
|
5
|
+
describe "Config" do
|
6
|
+
subject {
|
7
|
+
Mat::API::Config.new do |c|
|
8
|
+
c.base_url = base_url
|
9
|
+
end
|
10
|
+
}
|
11
|
+
|
12
|
+
let(:base_url) { 'http://config.test/' }
|
13
|
+
|
14
|
+
it "returns the base_url" do
|
15
|
+
subject.base_url.must_equal 'http://config.test/'
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "json_parser" do
|
19
|
+
it "is a lambda by default" do
|
20
|
+
subject.json_parser.
|
21
|
+
parse('{"foo":123}')['foo'].must_equal 123
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can be changed" do
|
25
|
+
subject.json_parser = "foo"
|
26
|
+
subject.json_parser.must_equal "foo"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "http_client" do
|
31
|
+
it "is Net::HTTP by default" do
|
32
|
+
subject.http_client.must_equal Mat::HTTP
|
33
|
+
end
|
34
|
+
|
35
|
+
it "can be changed" do
|
36
|
+
subject.http_client = "bar"
|
37
|
+
subject.http_client.must_equal "bar"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
|
5
|
+
describe Mat::CLI do
|
6
|
+
subject { Mat::CLI }
|
7
|
+
|
8
|
+
describe "get_data" do
|
9
|
+
it "finds foodstuff by number" do
|
10
|
+
Mat.api.stub(:foodstuff, "data") do
|
11
|
+
subject.get_data(123).must_equal "data"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "queries foodstuffs by name" do
|
16
|
+
Mat.api.stub(:foodstuffs, "search result") do
|
17
|
+
subject.get_data('Mjölk').must_equal "search result"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "search" do
|
23
|
+
it "pretty formats the returned JSON" do
|
24
|
+
subject.stub(:get_data, ->(q) { { foo:'bar' } }) do
|
25
|
+
->{ subject.search('foo') }.must_output "{\n \"foo\": \"bar\"\n}\n"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "prints a warning on exception" do
|
30
|
+
subject.stub(:get_data, ->(q){ raise Mat::HTTP::Exception }) do
|
31
|
+
->{ subject.search('foo') }.must_output nil, "Nothing found\n"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
|
5
|
+
describe Mat::Nutrient do
|
6
|
+
subject { Mat::Nutrient }
|
7
|
+
|
8
|
+
let(:fixture_data) { parsed_fixture('nutrient') }
|
9
|
+
let(:nutrients) { fixture_data.map { |d| subject.new(d) } }
|
10
|
+
let(:nutrient) { nutrients[4] }
|
11
|
+
|
12
|
+
describe "initialize" do
|
13
|
+
it "takes data as input" do
|
14
|
+
subject.new("foo").data.must_equal "foo"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "slug" do
|
19
|
+
it "returns the slug from the data" do
|
20
|
+
nutrient.slug.must_equal "carbohydrates"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "name" do
|
25
|
+
it "returns the name from the data" do
|
26
|
+
nutrient.name.must_equal "Carbohydrates"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "unit" do
|
31
|
+
it "returns the unit from the data" do
|
32
|
+
nutrient.unit.must_equal "g"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/mat_spec.rb
CHANGED
@@ -12,8 +12,8 @@ describe Mat do
|
|
12
12
|
api.config.base_url.must_equal "api.test"
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
16
|
-
subject.api.object_id.
|
15
|
+
it "memoizes the api client" do
|
16
|
+
subject.api.object_id.must_equal subject.api.object_id
|
17
17
|
end
|
18
18
|
|
19
19
|
it "can configure the base_url" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Hellberg
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '5.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '5.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +84,20 @@ files:
|
|
84
84
|
- lib/mat.rb
|
85
85
|
- lib/mat/api.rb
|
86
86
|
- lib/mat/api/config.rb
|
87
|
+
- lib/mat/cli.rb
|
87
88
|
- lib/mat/foodstuff.rb
|
88
89
|
- lib/mat/http.rb
|
89
90
|
- lib/mat/nutrient.rb
|
90
91
|
- lib/mat/version.rb
|
91
92
|
- mat.gemspec
|
92
|
-
- spec/fixtures/foodstuff/24_nutrient_carbohydrates.json
|
93
93
|
- spec/fixtures/foodstuff/44.json
|
94
|
+
- spec/fixtures/nutrient.json
|
95
|
+
- spec/mat/api/config_spec.rb
|
94
96
|
- spec/mat/api_spec.rb
|
97
|
+
- spec/mat/cli_spec.rb
|
95
98
|
- spec/mat/foodstuff_spec.rb
|
96
99
|
- spec/mat/http_spec.rb
|
100
|
+
- spec/mat/nutrient_spec.rb
|
97
101
|
- spec/mat/version_spec.rb
|
98
102
|
- spec/mat_spec.rb
|
99
103
|
- spec/spec_helper.rb
|
@@ -122,12 +126,14 @@ signing_key:
|
|
122
126
|
specification_version: 4
|
123
127
|
summary: A small API client for the Mat API
|
124
128
|
test_files:
|
125
|
-
- spec/fixtures/foodstuff/24_nutrient_carbohydrates.json
|
126
129
|
- spec/fixtures/foodstuff/44.json
|
130
|
+
- spec/fixtures/nutrient.json
|
131
|
+
- spec/mat/api/config_spec.rb
|
127
132
|
- spec/mat/api_spec.rb
|
133
|
+
- spec/mat/cli_spec.rb
|
128
134
|
- spec/mat/foodstuff_spec.rb
|
129
135
|
- spec/mat/http_spec.rb
|
136
|
+
- spec/mat/nutrient_spec.rb
|
130
137
|
- spec/mat/version_spec.rb
|
131
138
|
- spec/mat_spec.rb
|
132
139
|
- spec/spec_helper.rb
|
133
|
-
has_rdoc:
|