Liking cljdoc? Tell your friends :D

io.randomseed.bankster.util.importer

Bankster library, import-export operations.

Bankster library, import-export operations.
raw docstring

countries-loadclj

(countries-load)
(countries-load pathname)

Reads CSV file in a format compliant with Joda Money and returns a map with currency to countries associations where countries are sets. The pathname should be relative to the resources directory.

Reads CSV file in a format compliant with Joda Money and returns a map with currency
to countries associations where countries are sets. The pathname should be
relative to the resources directory.
sourceraw docstring

currencies-loadclj

(currencies-load)
(currencies-load pathname)

Reads a CSV file compliant with Joda Money and returns a sequence of currencies.

The pathname should be relative to the resources directory.

Reads a CSV file compliant with Joda Money and returns a sequence of currencies.

The pathname should be relative to the resources directory.
sourceraw docstring

currency->mapclj

(currency->map {:keys [:numeric :scale :kind] :as c})

Takes a currency and returns a map suitable for putting into a configuration file. Extension fields are ignored.

Takes a currency and returns a map suitable for putting into a configuration
file. Extension fields are ignored.
sourceraw docstring

default-countries-csvclj

Default CSV file with countries database.

Default CSV file with countries database.
sourceraw docstring

default-currencies-csvclj

Default CSV file with currencies database.

Default CSV file with currencies database.
sourceraw docstring

default-data-reader-filenameclj

Default data reader filename (pure data).

Default data reader filename (pure data).
sourceraw docstring

default-dump-filenameclj

Default EDN dump file.

Default EDN dump file.
sourceraw docstring

default-export-currency-oriented-filenameclj

Default EDN export file (currency-oriented).

Default EDN export file (currency-oriented).
sourceraw docstring

default-export-filenameclj

Default EDN export file.

Default EDN export file.
sourceraw docstring

default-handlers-namespaceclj

Default namespace of reader handlers.

Default namespace of reader handlers.
sourceraw docstring

default-handlers-pathnameclj

Default pathname of a reader handlers file.

Default pathname of a reader handlers file.
sourceraw docstring

default-legacy-weightclj

Default weight of legacy currencies.

Default weight of legacy currencies.
sourceraw docstring

default-reader-filenamesclj

Default data reader filenames (Clojure code).

Default data reader filenames (Clojure code).
sourceraw docstring

default-resource-must-exist-fileclj

Filename in a default resource container that must exist.

Filename in a default resource container that must exist.
sourceraw docstring

default-resource-nameclj

Name of a default resource container.

Name of a default resource container.
sourceraw docstring

dumpclj

(dump)
(dump registry)
(dump filename registry)

For the given filename (defaults to default-dump-filename) and a registry (defaults to a global registry) creates a dump in EDN format.

Filename will be placed in the default directory of resources (the same directory as config.edn).

For the given filename (defaults to default-dump-filename) and a registry (defaults
to a global registry) creates a dump in EDN format.

Filename will be placed in the default directory of resources (the same directory
as `config.edn`).
sourceraw docstring

edn-importclj

(edn-import)

Alias for io.randomseed.bankster.registry/global.

Alias for `io.randomseed.bankster.registry/global`.
sourceraw docstring

exportclj

(export)
(export registry)
(export filename registry)

For the given filename (defaults to default-export-filename) and a registry (defaults to a global registry) creates a configuration file in EDN format.

Filename will be placed in the default directory of resources (the same directory that holds config.edn).

For the given filename (defaults to default-export-filename) and a registry (defaults
to a global registry) creates a configuration file in EDN format.

Filename will be placed in the default directory of resources (the same directory
that holds `config.edn`).
sourceraw docstring

export-currency-orientedclj

(export-currency-oriented)
(export-currency-oriented registry)
(export-currency-oriented filename registry)

For the given filename (defaults to default-export-currency-oriented-filename) and a registry (defaults to a global registry) creates a currency-oriented configuration file in EDN format.

Currency-oriented export embeds per-currency properties (countries, localized properties and traits) into the maps under :currencies. Top-level branches keep only orphaned entries.

For the given filename (defaults to default-export-currency-oriented-filename) and a
registry (defaults to a global registry) creates a currency-oriented configuration
file in EDN format.

Currency-oriented export embeds per-currency properties (countries, localized
properties and traits) into the maps under `:currencies`. Top-level branches keep
only orphaned entries.
sourceraw docstring

handler-genclj

(handler-gen names)

