-
Notifications
You must be signed in to change notification settings - Fork 1
/
yeasts.cljc
466 lines (342 loc) · 15.2 KB
/
yeasts.cljc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
(ns common-beer-format.yeasts
"The definition of a yeast record used in BeerXML."
{:added "2.0"}
(:require [clojure.spec.alpha :as spec]
[common-beer-format.impl :as impl]
[common-beer-format.primitives :as prim]
[spec-tools.core :as st])
(:refer-clojure :exclude [name type]))
(def yeast
"A map representing the yeast used during the mash and for top-up."
:yeast)
(def yeasts
"A vector of yeast records."
:yeasts)
(def name
"The name of the yeast record."
:name)
(def version
"The version of the BeerXML specification used to create the yeast record."
:version)
(def amount
"The amount of yeast in liters or kilograms.
Depends upon `:amount-is-weight`."
:amount)
(def type
"The type of yeast, usually categorized by the intended beverage or style.
Currently, the following types are supported:
- `ale` - Yeast that ferments at higher temperatures and produces a more fruity, estery, and alcohol-forward beer.
- `lager` - Yeast that ferments at lower temperatures and produces a crisp, clean, and alcohol-restrained beer.
- `wheat` - Yeast that ferments at higher temperatures and produces a fruity and phenol-forward beer.
- `wine` - Yeast traditionally used in wine making.
- `champagne` - Yeast traditionally used in champagne making, offering a dry taste."
:type)
(def ale
"Yeast that ferments at higher temperatures and produces a more fruity, estery, and alcohol-forward beer."
"Ale")
(def lager
"Yeast that ferments at lower temperatures and produces a crisp, clean, and alcohol-restrained beer."
"Lager")
(def wheat
"Yeast that ferments at higher temperatures and produces a fruity and phenol-forward beer."
"Wheat")
(def wine
"Yeast traditionally used in wine making."
"Wine")
(def champagne
"Yeast traditionally used in champagne making, offering a dry taste."
"Champagne")
(def yeast-types
"The allowed values for the `:type` of yeast used to ferment the beer."
#{ale
lager
wheat
wine
champagne})
(def form
"The form of the yeast added to the beer.
Currently, the following forms are supported:
- `liquid` - A liquid slurry of yeast, usually with a source of nutrients or sugars.
- `dry` - Dry yeast sold in a dehydrated state to extend shelf life.
- `slant` - Yeast cultivated on a solid growth medium.
- `culture` - Yeast cultivated from previous fermentations."
:form)
(def liquid
"A liquid slurry of yeast, usually with a source of nutrients or sugars."
"Liquid")
(def dry
"Dry yeast sold in a dehydrated state to extend shelf life."
"Dry")
(def slant
"Yeast cultivated on a solid growth medium."
"Slant")
(def culture
"Yeast cultivated from previous fermentations."
"Culture")
(spec/def ::type
(st/spec
{:type :string
:spec yeast-types
impl/beer-xml-type-key impl/beer-xml-list
:gen #(spec/gen yeast-types)
:description (impl/multiline
"A case-sensitive string representing the type of yeast added to the beer."
(impl/set->description yeast-types)
""
"- Ale: Yeast that ferments at higher temperatures and produces a more fruity, estery, and alcohol-forward beer."
"- Lager: Yeast that ferments at lower temperatures and produces a crisp, clean, and alcohol-restrained beer."
"- Wheat: Yeast that ferments at higher temperatures and produces a fruity and phenol-forward beer."
"- Wine: Yeast traditionally used in wine making."
"- Champagne: Yeast traditionally used in champagne making, offering a dry taste.")
:json-schema/example "Ale"}))
(def yeast-forms
"The allowed values for the `:form` of yeast used to ferment the beer."
#{liquid
dry
slant
culture})
(def amount-is-weight
"A boolean value indicating whether the `:amount` is in kilograms or liters."
:amount-is-weight)
(def laboratory
"The laboratory that cultivated the yeast."
:laboratory)
(def product-id
"The product label or id number that identifies the strain of yeast."
:product-id)
(def min-temperature
"The minimum recommended temperature of fermentation."
:min-temperature)
(def max-temperature
"The maximum recommended temperature of fermentation."
:max-temperature)
(def flocculation
"The rate at which the yeast settles out of suspension.
Currently, the following flocculation types are supported:
- `low` - The yeast settles out of suspension slowly.
- `medium` - The yeast settles out of suspension at a moderate rate.
- `high` - The yeast settles out of suspension quickly.
- `very high` - The yeast settles out of suspension very quickly."
:flocculation)
(def low
"The yeast settles out of suspension slowly."
"Low")
(def medium
"The yeast settles out of suspension at a moderate rate."
"Medium")
(def high
"The yeast settles out of suspension quickly."
"High")
(def very-high
"The yeast settles out of suspension very quickly."
"Very High")
(def attenuation
"The percentage of sugars that are typically converted to alcohol during fermentation."
:attenuation)
(def notes
"A free-form text field for recording any additional information about the yeast."
:notes)
(def best-for
"A free-form text field for denoting styles the yeast is best suited for."
:best-for)
(def times-cultured
"The number of times the yeast has been cultured."
:times-cultured)
(def max-reuse
"A suggestion of the maximum number of times the yeast can be cultured."
:max-reuse)
(def add-to-secondary
"A boolean value indicating whether the yeast should be added to the secondary fermentation."
:add-to-secondary)
(def display-amount
"A human-readable string representing the amount of yeast added to the beer."
:display-amount)
(def disp-min-temp
"A human-readable string representing the minimum recommended temperature of fermentation."
:disp-min-temp)
(def disp-max-temp
"A human-readable string representing the maximum recommended temperature of fermentation."
:disp-max-temp)
(def inventory
"A map containing information about the yeast on hand in inventory."
:inventory)
(def culture-date
"A non-empty string denoting a display value for the date the yeast sample was last cultured formatted for display in arbitrary structure"
:culture-date)
(spec/def ::form
(st/spec
{:type :string
:spec yeast-forms
impl/beer-xml-type-key impl/beer-xml-list
:gen #(spec/gen yeast-forms)
:description (impl/multiline
"A case-sensitive string representing the form of the yeast added to the beer."
(impl/set->description yeast-forms)
""
"- Liquid: A liquid slurry of yeast, usually with a source of nutrients or sugars."
"- Dry: Dry yeast sold in a dehydrated state to extend shelf life."
"- Slant: Yeast cultivated on a solid growth medium."
"- Culture: Yeast cultivated from previous fermentations.")
:json-schema/example "Ale"}))
(spec/def ::laboratory
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting the laboratory that cultivated the yeast."
:json-schema/example "White Labs"}))
(spec/def ::product-id
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting the product label or id number that identifies the strain of yeast."
:json-schema/example "WLP008"}))
(spec/def ::min-temperature
(st/spec
{:type :double
:spec ::prim/degrees-celsius
impl/display-name-key "Minimum Temperature"
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-degrees-celsius
:description "An IEEE-754 floating point number representing the minimum recommended temperature of fermentation."
:json-schema/example 19.5}))
(spec/def ::max-temperature
(st/spec
{:type :double
:spec ::prim/degrees-celsius
impl/display-name-key "Maximum Temperature"
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-degrees-celsius
:description "An IEEE-754 floating point number representing the maximum recommended temperature of fermentation."
:json-schema/example 23.9}))
(def yeast-flocculation-types
"The allowed values for the `:flocculation` of yeast used to ferment the beer."
#{low
medium
high
very-high})
(spec/def ::flocculation
(st/spec
{:type :string
:spec yeast-flocculation-types
impl/beer-xml-type-key impl/beer-xml-list
:gen #(spec/gen yeast-flocculation-types)
:description (impl/multiline "A case-sensitive string representing how dense of a floc the yeast will form."
(impl/set->description yeast-flocculation-types)
""
"- Low: The yeast settles out of suspension slowly."
"- Medium: The yeast settles out of suspension at a moderate rate."
"- High: The yeast settles out of suspension quickly."
"- Very High: The yeast settles out of suspension very quickly.")
:json-schema/example "High"}))
(spec/def ::attenuation
(st/spec
{:type :double
:spec ::prim/percent
impl/beer-xml-type-key impl/beer-xml-percentage
:description "A positive IEEE-754 floating point number representing the percent of malt sugar that can be converted to ethanol and carbon dioxide."
:json-schema/example 73.2}))
(spec/def ::best-for
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting the styles of beer this yeast is best suited for."
:json-schema/example "WLP008"}))
(spec/def ::times-cultured
(st/spec
{:type :long
:spec (spec/and int? pos?)
impl/beer-xml-type-key impl/beer-xml-integer
:description (impl/multiline
"A non-negative integer representing the number of times this yeast has been harvested and re-used."
"A value of zero assumes the yeast came directly from the manufacturer.")
:json-schema/example 1}))
(spec/def ::max-reuse
(st/spec
{:type :long
:spec (spec/and int? pos?)
impl/beer-xml-type-key impl/beer-xml-integer
:description "A non-negative integer representing the suggested maximum number of times the yeast may be harvested and recultured."
:json-schema/example 3}))
(spec/def ::add-to-secondary
(st/spec
{:spec ::prim/boolean
impl/beer-xml-type-key impl/beer-xml-boolean
:description (impl/multiline
"A boolean representing if this yeast was added for a secondary fermentation."
"When absent, assume false.")
:json-schema/example false
:decode/string impl/decode-boolean
:encode/string impl/encode-boolean}))
(spec/def ::disp-min-temp
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
impl/display-name-key "Display Minimum Temperature"
:description "A non-empty string denoting a display value for the minimum fermentation temperature formatted for display in arbitrary units."
:json-schema/example "68F"}))
(spec/def ::disp-max-temp
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
impl/display-name-key "Display Maximum Temperature"
:description "A non-empty string denoting a display value for the maximum fermentation temperature formatted for display in arbitrary units."
:json-schema/example "75F"}))
(spec/def ::culture-date
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting a display value for the date the yeast sample was last cultured formatted for display in arbitrary structure."
:json-schema/example "10/10/2020"}))
(spec/def ::yeast
(st/spec
{:type :map
:description "A record representing the yeast in a beer recipe."
:spec (spec/keys :req-un [::prim/name
::prim/version
::type
::form
::prim/amount]
:opt-un [::prim/amount-is-weight
::laboratory
::product-id
::min-temperature
::max-temperature
::flocculation
::attenuation
::prim/notes
::best-for
::times-cultured
::max-reuse
::add-to-secondary
::prim/display-amount
::disp-min-temp
::disp-max-temp
::prim/inventory
::culture-date])}))
(spec/def ::yeast-wrapper
(st/spec
{:type :map
impl/wrapper-spec-key true
impl/beer-xml-type-key impl/beer-xml-record
:description "A `::yeast` record wrapped in a `:yeast` map."
:spec (spec/keys :req-un [::yeast])}))
(spec/def ::yeasts
(st/spec
{:type :vector
:description "A vector of valid `::yeast` records."
:spec (spec/coll-of ::yeast-wrapper :into [] :kind vector?)
:decode/string #(impl/decode-sequence %1 ::yeast-wrapper %2)
:encode/string #(impl/encode-sequence %1 ::yeast-wrapper %2)}))
(spec/def ::yeasts-wrapper
(st/spec
{:type :map
impl/wrapper-spec-key true
impl/beer-xml-type-key impl/beer-xml-record-set
:description "A `::yeasts-wrapper` record set."
:spec (spec/keys :req-un [::yeasts])}))