Liking cljdoc? Tell your friends :D

nicheware.platform.utilities.common.config

Supports reading application configuration as a clojure map.

Features include:

  • merging of a global config file, with an environment specific one (eg dev, test, prod)
  • mustache variable substitution in config values. Variables are previously defined config values.
  • mustache function operation on config value.
  • optional parameters to override defaults.

As an example, global configuration, common to every environment, could be defined in resources/app/config.edn

{:env "default"
 :value "common-value"
 :file "{{env}}-file.txt"}

An environment specific config (eg for test) could be defined in env/test/resources/app/env-config.edn.

{:env "test"
 :other "value"}

When the execution environment is setup to include "resources" and "env/test/resources" on the classpath (as would be done when executing tests), then calling (load-config "app") will return:

{:env "test"
 :other "value"
 :value "common-value"
 :file "test-file.txt"}

Variable evaluation is done recursively, on the final merged map until all variables have been evaluated.

Both load-config and load-http-config accept an optional opts map, which can selectively override the following defaults:

{:env-file-name "env-config.edn"
 :common-file-name "config.edn"
 :resolve-vars true}

The opts arguments may also define :common-path or :env-path, which would then be used instead of building up the path from the file name and provided path prefix.

Supports reading application configuration as a clojure map.

   Features include:

   - merging of a global config file, with an environment specific one (eg dev, test, prod)
   - mustache variable substitution in config values. Variables are previously defined config values.
   - mustache function operation on config value.
   - optional parameters to override defaults.

   As an example, global configuration, common to every environment, could be defined in ```resources/app/config.edn```

```clojure
{:env "default"
 :value "common-value"
 :file "{{env}}-file.txt"}
```

   An environment specific config (eg for test) could be defined in ```env/test/resources/app/env-config.edn```.

```clojure
{:env "test"
 :other "value"}
```

   When the execution environment is setup to include "resources" and "env/test/resources" on the classpath
   (as would be done when executing tests), then calling ```(load-config "app")``` will return:

```clojure
{:env "test"
 :other "value"
 :value "common-value"
 :file "test-file.txt"}
```

   Variable evaluation is done recursively, on the final merged map until all variables have been evaluated.

   Both [[load-config]] and [[load-http-config]] accept an optional opts map, which can selectively override
   the following defaults:

```clojure
{:env-file-name "env-config.edn"
 :common-file-name "config.edn"
 :resolve-vars true}
```

  The opts arguments may also define ```:common-path``` or ```:env-path```, which would then be used
  instead of building up the path from the file name and provided path prefix.
raw docstring

nicheware.platform.utilities.common.core

This namespace contains functions that complement those in clojure.core, operating on the main clojure collections and data types.

There are groups of functions within common.core that deal with:

Function groupFunctions
slicing collectionsslice, slice-wrap, remove-slice, remove-slice-wrap, filter-count
collection insertsinsert-before, insert-after, replace-at
integer functionsrange-of-range, negate, snap
general sequence functionsrotate-seq, selective-merge, pad-with, seq-of
collection searchingfind-first, find-last, find-index, find-last-index, find-nth, replace-leading-nils
map utilitydeep-merge, dissoc-in, index-by
map transformmap-values, map-keys, map-all-keys
map filteringfilter-val, filter-key, filter-remove-val, remove-nil, remove-empty
vector functionsvec-remove-nil, find-by-pred, find-element, replace-element-by-pred, replace-element
string functionsafter, before, before-last, str-to-int
cross-platform functionsrand-uuid, parse-int, current-time-millis, edn-read
function compositioncompose-fns
exceptionsthrow-illegal-arg
threading macroscond-t
This namespace contains functions that complement those in clojure.core, operating on the main clojure collections and data types.

There are groups of functions within common.core that deal with:

|Function group|Functions|
|---|---|
|slicing collections| [[slice]], [[slice-wrap]], [[remove-slice]], [[remove-slice-wrap]], [[filter-count]]|
|collection inserts| [[insert-before]], [[insert-after]], [[replace-at]]|
|integer functions| [[range-of-range]], [[negate]], [[snap]]|
|general sequence functions| [[rotate-seq]], [[selective-merge]], [[pad-with]], [[seq-of]]|
|collection searching| [[find-first]], [[find-last]], [[find-index]], [[find-last-index]], [[find-nth]], [[replace-leading-nils]]|
|map utility|  [[deep-merge]], [[dissoc-in]], [[index-by]]|
|map transform| [[map-values]], [[map-keys]], [[map-all-keys]]|
|map filtering| [[filter-val]], [[filter-key]], [[filter-remove-val]], [[remove-nil]], [[remove-empty]]|
|vector functions| [[vec-remove-nil]], [[find-by-pred]], [[find-element]], [[replace-element-by-pred]], [[replace-element]]|
|string functions| [[after]], [[before]], [[before-last]], [[str-to-int]]|
|cross-platform functions| [[rand-uuid]], [[parse-int]], [[current-time-millis]], [[edn-read]]|
|function composition| [[compose-fns]]|
|exceptions| [[throw-illegal-arg]]|
|threading macros| [[cond-t]]|
raw docstring

nicheware.platform.utilities.common.graphics

Functions useful in graphics and drawing calculations.

There are groups of functions within the graphics namespace that deal with:

Function groupFunctions
size fittingaspect-ratio, fit-to-height, fit-to-width, fit-to-dimensions, position-to-dimensions, reverse-transform
shapesupdate-fill-colors, translate-shapes

In these functions the following logical data types are supported:

dimensions:

{:width 100
 :height 20}

transform:

{:x 10
 :y 20
 :scale 0.5}

shape:

{:shape :rect
 :x 10
 :y 30
 :width 100
 :height 30
 :fill-color 3}

The actual units and meaning of these fields is up to the code using these structures for drawing. These functions just update the values as requested.

Functions useful in graphics and drawing calculations.

There are groups of functions within the graphics namespace that deal with:

|Function group|Functions|
|---|---|
|size fitting| [[aspect-ratio]], [[fit-to-height]], [[fit-to-width]], [[fit-to-dimensions]], [[position-to-dimensions]], [[reverse-transform]]|
|shapes| [[update-fill-colors]], [[translate-shapes]]|

In these functions the following logical data types are supported:

 **dimensions**:

```clojure
{:width 100
 :height 20}
```

**transform**:

```clojure
{:x 10
 :y 20
 :scale 0.5}
```

 **shape**:

```clojure
{:shape :rect
 :x 10
 :y 30
 :width 100
 :height 30
 :fill-color 3}
```
The actual units and meaning of these fields is up to the code using these structures for drawing. These functions just update the values as requested.
raw docstring

nicheware.platform.utilities.common.graphics.color

Functions for dealing with colors and conversion between different color representations.

There are groups of functions and variables within the color namespace that deal with:

Function groupFunctions
constants for argb packed int colorsblue-color, black-color, light-grey-color, dark-red-color, transparent-blue-color, dark-blue-color, white-color, dark-green-color, green-color, yellow-color
constants for css string hex colorsbright-red-color, css-yellow-color, css-blue-color, css-pink-color, css-white-color
rgb utility functionsnormalise-rgb, int-rgb, ratio-rgba-to-int-rgba, nudge-color, unique-color
rgb format conversioncolor-as-rgba, color-as-map, rgba-as-css-hex, color-as-css-hex, react-color-as-rgba
rgba, hsla color model conversionrgba-to-hsla, hsla-to-rgba
color model keyword functionsmodel-from-to, model-ranges
color gradient functionsmake-color-increment-fn, color-difference-seq

The different color representations that are used by functions include:

|Representation|Description| |--|--| |RGBA| an RGB color with an alpha channel, represented as a vector with 4 values [R G B A]. Each value is an int from 0 to 255| |RGB or packed RGB| an RGB color with an alpha channel, packed as a Clojure integer, with each byte representing A, R, G, B. The unpacked values are from 0 to 255| |RGB CSS| String hex representation of an RGB color with no alpha channel, as used in CSS color specifications.| |HSLA| Hue, Saturation, Lightness, Alpha as a clojure vector [H S L A]. Hue is a degree on the color wheel, 0 to 360. Saturation is a percentage (100 full color), Lightness is percentage of reflecting color (0 is dark, 100 is light), Alpha is 0 to 255.|

Functions for dealing with colors and conversion between different color representations.

There are groups of functions and variables within the color namespace that deal with:

|Function group|Functions|
|---|---|
|constants for argb packed int colors |[[blue-color]], [[black-color]], [[light-grey-color]], [[dark-red-color]], [[transparent-blue-color]], [[dark-blue-color]], [[white-color]], [[dark-green-color]], [[green-color]], [[yellow-color]]|
|constants for css string hex colors| [[bright-red-color]], [[css-yellow-color]], [[css-blue-color]], [[css-pink-color]], [[css-white-color]]|
|rgb utility functions| [[normalise-rgb]], [[int-rgb]], [[ratio-rgba-to-int-rgba]], [[nudge-color]], [[unique-color]]|
|rgb format conversion| [[color-as-rgba]], [[color-as-map]], [[rgba-as-css-hex]], [[color-as-css-hex]],  [[react-color-as-rgba]]|
|rgba, hsla color model conversion| [[rgba-to-hsla]], [[hsla-to-rgba]]|
|color model keyword functions| [[model-from-to]], [[model-ranges]]|
|color gradient functions| [[make-color-increment-fn]], [[color-difference-seq]]|

The different color representations that are used by functions include:

|Representation|Description|
|--|--|
|RGBA| an RGB color with an alpha channel, represented as a vector with 4 values ```[R G B A]```. Each value is an int from 0 to 255|
|RGB or packed RGB| an RGB color with an alpha channel, packed as a Clojure integer, with each byte representing A, R, G, B. The unpacked values are from 0 to 255|
|RGB CSS| String hex representation of an RGB color with no alpha channel, as used in CSS color specifications.|
|HSLA| Hue, Saturation, Lightness, Alpha as a clojure vector ```[H S L A]```.  **Hue** is a degree on the color wheel, 0 to 360.  **Saturation** is a percentage (100 full color),  **Lightness** is percentage of reflecting color (0 is dark, 100 is light),  **Alpha** is 0 to 255.|
raw docstring

nicheware.platform.utilities.common.graphics.interpolate

Functions for performing different interpolations between two points.

Function groupFunctions
interpolationget-options, interpolate

Interpolation is done between two n-dimension co-ordinates/points.

It can be used for calculating curves or lines in an n-dimensional spaces or filling in a colour spectrum between two colours in a colour model.

The following interpolation types are supported:

TypeDescription
lineardirect linear interpolation
quadratic-beziera quadratic bezier interpolation between to two points and one control point.
cubic-beziera cubic bezier interpolation between the two points, using two control points.
ease-ina quadratic bezier interpolation, where the control point is selected using the ease factor and end point.
ease-outa quadratic bezier interpolation, where the control point is selected using the ease factor and end point.
ease-in-outa cubic bezier interpolation, where the two control points are selected using the ease factors and end point.
step-upcomputes a fix step up for each dimension.
step-downcomputes a fixed step down for each dimension.

The variable interpolation-types is a vector of all the valid interpolation keywords.

Functions for performing different interpolations between two points.

|Function group|Functions|
|---|---|
|interpolation|[[get-options]], [[interpolate]]|

Interpolation is done between two n-dimension co-ordinates/points.

It can be used for calculating curves or lines in an n-dimensional spaces
or filling in a colour spectrum between two colours in a colour model.

The following interpolation types are supported:

|Type|Description|
|---|---|
|**linear**| direct linear interpolation|
|**quadratic-bezier**| a quadratic bezier interpolation between to two points and one control point.|
|**cubic-bezier**| a cubic bezier interpolation between the two points, using two control points.|
|**ease-in**| a quadratic bezier interpolation, where the control point is selected using the ease factor and end point.|
|**ease-out**| a quadratic bezier interpolation, where the control point is selected using the ease factor and end point.|
|**ease-in-out**| a cubic bezier interpolation, where the two control points are selected using the ease factors and end point.|
|**step-up**| computes a fix step up for each dimension.|
|**step-down**| computes a fixed step down for each dimension.|

 The variable [[interpolation-types]] is a vector of all the valid interpolation keywords.
raw docstring

nicheware.platform.utilities.common.graphics.line

Functions for with mathematical straight and curved lines:

There are groups of functions and variables within line that deal with:

Function groupFunctions
equationsstraight-line-equation, [[bezier-qudaratic-equation]], bezier-cubic-equation
curve and line building functionsmake-lerp, lerp, [[make-curve-fn-from-sample]], rasterize-bezier-quadratic, interpolate-n-points
  Functions for with mathematical straight and curved lines:

There are groups of functions and variables within line that deal with:

|Function group|Functions|
|---|---|
|equations| [[straight-line-equation]], [[bezier-qudaratic-equation]], [[bezier-cubic-equation]]|
|curve and line building functions| [[make-lerp]], [[lerp]], [[make-curve-fn-from-sample]], [[rasterize-bezier-quadratic]], [[interpolate-n-points]]|
raw docstring

nicheware.platform.utilities.common.math

Functions complementing those in the Clojure/Clojurescript Math namespace.

There are groups of functions and variables within math that deal with:

Function groupFunctions
value manipulationsroundn, round, ceil, floor, div, diff, mult, clamp-change, max-abs
sequence generatorsmake-ratio-sequence-fn, ratio-sequence

Where suitable, uses Math/ functions.

  Functions complementing those in the Clojure/Clojurescript Math namespace.

There are groups of functions and variables within math that deal with:

|Function group|Functions|
|---|---|
|value manipulations| [[roundn]], [[round]], [[ceil]], [[floor]], [[div]], [[diff]], [[mult]], [[clamp-change]], [[max-abs]]|
|sequence generators| [[make-ratio-sequence-fn]], [[ratio-sequence]]|

  Where suitable, uses Math/ functions.
raw docstring

nicheware.platform.utilities.common.state.migration

Functions used when handling migration of state, where state is represented by a Clojure map.

The functions within the migration namespace can be categorised as:

Function groupFunctions
helper functionsmajor-version, minor-version, major-minor-version, could-upgrade-version
migration interfacemigrate-state

The migration functions assume the state map contains a version attribute

  { :version "1.0.1"}

Some functions require a migration map which for each current version defines the migrations that are defined to a later version.

  {"1.0"{:from-version "1.0"
           :to-version "1.1.0"
           :migration-fns [identity]}

   "1.1"{:from-version "1.1"
           :to-version "1.2.0"
           :migration-fns [add-effects/add-pattern-effects]}}

The :migration-fns attribute is a vector of functions that accept the old state map and return a newly migrated state map.

  Functions used when handling migration of state, where state is represented by a Clojure map.

  The functions within the migration namespace can be categorised as:

|Function group|Functions|
|---|---|
|helper functions| [[major-version]], [[minor-version]], [[major-minor-version]], [[could-upgrade-version]]|
|migration interface| [[migrate-state]]|

  The migration functions assume the state map contains a version attribute

```clojure
  { :version "1.0.1"}
```

 Some functions require a migration map which for each current version defines the migrations that are defined
 to a later version.

```clojure
  {"1.0"{:from-version "1.0"
           :to-version "1.1.0"
           :migration-fns [identity]}

   "1.1"{:from-version "1.1"
           :to-version "1.2.0"
           :migration-fns [add-effects/add-pattern-effects]}}
```