Generates handler functions for tagged literals for each namespaced currency. Each function will have a prefixed name.

Generates handler functions for tagged literals for each namespaced currency. Each
function will have a prefixed name.
sourceraw docstring

import-seedclj

Filename in a default resource container which is a static seed for data when importing.

Filename in a default resource container which is a static seed for data when
importing.
sourceraw docstring

joda->bankster-dumpclj

(joda->bankster-dump)

Reads Joda Money CSV files and creates a registry dump named resources/io/randomseed/bankster/registry-dump.edn.

Reads Joda Money CSV files and creates a registry dump named
resources/io/randomseed/bankster/registry-dump.edn.
sourceraw docstring

joda->bankster-exportclj

(joda->bankster-export)

Reads Joda Money CSV files and creates a configuration file named resources/io/randomseed/bankster/registry-export.edn.

Reads Joda Money CSV files and creates a configuration file named
resources/io/randomseed/bankster/registry-export.edn.
sourceraw docstring

joda-importclj

(joda-import)
(joda-import countries-pathname currencies-pathname)

Reads CSV files with countries and currencies definitions (Joda Money format) and returns a registry.

Reads CSV files with countries and currencies definitions (Joda Money format) and
returns a registry.
sourceraw docstring

localized->mapclj

(localized->map m)

Takes a localized map entry (1st level) and returns a map suitable for putting into a configuration file.

Takes a localized map entry (1st level) and returns a map suitable for putting into
a configuration file.
sourceraw docstring

map->currency-orientedclj

(map->currency-oriented m)

Takes a configuration map in a branch-oriented shape (as produced by registry->map) and returns a currency-oriented variant.

Per-currency properties are embedded into each currency map under :currencies:

  • :countries (vector of country IDs),
  • :localized (localized properties map),
  • :traits (vector of traits),
  • :weight (currency weight).

Top-level branches :countries, :localized, :traits and :weights are reduced to contain only orphaned entries (i.e. those not associated with any known currency IDs).

Takes a configuration map in a branch-oriented shape (as produced by `registry->map`)
and returns a currency-oriented variant.

Per-currency properties are embedded into each currency map under `:currencies`:
- `:countries` (vector of country IDs),
- `:localized` (localized properties map),
- `:traits`    (vector of traits),
- `:weight`    (currency weight).

Top-level branches `:countries`, `:localized`, `:traits` and `:weights` are reduced
to contain only orphaned entries (i.e. those not associated with any known currency
IDs).
sourceraw docstring

merge-registryclj

(merge-registry dst src)
(merge-registry dst src verbose?)
(merge-registry dst src verbose? preserve-fields)
(merge-registry dst src verbose? preserve-fields iso-like?)

Merges two registries by registering currencies from src into dst.

Hierarchies (stored in :hierarchies) and extension data (stored in :ext) are merged as well.

When verbose? is truthy it prints a message for each currency which is present in src but not in dst.

When preserve-fields is given (a sequence of currency record keys, e.g. [:domain :kind]) and a currency is being replaced in dst, the values of these fields are preserved from the original currency in dst.

Special sentinel keywords may be included in preserve-fields:

  • ::localized preserve localized properties from dst,
  • ::countries preserve assigned countries from dst.

When iso-like? is truthy and the source currency is ISO-like (domain :ISO-4217 or :ISO-4217-LEGACY) then the currency identity is treated as its ISO code (name part of the ID). If the source currency is a legacy ISO currency then its destination ID is normalized to :iso-4217-legacy/CODE and it replaces a previously existing :CODE entry (including migration of attached country mappings and localized properties).

Note: in ISO-like mode :domain is never preserved from dst for ISO-like currencies (even if present in preserve-fields), to allow aligning ISO vs legacy ISO classification based on the source.

Legacy currency weight: when a legacy currency has weight 0 and the weight was not explicitly set (presence in :cur-id->weight) in either source or destination, it is set to default-legacy-weight. Explicit weight 0 is preserved.

Merges two registries by registering currencies from `src` into `dst`.

Hierarchies (stored in `:hierarchies`) and extension data (stored in `:ext`) are
merged as well.

When `verbose?` is truthy it prints a message for each currency which is present in
`src` but not in `dst`.

When `preserve-fields` is given (a sequence of currency record keys, e.g.
`[:domain :kind]`) and a currency is being replaced in `dst`, the values of these
fields are preserved from the original currency in `dst`.

Special sentinel keywords may be included in `preserve-fields`:

- `::localized`  preserve localized properties from `dst`,
- `::countries`  preserve assigned countries from `dst`.

When `iso-like?` is truthy and the source currency is ISO-like (domain
`:ISO-4217` or `:ISO-4217-LEGACY`) then the currency identity is treated as its
ISO code (name part of the ID). If the source currency is a legacy ISO currency
then its destination ID is normalized to `:iso-4217-legacy/CODE` and it replaces
a previously existing `:CODE` entry (including migration of attached country
mappings and localized properties).

Note: in ISO-like mode `:domain` is never preserved from `dst` for ISO-like
currencies (even if present in `preserve-fields`), to allow aligning ISO vs
legacy ISO classification based on the source.

Legacy currency weight: when a legacy currency has weight 0 and the weight was not
explicitly set (presence in `:cur-id->weight`) in either source or destination,
it is set to `default-legacy-weight`. Explicit weight 0 is preserved.
sourceraw docstring

readers-exportclj

(readers-export)
(readers-export registry)
(readers-export registry filenames)
(readers-export registry filenames data-filename)
(readers-export registry
                filenames
                data-filename
                handlers-pathname
                handlers-namespace)

Creates clojure source code files with reader functions for tagged literals handling on a basis of registry information and data reader map files referring to the created handlers.

The purpose of generation is primarily to create handlers for literals in forms of #money/NS[…], where NS is a namespace that corresponds to a namespace of a currency. Possible namespaces are taken from a registry (a map from its field .cur-id->cur).

The function takes a registry (defaults to a global registry if not given), a sequence of reader filenames (defaults to default-reader-filenames), default handlers pathname (defaults to default-handlers-pathname) and default handlers namespace (defaults to default-handlers-namespace).

Default namespace is a namespace in which money handlers will be defined. These handlers will be written to a file which pathname is constructed using the following tactic:

  1. Obtain the directory of the first filename from the given filenames list using Java's resource lookup. The assumption is it should be src directory of a project.

  2. Append the file path passed as the handlers-pathname.

As for data reader map files, their directory name is also based on the lookup of the first filename. Each filename will be populated with the same content which is a map associating tagged literal with a function.

Creates clojure source code files with reader functions for tagged literals handling
on a basis of registry information and data reader map files referring to the
created handlers.

The purpose of generation is primarily to create handlers for literals in forms of
#money/NS[…], where NS is a namespace that corresponds to a namespace of a
currency. Possible namespaces are taken from a registry (a map from its field
.cur-id->cur).

The function takes a registry (defaults to a global registry if not given), a
sequence of reader filenames (defaults to default-reader-filenames), default
handlers pathname (defaults to default-handlers-pathname) and default handlers
namespace (defaults to default-handlers-namespace).

Default namespace is a namespace in which money handlers will be defined. These
handlers will be written to a file which pathname is constructed using the
following tactic:

1. Obtain the directory of the first filename from the given filenames list using
   Java's resource lookup. The assumption is it should be src directory of
   a project.

2. Append the file path passed as the handlers-pathname.

As for data reader map files, their directory name is also based on the lookup of
the first filename. Each filename will be populated with the same content which is
a map associating tagged literal with a function.
sourceraw docstring

registry->mapclj

(registry->map)
(registry->map registry)

Takes a registry and returns a map suitable for putting into a configuration file. Extension fields are ignored. When registry is not given it uses the global one.

Takes a registry and returns a map suitable for putting into a configuration
file. Extension fields are ignored. When registry is not given it uses the global
one.
sourceraw docstring

registry->map-currency-orientedclj

(registry->map-currency-oriented)
(registry->map-currency-oriented registry)

Like registry->map, but produces a currency-oriented configuration map by embedding per-currency properties (countries, localized properties, traits) into the currency maps. Orphaned top-level entries are kept.

Like `registry->map`, but produces a currency-oriented configuration map by
embedding per-currency properties (countries, localized properties, traits) into
the currency maps. Orphaned top-level entries are kept.
sourceraw docstring

seed-importclj

(seed-import)
(seed-import resource-path)

Loads seed data from an EDN resource file (defaults to seed.edn) and returns a registry.

Loads seed data from an EDN resource file (defaults to `seed.edn`) and returns a
registry.
sourceraw docstring

traits->mapclj

(traits->map traits)

Takes a traits set/vector and returns a representation suitable for putting into a configuration file.

Takes a traits set/vector and returns a representation suitable for putting into a
configuration file.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close