Skip to content

Commit

Permalink
Add other formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
nnichols committed Oct 7, 2023
1 parent 8fb02d9 commit 6c3a79d
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ jobs:
ref: ${{ github.head_ref }}
token: ${{ secrets.WALL_BREW_BOT_PAT }}

- name: Cache maven dependencies
uses: actions/cache@v3
env:
cache-name: cache-maven
with:
path: ~/.m2
key: ${{ runner.os }}-clj-${{ hashFiles('**/project.clj') }}
restore-keys: |
${{ runner.os }}-clj
- name: Install Clojure dependencies
run: lein deps

- name: Install cljstyle
uses: just-sultanov/setup-cljstyle@v1
with:
Expand All @@ -22,6 +35,14 @@ jobs:
run: |
cljstyle fix --report --report-timing --verbose
- name: Sort Namespaces
run: |
lein ns-sort
- name: Render Changelog
run: |
lein sealog render
- name: Commit changes
uses: stefanzweifel/[email protected]
with:
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ version/major:
@ lein change version leiningen.release/bump-version release
@ lein sealog bump major
@ lein pom
@ npm version major --no-git-tag-version

version/minor:
$(info Updating minor version and adding CHANGELOG entry...)
Expand All @@ -22,6 +23,7 @@ version/minor:
@ lein change version leiningen.release/bump-version release
@ lein sealog bump minor
@ lein pom
@ npm version minor --no-git-tag-version

version/patch:
$(info Updating patch version and adding CHANGELOG entry...)
Expand All @@ -30,6 +32,7 @@ version/patch:
@ lein change version leiningen.release/bump-version release
@ lein sealog bump patch
@ lein pom
@ npm version patch --no-git-tag-version

changelog/render:
$(info Rendering CHANGELOG...)
Expand Down
2 changes: 1 addition & 1 deletion src/brewtility/calculations.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@


(def gravity->abv-multiplier
"The multiplier used to convert gravity to ABV.
"The multiplier used to convert gravity to ABV.
This is a constant, and is not configurable."
0.00135)
Expand Down
231 changes: 231 additions & 0 deletions src/brewtility/enrich/styles.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,234 @@
"brewtility.enrich.yeast"]}
(:require [brewtility.enrich.impl :as impl]))


