-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmash.cljc
513 lines (383 loc) · 17.7 KB
/
mash.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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
(ns common-beer-format.mash
"The definition of mash steps and the mash profile records 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 mash
"A record representing a mash profile."
:mash)
(def mash-step
"A record representing a mash-step."
:mash-step)
(def name
"The name of the mash step or mash profile."
:name)
(def version
"The version of the BeerXML specification used to create the mash step or mash profile."
:version)
(def type
"The type of mash step.
Currently, the following types are allowed:
- `decoction` - A mash step where the fermentable ingredients are boiled and then returned to the mash tun.
- `infusion` - A mash step where fermentable ingredients steep in water at a specific temperature.
- `temperature` - A mash step where the temperature of the mash is held at a specific temperature for a specific time by an external source."
:type)
(def infuse-amount
"The volume of water in liters required for an infusion step."
:infuse-amount)
(def step-temp
"The temperature of the mash step should be performed at in degrees Celsius."
:step-temp)
(def step-time
"The time in minutes to spend at this step."
:step-time)
(def ramp-time
"The time in minutes to achieve the desired step temperature."
:ramp-time)
(def end-temp
"The temperature of the mash after the step has completed."
:end-temp)
(def description
"A human-readable description of the mash step."
:description)
(def water-grain-ratio
"A display value for the water:grain ratio after infusion formatted for display in arbitrary units."
:water-grain-ratio)
(def decoction-amt
"A display value for the calculated volume of mash to decoct formatted for display in arbitrary units."
:decoction-amt)
(def infuse-temp
"A display value for the temperature of an infusion step formatted for display in arbitrary units."
:infuse-temp)
(def display-step-temp
"A display value for the temperature of the mash step formatted for display in arbitrary units."
:display-step-temp)
(def display-infuse-amt
"A display value for the volume of water in the mash step formatted for display in arbitrary units."
:display-infuse-amt)
(def decoction
"A mash step where the fermentable ingredients are boiled and then returned to the mash tun."
"Decoction")
(def infusion
"A mash step where fermentable ingredients steep in water at a specific temperature."
"Infusion")
(def temperature
"A mash step where the temperature of the mash is held at a specific temperature for a specific time by an external source."
"Temperature")
(def mash-step-types
"A set of allowed mash types.
Currently, the following types are allowed:
- `decoction` - A mash step where the fermentable ingredients are boiled and then returned to the mash tun.
- `infusion` - A mash step where fermentable ingredients steep in water at a specific temperature.
- `temperature` - A mash step where the temperature of the mash is held at a specific temperature for a specific time by an external source."
#{decoction
infusion
temperature})
(spec/def ::type
(st/spec
{:type :string
:spec mash-step-types
impl/beer-xml-type-key impl/beer-xml-list
:gen #(spec/gen mash-step-types)
:description (impl/multiline "A case-sensitive string representing the type of mash step."
(impl/set->description mash-step-types)
""
"- Decoction: A mash step where the fermentable ingredients are boiled and then returned to the mash tun."
"- Infusion: A mash step where fermentable ingredients steep in water at a specific temperature."
"- Temperature: A mash step where the temperature of the mash is held at a specific temperature for a specific time by an external source.")
:json-schema/example "Temperature"}))
(spec/def ::infuse-amount
(st/spec
{:type :double
:spec ::prim/liter
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-liter
:description "A non-negative IEEE-754 floating point number representing the volume of water in liters required for an infusion step."
:json-schema/example 5.8}))
(spec/def ::step-temp
(st/spec
{:type :double
impl/display-name-key "Step Temperature"
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-degrees-celsius
:spec ::prim/degrees-celsius
:description "A non-negative IEEE-754 floating point number representing the temperature of the mash step should be performed at in degrees Celsius."
:json-schema/example 80}))
(spec/def ::step-time
(st/spec
{:type :double
:spec ::prim/minute
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-minute
:description "A non-negative IEEE-754 floating point number representing the time in minutes to spend at this step."
:json-schema/example 45.0}))
(spec/def ::ramp-time
(st/spec
{:type :double
:spec ::prim/minute
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-minute
:description "A non-negative IEEE-754 floating point number representing the time in minutes to achieve the desired step temperature."
:json-schema/example 45.0}))
(spec/def ::end-temp
(st/spec
{:type :double
impl/display-name-key "End Temperature"
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-degrees-celsius
:spec ::prim/degrees-celsius
:description "A non-negative IEEE-754 floating point number representing the temperature of the mash after the step has completed in degrees Celsius."
:json-schema/example 80}))
(spec/def ::description
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string describing the mash step."
:json-schema/example "Stir your grain bag carefully at 140F."}))
(spec/def ::water-grain-ratio
(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 water:grain ratio after infusion formatted for display in arbitrary units."
:json-schema/example "1.5qt/lb"}))
(spec/def ::decoction-amt
(st/spec
{:type :string
impl/display-name-key "Decoction Amount"
impl/beer-xml-type-key impl/beer-xml-text
:spec ::prim/text
:description "A non-empty string denoting a display value for the calculated volume of mash to decoct formatted for display in arbitrary units."
:json-schema/example "7.5 liters"}))
(spec/def ::infuse-temp
(st/spec
{:type :string
impl/display-name-key "Infusion Temperature"
impl/beer-xml-type-key impl/beer-xml-text
:spec ::prim/text
:description "A non-empty string denoting a display value for the temperature of an infusion step formatted for display in arbitrary units."
:json-schema/example "150F"}))
(spec/def ::display-step-temp
(st/spec
{:type :string
impl/display-name-key "Display Step Temperature"
impl/beer-xml-type-key impl/beer-xml-text
:spec ::prim/text
:description "A non-empty string denoting a display value for the temperature of an arbitrary step formatted for display in arbitrary units."
:json-schema/example "150F"}))
(spec/def ::display-infuse-amt
(st/spec
{:type :string
impl/display-name-key "Display Infusion Amount"
impl/beer-xml-type-key impl/beer-xml-text
:spec ::prim/text
:description "A non-empty string denoting a display value for the volume of infused liquid formatted for display in arbitrary units."
:json-schema/example "2.2L"}))
(spec/def ::mash-step
(st/spec
{:type :map
:description "A record representing a step within the mashing process."
:spec (spec/keys :req-un [::prim/name
::prim/version
::type
::infuse-amount
::step-temp
::step-time]
:opt-un [::ramp-time
::end-temp
::description
::water-grain-ratio
::decoction-amt
::infuse-temp
::display-step-temp
::display-infuse-amt])}))
(spec/def ::mash-step-wrapper
(st/spec
{:type :map
impl/wrapper-spec-key true
impl/beer-xml-type-key impl/beer-xml-record
:description "A `::mash` record wrapped in a `:mash` map"
:spec (spec/keys :req-un [::mash-step])}))
(spec/def ::mash-steps
(st/spec
{:type :vector
impl/beer-xml-type-key impl/beer-xml-record-set
:description "A `::mash-step` record set."
:spec (spec/coll-of ::mash-step-wrapper :into [] :kind vector?)
:decode/string #(impl/decode-sequence %1 ::mash-step-wrapper %2)
:encode/string #(impl/encode-sequence %1 ::mash-step-wrapper %2)}))
(def mash-steps
"A collection of mash-steps."
:mash-steps)
(def grain-temp
"The temperature of the grain before adding it to the mash."
:grain-temp)
(def notes
"Notes about the mash."
:notes)
(def tun-temp
"The pre-mash temperature of the mash tun."
:tun-temp)
(def sparge-temp
"The temperature of the sparge water."
:sparge-temp)
(def ph
"The PH of the water."
:ph)
(def tun-weight
"The weight of the mash tun."
:tun-weight)
(def tun-specific-heat
"The specific heat of the mash tun in Calories per gram-degree Celsius."
:tun-specific-heat)
(def equip-adjust
"Whether or not to account for the temperature effects of the equipment used."
:equip-adjust)
(def display-grain-temp
"A display value for the temperature of the grain before adding it to the mash."
:display-grain-temp)
(def display-tun-temp
"A display value for the temperature of the mash tun."
:display-tun-temp)
(def display-sparge-temp
"A display value for the temperature of the sparge water."
:display-sparge-temp)
(def display-tun-weight
"A display value for the weight of the mash tun."
:display-tun-weight)
(spec/def ::grain-temp
(st/spec
{:type :double
impl/display-name-key "Grain Temperature"
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-degrees-celsius
:spec ::prim/degrees-celsius
:description "A non-negative IEEE-754 floating point number representing the temperature of the grain before adding it to the mash in degrees Celsius."
:json-schema/example 80}))
(spec/def ::tun-temp
(st/spec
{:type :double
impl/display-name-key "Tun Temperature"
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-degrees-celsius
:spec ::prim/degrees-celsius
:description "A non-negative IEEE-754 floating point number representing the temperature of the grain tun in degrees Celsius."
:json-schema/example 80}))
(spec/def ::sparge-temp
(st/spec
{:type :double
impl/display-name-key "Sparge Temperature"
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-degrees-celsius
:spec ::prim/degrees-celsius
:description "A non-negative IEEE-754 floating point number representing the temperature of the sparge in degrees Celsius."
:json-schema/example 50}))
(spec/def ::ph
(st/spec
{:type :double
impl/display-name-key "PH"
impl/beer-xml-type-key impl/beer-xml-floating-point
:spec ::prim/non-negative-number
:description "A non-negative IEEE-754 floating point number representing the PH of the water."
:json-schema/example 2.5}))
(spec/def ::tun-weight
(st/spec
{:type :double
:spec ::prim/kilogram
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-kilogram
:description "A non-negative IEEE-754 floating point number representing the weight of the of the mash tun in kilograms."
:json-schema/example 15.0}))
(spec/def ::tun-specific-heat
(st/spec
{:type :double
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-calories-per-gram-degree-celsius
:spec ::prim/non-negative-number
:description "A non-negative IEEE-754 floating point number representing the specific heat of the mash tun in Calories per gram-degree Celsius."
:json-schema/example 0.2}))
(spec/def ::equip-adjust
(st/spec
{:spec ::prim/boolean
impl/display-name-key "Equipment Adjust"
impl/beer-xml-type-key impl/beer-xml-boolean
:description (impl/multiline "A boolean denoting whether or not programs should account for the temperature effects of the equipment used."
"When absent, assume false.")
:json-schema/example true
:decode/string impl/decode-boolean
:encode/string impl/encode-boolean}))
(spec/def ::display-grain-temp
(st/spec
{:type :string
impl/display-name-key "Display Grain Temperature"
impl/beer-xml-type-key impl/beer-xml-text
:spec ::prim/text
:description "A non-empty string denoting a display value for grain temperature formatted for display in arbitrary units."
:json-schema/example "72F"}))
(spec/def ::display-tun-temp
(st/spec
{:type :string
impl/display-name-key "Display Tun Temperature"
impl/beer-xml-type-key impl/beer-xml-text
:spec ::prim/text
:description "A non-empty string denoting a display value for mash tun temperature formatted for display in arbitrary units."
:json-schema/example "72F"}))
(spec/def ::display-sparge-temp
(st/spec
{:type :string
impl/display-name-key "Display Sparge Temperature"
impl/beer-xml-type-key impl/beer-xml-text
:spec ::prim/text
:description "A non-empty string denoting a display value for sparging process temperature formatted for display in arbitrary units."
:json-schema/example "172F"}))
(spec/def ::display-tun-weight
(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 mash tun weight formatted for display in arbitrary units."
:json-schema/example "72lbs"}))
(spec/def ::mash
(st/spec
{:type :map
:description "A record representing the mashing process."
:spec (spec/keys :req-un [::prim/name
::prim/version
::grain-temp
::mash-steps]
:opt-un [::prim/notes
::tun-temp
::sparge-temp
::ph
::tun-weight
::tun-specific-heat
::equip-adjust
::display-grain-temp
::display-tun-temp
::display-sparge-temp
::display-tun-weight])}))
(spec/def ::mash-wrapper
(st/spec
{:type :map
impl/wrapper-spec-key true
impl/beer-xml-type-key impl/beer-xml-record
:description "A `::mash-wrapper` record"
:spec (spec/keys :req-un [::mash])}))
(spec/def ::mashs
(st/spec
{:type :vector
:description "A vector of valid `::mash` records."
:spec (spec/coll-of ::mash-wrapper :into [] :kind vector?)
:decode/string #(impl/decode-sequence %1 ::mash-wrapper %2)
:encode/string #(impl/encode-sequence %1 ::mash-wrapper %2)}))
(spec/def ::mashs-wrapper
(st/spec
{:type :map
impl/wrapper-spec-key true
impl/beer-xml-type-key impl/beer-xml-record-set
:description "A `::mashs` record record set."
:spec (spec/keys :req-un [::mashs])}))