We’re making beer. I’m the brewery! Bender Bending Rodriguez from Futurama
A Clojure(Script) library to create randomized beer recipes!
The beta release of our SPA is now available!
This repository follows the guidelines and standards of the Wall Brew Open Source Policy.
A deployed copy of the most recent version of brew-bot can be found on clojars. To use it, add the following as a dependency in your project.clj file:
The next time you build your application, Leiningen or deps.edn should pull it automatically. Alternatively, you may clone or fork the repository to work with it directly.
This library heavily relies upon the common-beer-format and returns all recipes and ingredients to match its specification. Therefore, all arguments passed to functions in brew-bot are normalized to these standards as well. Most importantly, it assumes measurements are provided in the International System of Units, also known as the modern metric system. Since many brewing applications, especially those based in America, operate on Imperial Measurements, you may wish to add brewtility to any applications consuming this library to assist with conversions between systems of measure.
All functions necessary to generate a recipe are provided in the core namespace.
(:require [brew-bot.core :refer :all])
(def fermentables
(select-fermentables))
(def hops
(select-hops :random))
(def yeast
(select-yeasts :random {:count-cutoff 1}))
(def my-random-recipe
(ingredients->cbf-recipe-template fermentables hops yeast))
Each of the three functions select-fermentables
, select-hops
, and select-yeasts
support multiple arities:
- Zero - Selects ingredients completely randomly across the full set provided by
common-beer-format
- One - Given a strategy, select ingredients from the full set provided by
common-beer-format
- Two - Given a strategy and a map of options, select ingredients with fine-grained control.
These are the currently supported strategies:
:random
- Select ingredients at random with an even probability of selection and with replacement:weighted
- Select ingredients with a provided selection probability and with replacement. For example,{:galaxy 15.0, :el-dorado 5.0, :topaz 1.0}
. In this example, galaxy hops have a 71.43% chance of being selected (15.0 / (15.0 + 5.0 + 1.0)).
These are the currently supported options:
- amount-cutoff - The maximum weight, in kilograms, of fermentable ingredients to select. Defaults to
2.26796
kilograms (5 pounds) - count-cutoff - The maximum number of unique ingredients to allow.
- selection-weights - A map from ingredient names to probability weights. e.g.
{:amber-liquid-extract 5.0 :biscuit-malt 15.0 ...}
. Only applicable for the:weighted
strategy - default-weight - A probability weight to fall back to for ingredients not specified in selection-weights. Only applicable for the
:weighted
strategy
Additionally, per ingredient type, you may focus the possible ingredient selections. Hops also support two additional options for determining when hops are added and their primary use case.
- include-adjuncts? - A boolean switch to include adjuncts in the list of selectable ingredients. Defaults to
true
- include-dry-extracts? - A boolean switch to include dry extracts in the list of selectable ingredients. Defaults to
true
- include-extracts? - A boolean switch to include extracts in the list of selectable ingredients. Defaults to
true
- include-grains? - A boolean switch to include grains in the list of selectable ingredients. Defaults to
true
- include-sugars? - A boolean switch to include sugars in the list of selectable ingredients. Defaults to
true
- timing-strategy - A keyword from the set
#{:random :weighted :inferred}
to determine how hop timings and uses should be selected. Defaults to:random
- time-weights - A map from hop addition times to weights. e.g.
{120 60.0 45 15.0 ...}
- use-weights - A map from hop use names to weights. e.g.
{"boil" 60 ...}
- include-aroma? - A boolean switch to include aromatic hops. Defaults to
true
- include-bittering? - A boolean switch to include bittering hops. Defaults to
true
- include-both? - A boolean switch to include dual-purpose hops. Defaults to
true
- include-brewtek? - A boolean switch to include yeasts from Brewtek. Defaults to
true
- include-dcl-fermentis? - A boolean switch to include yeasts from DCL Fermentis. Defaults to
true
- include-lallemand? - A boolean switch to include yeasts from Lallemand. Defaults to
true
- include-white-labs? - A boolean switch to include yeasts from White Labs. Defaults to
true
- include-wyeast? - A boolean switch to include yeasts from Wyeast. Defaults to
true
doo, a Leiningen plugin used to run ClojureScript tests in many JS environments, is already in project.clj
.
Karma is used as the test runner, and is included in package.json
.
To install Karma, simply install the Node package:
npm install
Then build the application and run the tests:
lein test-build
The tests will also execute on the JVM, to ensure the library is compatible for both runtime environments.
Copyright © Wall Brew Co
This software is provided for free, public use as outlined in the MIT License