The ```:migration-fns``` attribute is a vector of functions that accept the old state map and return a newly migrated state map.
raw docstring

nicheware.platform.utilities.common.version

This namespace provides a set of functions supporting in-memory versioning of a map of assets represented by a clojure map.

There are groups of functions within the version namespace that deal with:

Function groupFunctions
version reference functionsmake-ref-name-fn find-element-with-ref-name, get-current-ref, get-first-asset-ref, replace-element-with-ref-name
version access functionsget-ordered-versions, find-index, current-version-key, get-version, get-current, get-current-asset
version update functionsrename-versions, [[rename-versioned-assets]], timestamp-element, version-element, add-version, replace-current, set-version, mutate-version, delete-version, delete-asset-version, remove-unused-versions

A collection of versioned assets are assumed to be held in an asset map of the form:

{ <asset-key> {:current <modified-time>
              :name <asset-key>
              :versions { <modified-time-1> {<asset-v1> :name <asset-key> :modified-time <modified-time-1> }
                          <modified-time-2> {<asset-v2> :name <asset-key> :modified-time <modified-time-2> }
                        }
             }

 <asset-key-2> ....
}

Each asset has a unique key (asset-key). The key is used to

  • access the asset in the top level map of different assets
  • usually accessible as the :name attribute in the full versioned asset
  • usually accessible as the :name attribute in each of the versions of the asset.

Versioning is done by having a current version (:current) which is a key into different versions of the assets. The keys will normally be the time the version was created.

Functions are provided for adding a new version, removing existing versions etc.

In this simple implementation each version is a full copy of the assets state (any Clojure data structure).

It supports moving through past versions (or undo) simply by changing the modified time referenced by :current.

The functions also support the concept of a version reference, which is a vector of the form

[ <asset-key> <version-number>]

This would be used as reference pointer in any Clojure data type to reference a particular version of an asset.

version-number is normally just the modified time.


This namespace provides a set of functions supporting in-memory versioning of a map of  assets represented
by a clojure map.

There are groups of functions within the version namespace that deal with:

|Function group|Functions|
|---|---|
|version reference functions| [[make-ref-name-fn]] [[find-element-with-ref-name]], [[get-current-ref]], [[get-first-asset-ref]], [[replace-element-with-ref-name]]|
|version access functions| [[get-ordered-versions]], [[find-index]], [[current-version-key]], [[get-version]], [[get-current]], [[get-current-asset]]|
|version update functions| [[rename-versions]], [[rename-versioned-assets]], [[timestamp-element]], [[version-element]], [[add-version]], [[replace-current]], [[set-version]], [[mutate-version]], [[delete-version]], [[delete-asset-version]], [[remove-unused-versions]]|

A collection of versioned assets are assumed to be held in an asset map of the form:

```clojure
{ <asset-key> {:current <modified-time>
              :name <asset-key>
              :versions { <modified-time-1> {<asset-v1> :name <asset-key> :modified-time <modified-time-1> }
                          <modified-time-2> {<asset-v2> :name <asset-key> :modified-time <modified-time-2> }
                        }
             }

 <asset-key-2> ....
}
```

Each asset has a unique key (asset-key). The key is used to

- access the asset in the top level map of different assets
- usually accessible as the ```:name``` attribute in the full versioned asset
- usually accessible as the ```:name``` attribute in each of the versions of the asset.

Versioning is done by having a current version (```:current```) which
is a key into different versions of the assets. The keys will normally be the time the version was created.

Functions are provided for adding a new version, removing existing versions etc.

In this simple implementation each version is a full copy of the assets state (any Clojure data structure).

It supports moving through past versions (or undo) simply by changing the modified time referenced by ```:current```.

The functions also support the concept of a version reference, which is a vector of the form

```clojure
[ <asset-key> <version-number>]
```

This would be used as reference pointer in any Clojure data type to reference a particular version of an asset.

```version-number``` is normally just the modified time.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close