-
Notifications
You must be signed in to change notification settings - Fork 1
/
miscs.cljc
299 lines (220 loc) · 9.12 KB
/
miscs.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
(ns common-beer-format.miscs
"The definition of a misc 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 time type use]))
(def misc
"A miscellaneous ingredient in a beer recipe."
:misc)
(def miscs
"A collection of miscellaneous ingredients in a beer recipe."
:miscs)
(def name
"The name of a miscellaneous ingredient which isn't a hop, yeast, or primarily fermentable sugar."
:name)
(def version
"The BeerXML version of the miscellaneous ingredient."
:version)
(def type
"The type of the miscellaneous ingredient.
Currently, BeerXML Supports the following types:
- `spice`: A spice, such as cinnamon or ginger.
- `fining`: A fining agent, such as isinglass.
- `water agent`: A water agent, such as campden tablet.
- `herb`: An herb, such as mint.
- `flavor`: A flavoring, such as orange peel or a flavor concentrate.
- `other`: Any other type of miscellaneous ingredient."
:type)
(def use
"How the miscellaneous ingredient is used in the brewing process.
Currently, BeerXML supports the following uses:
- `boil`: The ingredient is added to the boil.
- `mash`: The ingredient is added to the mash.
- `primary`: The ingredient is added to the primary fermentation.
- `secondary`: The ingredient is added to the secondary fermentation.
- `bottling`: The ingredient is added to the bottling process."
:use)
(def time
"The time in minutes the ingredient is added to the beer.
For `boil` this is the boil time.
For `mash` this is the mash time.
For `primary`, `secondary`, and `bottling` this is the amount of time the ingredient spent in that state."
:time)
(def amount
"The amount of the ingredient added to the beer."
:amount)
(def amount-is-weight
"Whether the amount is a weight or a volume."
:amount-is-weight)
(def use-for
"A description of what the ingredient is used for."
:use-for)
(def notes
"Notes about the ingredient."
:notes)
(def display-amount
"The amount of the ingredient to display."
:display-amount)
(def inventory
"The amount of the ingredient in inventory."
:inventory)
(def display-time
"A human-readable version of the time."
:display-time)
(def fining
"A fining agent, such as isinglass."
"Fining")
(def flavor
"A flavoring, such as orange peel or a flavor concentrate."
"Flavor")
(def herb
"An herb, such as mint."
"Herb")
(def other
"Any other type of miscellaneous ingredient."
"Other")
(def spice
"A spice, such as cinnamon or ginger."
"Spice")
(def water-agent
"A water agent, such as campden tablet."
"Water Agent")
(def misc-types
"A set of the miscellaneous ingredient types supported by BeerXML.
Currently, BeerXML Supports the following types:
- `spice`: A spice, such as cinnamon or ginger.
- `fining`: A fining agent, such as isinglass.
- `water agent`: A water agent, such as campden tablet.
- `herb`: An herb, such as mint.
- `flavor`: A flavoring, such as orange peel or a flavor concentrate.
- `other`: Any other type of miscellaneous ingredient."
#{fining
flavor
herb
other
spice
water-agent})
(spec/def ::type
(st/spec
{:type :string
:spec misc-types
impl/beer-xml-type-key impl/beer-xml-list
:gen #(spec/gen misc-types)
:description (impl/multiline
"A case-sensitive string representing the type of the miscellaneous item added to the beer."
(impl/set->description misc-types)
""
"- Fining: A fining agent, such as isinglass."
"- Flavor: A flavoring, such as orange peel or a flavor concentrate."
"- Herb: An herb, such as mint."
"- Other: Any other type of miscellaneous ingredient."
"- Spice: A spice, such as cinnamon or ginger."
"- Water Agent: A water agent, such as campden tablet.")
:json-schema/example "Spice"}))
(def boil
"The ingredient is added to the boil."
"Boil")
(def mash
"The ingredient is added to the mash."
"Mash")
(def primary
"The ingredient is added to the primary fermentation."
"Primary")
(def secondary
"The ingredient is added to the secondary fermentation."
"Secondary")
(def bottling
"The ingredient is added to the bottling process."
"Bottling")
(def misc-uses
"A set of the miscellaneous ingredient uses supported by BeerXML.
Currently, BeerXML supports the following uses:
- `boil`: The ingredient is added to the boil.
- `mash`: The ingredient is added to the mash.
- `primary`: The ingredient is added to the primary fermentation.
- `secondary`: The ingredient is added to the secondary fermentation.
- `bottling`: The ingredient is added during the bottling process."
#{boil
mash
primary
secondary
bottling})
(spec/def ::use
(st/spec
{:type :string
:spec misc-uses
impl/beer-xml-type-key impl/beer-xml-list
:gen #(spec/gen misc-uses)
:description (impl/multiline
"A case-sensitive string representing the point in the brewing cycle the miscellaneous ingredient is added to the beer."
(impl/set->description misc-uses)
""
"- Boil: The ingredient is added to the boil."
"- Mash: The ingredient is added to the mash."
"- Primary: The ingredient is added to the primary fermentation."
"- Secondary: The ingredient is added to the secondary fermentation."
"- Bottling: The ingredient is added during the bottling process.")
:json-schema/example "Mash"}))
(spec/def ::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 (impl/multiline
"A non-negative IEEE-754 floating point number representing the time in minutes the ingredient was added dependant on the `:use` field."
"For \"Boil\" this is the boil time."
"For \"Mash\" this is the mash time."
"For \"Primary\", \"Secondary\", and \"Bottling\" this is the amount of time the ingredient spent in that state.")
:json-schema/example 15.0}))
(spec/def ::use-for
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting what the ingredient is used for."
:json-schema/example "Used to impart a mild, zesty flavor"}))
(spec/def ::misc
(st/spec
{:type :map
impl/display-name-key "Miscellaneous Ingredient"
:description "A record representing a miscellaneous ingredient in a beer recipe."
:spec (spec/keys :req-un [::prim/name
::prim/version
::type
::use
::time
::prim/amount]
:opt-un [::prim/amount-is-weight
::use-for
::prim/notes
::prim/display-amount
::prim/inventory
::prim/display-time])}))
(spec/def ::misc-wrapper
(st/spec
{:type :map
impl/display-name-key "Miscellaneous Ingredient Wrapper"
impl/wrapper-spec-key true
impl/beer-xml-type-key impl/beer-xml-record
:description "A `::misc` record wrapped in a `:misc` map."
:spec (spec/keys :req-un [::misc])}))
(spec/def ::miscs
(st/spec
{:type :vector
impl/display-name-key "Miscellaneous Ingredients"
:description "A vector of valid `::misc` records."
:spec (spec/coll-of ::misc-wrapper :into [] :kind vector?)
:decode/string #(impl/decode-sequence %1 ::misc-wrapper %2)
:encode/string #(impl/encode-sequence %1 ::misc-wrapper %2)}))
(spec/def ::miscs-wrapper
(st/spec
{:type :map
impl/display-name-key "Miscellaneous Ingredients Wrapper"
impl/wrapper-spec-key true
impl/beer-xml-type-key impl/beer-xml-record-set
:description "A `::miscs` record."
:spec (spec/keys :req-un [::miscs])}))