(defn enrich-display-og-min
"An enricher pattern function to render a human-readable display minimum original gravity of a [style](https://github.com/Wall-Brew-Co/common-beer-format/blob/master/src/common_beer_format/style.cljc) is in a given system.
An option map may be passed as an optional second argument to this function to override the default behavior.
Supported keys include:
- `:system-of-measure`: The unit system of measure to convert the min-temperature into. Defaults to `:us`. Acceptable values are:
- `:imperial`: The [British imperial](https://en.wikipedia.org/wiki/Imperial_units) system of measure.
- `:metric`: The [metric system](https://en.wikipedia.org/wiki/Metric_system) of measure.
- `:us`: The [United States Customary Units](https://en.wikipedia.org/wiki/United_States_customary_units) system of measure.
- `:si`: The [International System of Units](https://en.wikipedia.org/wiki/International_System_of_Units) system of measure.
- `:precision`: The number of significant decimal places to display. Defaults to 3.
- `:suffix`: The suffix type to append to the min-temperature Defaults to `:short`. Acceptable values are:
- `:short`: A customary abbreviation for the selected unit. For example, `\"lb\"` for `\"pounds\"`.
- `:full`: The full name of the selected unit. For example, `\"gram\"` for `\"gram\"`.
To support fine-grained selections within the context of `enrich-style` and `enrich-style-wrapper`, this function also supports the following keys:
- `:style-display-og-min-target-units`: The unit to convert the min-temperature into. Supersedes `:system-of-measure`.
- `:style-display-og-min-precision`: The number of significant decimal places to display. Supersedes `:precision`.
- `:style-display-og-min-suffix`: The suffix type to append to the min-temperature. Supersedes `:suffix`."
{:added "2.1"
:see-also ["enrich-style"
"enrich-style-wrapper"
"enrich-styles"
"enrich-styles-wrapper"]}
([style] (enrich-display-og-min style {}))
([style {:keys [style-display-og-min-target-units
style-display-og-min-precision
style-display-og-min-suffix]
:as opts}]
(let [options (merge opts {impl/value-key :og-min
impl/display-key :display-og-min
impl/fine-grain-target-units style-display-og-min-target-units
impl/fine-grain-precision style-display-og-min-precision
impl/fine-grain-suffix style-display-og-min-suffix})]
(impl/enrich-displayable-specific-gravity style options))))


(defn enrich-display-og-max
"An enricher pattern function to render a human-readable display maximum original gravity of a [style](https://github.com/Wall-Brew-Co/common-beer-format/blob/master/src/common_beer_format/style.cljc) is in a given system.
An option map may be passed as an optional second argument to this function to override the default behavior.
Supported keys include:
- `:system-of-measure`: The unit system of measure to convert the min-temperature into. Defaults to `:us`. Acceptable values are:
- `:imperial`: The [British imperial](https://en.wikipedia.org/wiki/Imperial_units) system of measure.
- `:metric`: The [metric system](https://en.wikipedia.org/wiki/Metric_system) of measure.
- `:us`: The [United States Customary Units](https://en.wikipedia.org/wiki/United_States_customary_units) system of measure.
- `:si`: The [International System of Units](https://en.wikipedia.org/wiki/International_System_of_Units) system of measure.
- `:precision`: The number of significant decimal places to display. Defaults to 3.
- `:suffix`: The suffix type to append to the min-temperature Defaults to `:short`. Acceptable values are:
- `:short`: A customary abbreviation for the selected unit. For example, `\"lb\"` for `\"pounds\"`.
- `:full`: The full name of the selected unit. For example, `\"gram\"` for `\"gram\"`.
To support fine-grained selections within the context of `enrich-style` and `enrich-style-wrapper`, this function also supports the following keys:
- `:style-display-og-max-target-units`: The unit to convert the min-temperature into. Supersedes `:system-of-measure`.
- `:style-display-og-max-precision`: The number of significant decimal places to display. Supersedes `:precision`.
- `:style-display-og-max-suffix`: The suffix type to append to the min-temperature. Supersedes `:suffix`."
{:added "2.1"
:see-also ["enrich-style"
"enrich-style-wrapper"
"enrich-styles"
"enrich-styles-wrapper"]}
([style] (enrich-display-og-max style {}))
([style {:keys [style-display-og-max-target-units
style-display-og-max-precision
style-display-og-max-suffix]
:as opts}]
(let [options (merge opts {impl/value-key :og-max
impl/display-key :display-og-max
impl/fine-grain-target-units style-display-og-max-target-units
impl/fine-grain-precision style-display-og-max-precision
impl/fine-grain-suffix style-display-og-max-suffix})]
(impl/enrich-displayable-specific-gravity style options))))


(defn enrich-display-fg-min
"An enricher pattern function to render a human-readable display minimum final gravity of a [style](https://github.com/Wall-Brew-Co/common-beer-format/blob/master/src/common_beer_format/style.cljc) is in a given system.
An option map may be passed as an optional second argument to this function to override the default behavior.
Supported keys include:
- `:system-of-measure`: The unit system of measure to convert the min-temperature into. Defaults to `:us`. Acceptable values are:
- `:imperial`: The [British imperial](https://en.wikipedia.org/wiki/Imperial_units) system of measure.
- `:metric`: The [metric system](https://en.wikipedia.org/wiki/Metric_system) of measure.
- `:us`: The [United States Customary Units](https://en.wikipedia.org/wiki/United_States_customary_units) system of measure.
- `:si`: The [International System of Units](https://en.wikipedia.org/wiki/International_System_of_Units) system of measure.
- `:precision`: The number of significant decimal places to display. Defaults to 3.
- `:suffix`: The suffix type to append to the min-temperature Defaults to `:short`. Acceptable values are:
- `:short`: A customary abbreviation for the selected unit. For example, `\"lb\"` for `\"pounds\"`.
- `:full`: The full name of the selected unit. For example, `\"gram\"` for `\"gram\"`.
To support fine-grained selections within the context of `enrich-style` and `enrich-style-wrapper`, this function also supports the following keys:
- `:style-display-fg-min-target-units`: The unit to convert the min-temperature into. Supersedes `:system-of-measure`.
- `:style-display-fg-min-precision`: The number of significant decimal places to display. Supersedes `:precision`.
- `:style-display-fg-min-suffix`: The suffix type to append to the min-temperature. Supersedes `:suffix`."
{:added "2.1"
:see-also ["enrich-style"
"enrich-style-wrapper"
"enrich-styles"
"enrich-styles-wrapper"]}
([style] (enrich-display-fg-min style {}))
([style {:keys [style-display-fg-min-target-units
style-display-fg-min-precision
style-display-fg-min-suffix]
:as opts}]
(let [options (merge opts {impl/value-key :fg-min
impl/display-key :display-fg-min
impl/fine-grain-target-units style-display-fg-min-target-units
impl/fine-grain-precision style-display-fg-min-precision
impl/fine-grain-suffix style-display-fg-min-suffix})]
(impl/enrich-displayable-specific-gravity style options))))


(defn enrich-display-fg-max
"An enricher pattern function to render a human-readable display maximum final gravity of a [style](https://github.com/Wall-Brew-Co/common-beer-format/blob/master/src/common_beer_format/style.cljc) is in a given system.
An option map may be passed as an optional second argument to this function to override the default behavior.
Supported keys include:
- `:system-of-measure`: The unit system of measure to convert the min-temperature into. Defaults to `:us`. Acceptable values are:
- `:imperial`: The [British imperial](https://en.wikipedia.org/wiki/Imperial_units) system of measure.
- `:metric`: The [metric system](https://en.wikipedia.org/wiki/Metric_system) of measure.
- `:us`: The [United States Customary Units](https://en.wikipedia.org/wiki/United_States_customary_units) system of measure.
- `:si`: The [International System of Units](https://en.wikipedia.org/wiki/International_System_of_Units) system of measure.
- `:precision`: The number of significant decimal places to display. Defaults to 3.
- `:suffix`: The suffix type to append to the min-temperature Defaults to `:short`. Acceptable values are:
- `:short`: A customary abbreviation for the selected unit. For example, `\"lb\"` for `\"pounds\"`.
- `:full`: The full name of the selected unit. For example, `\"gram\"` for `\"gram\"`.
To support fine-grained selections within the context of `enrich-style` and `enrich-style-wrapper`, this function also supports the following keys:
- `:style-display-fg-max-target-units`: The unit to convert the min-temperature into. Supersedes `:system-of-measure`.
- `:style-display-fg-max-precision`: The number of significant decimal places to display. Supersedes `:precision`.
- `:style-display-fg-max-suffix`: The suffix type to append to the min-temperature. Supersedes `:suffix`."
{:added "2.1"
:see-also ["enrich-style"
"enrich-style-wrapper"
"enrich-styles"
"enrich-styles-wrapper"]}
([style] (enrich-display-fg-max style {}))
([style {:keys [style-display-fg-max-target-units
style-display-fg-max-precision
style-display-fg-max-suffix]
:as opts}]
(let [options (merge opts {impl/value-key :fg-max
impl/display-key :display-fg-max
impl/fine-grain-target-units style-display-fg-max-target-units
impl/fine-grain-precision style-display-fg-max-precision
impl/fine-grain-suffix style-display-fg-max-suffix})]
(impl/enrich-displayable-specific-gravity style options))))


(defn enrich-display-color-min
"An enricher pattern function to render a human-readable display minimum color of a [style](https://github.com/Wall-Brew-Co/common-beer-format/blob/master/src/common_beer_format/style.cljc) is in a given system.
An option map may be passed as an optional second argument to this function to override the default behavior.
Supported keys include:
- `:system-of-measure`: The unit system of measure to convert the min-temperature into. Defaults to `:us`. Acceptable values are:
- `:imperial`: The [British imperial](https://en.wikipedia.org/wiki/Imperial_units) system of measure.
- `:metric`: The [metric system](https://en.wikipedia.org/wiki/Metric_system) of measure.
- `:us`: The [United States Customary Units](https://en.wikipedia.org/wiki/United_States_customary_units) system of measure.
- `:si`: The [International System of Units](https://en.wikipedia.org/wiki/International_System_of_Units) system of measure.
- `:precision`: The number of significant decimal places to display. Defaults to 3.
- `:suffix`: The suffix type to append to the min-temperature Defaults to `:short`. Acceptable values are:
- `:short`: A customary abbreviation for the selected unit. For example, `\"lb\"` for `\"pounds\"`.
- `:full`: The full name of the selected unit. For example, `\"gram\"` for `\"gram\"`.
To support fine-grained selections within the context of `enrich-style` and `enrich-style-wrapper`, this function also supports the following keys:
- `:style-display-color-min-target-units`: The unit to convert the min-temperature into. Supersedes `:system-of-measure`.
- `:style-display-color-min-precision`: The number of significant decimal places to display. Supersedes `:precision`.
- `:style-display-color-min-suffix`: The suffix type to append to the min-temperature. Supersedes `:suffix`."
{:added "2.1"
:see-also ["enrich-style"
"enrich-style-wrapper"
"enrich-styles"
"enrich-styles-wrapper"]}
([style] (enrich-display-color-min style {}))
([style {:keys [style-display-color-min-target-units
style-display-color-min-precision
style-display-color-min-suffix]
:as opts}]
(let [options (merge opts {impl/value-key :color-min
impl/display-key :display-color-min
impl/fine-grain-target-units style-display-color-min-target-units
impl/fine-grain-precision style-display-color-min-precision
impl/fine-grain-suffix style-display-color-min-suffix})]
(impl/enrich-displayable-color style options))))


(defn enrich-display-color-max
"An enricher pattern function to render a human-readable display maximum color of a [style](https://github.com/Wall-Brew-Co/common-beer-format/blob/master/src/common_beer_format/style.cljc) is in a given system.
An option map may be passed as an optional second argument to this function to override the default behavior.
Supported keys include:
- `:system-of-measure`: The unit system of measure to convert the min-temperature into. Defaults to `:us`. Acceptable values are:
- `:imperial`: The [British imperial](https://en.wikipedia.org/wiki/Imperial_units) system of measure.
- `:metric`: The [metric system](https://en.wikipedia.org/wiki/Metric_system) of measure.
- `:us`: The [United States Customary Units](https://en.wikipedia.org/wiki/United_States_customary_units) system of measure.
- `:si`: The [International System of Units](https://en.wikipedia.org/wiki/International_System_of_Units) system of measure.
- `:precision`: The number of significant decimal places to display. Defaults to 3.
- `:suffix`: The suffix type to append to the min-temperature Defaults to `:short`. Acceptable values are:
- `:short`: A customary abbreviation for the selected unit. For example, `\"lb\"` for `\"pounds\"`.
- `:full`: The full name of the selected unit. For example, `\"gram\"` for `\"gram\"`.
To support fine-grained selections within the context of `enrich-style` and `enrich-style-wrapper`, this function also supports the following keys:
- `:style-display-color-max-target-units`: The unit to convert the min-temperature into. Supersedes `:system-of-measure`.
- `:style-display-color-max-precision`: The number of significant decimal places to display. Supersedes `:precision`.
- `:style-display-color-max-suffix`: The suffix type to append to the min-temperature. Supersedes `:suffix`."
{:added "2.1"
:see-also ["enrich-style"
"enrich-style-wrapper"
"enrich-styles"
"enrich-styles-wrapper"]}
([style] (enrich-display-color-max style {}))
([style {:keys [style-display-color-max-target-units
style-display-color-max-precision
style-display-color-max-suffix]
:as opts}]
(let [options (merge opts {impl/value-key :color-max
impl/display-key :display-color-max
impl/fine-grain-target-units style-display-color-max-target-units
impl/fine-grain-precision style-display-color-max-precision
impl/fine-grain-suffix style-display-color-max-suffix})]
(impl/enrich-displayable-color style options))))

0 comments on commit 6c3a79d

Please sign in to comment.