diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 17cdf1b5..123de6d2 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -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: @@ -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/git-auto-commit-action@v5.0.0 with: diff --git a/Makefile b/Makefile index 4b1a5d7e..a91d4fd8 100644 --- a/Makefile +++ b/Makefile @@ -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...) @@ -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...) @@ -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...) diff --git a/src/brewtility/calculations.cljc b/src/brewtility/calculations.cljc index 7b63cf89..48b6a50a 100644 --- a/src/brewtility/calculations.cljc +++ b/src/brewtility/calculations.cljc @@ -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) diff --git a/src/brewtility/enrich/styles.cljc b/src/brewtility/enrich/styles.cljc index 719604d2..eb0e3ec9 100644 --- a/src/brewtility/enrich/styles.cljc +++ b/src/brewtility/enrich/styles.cljc @@ -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))))