io.randomseed.bankster.util.importer
countries-load
added in 1.0.0
(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 as sets. The pathname should be relative to resources directory.
currencies-load
added in 1.0.0
(currencies-load)
(currencies-load pathname)
Reads CSV file compliant with Joda Money and returns a map with currency ID (keyword) as a key and currency data as its value (vector). The pathname should be relative to resources directory.
currency->map
added in 1.0.0
(currency->map {:keys [:numeric :scale :kind :weight]})
Takes a currency and returns a map suitable for putting into a configuration file. Extensions fields are ignored.
default-resource-must-exist-file
added in 1.0.0
Filename in a default resource container that must exist.
dump
added in 1.0.0
(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 that which config.edn).
export
added in 1.0.0
(export)
(export registry)
(export filename registry)
For the given filename (defaults to default-dump-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 which holds config.edn).
handler-gen
(handler-gen names)
Generates handler functions for tagged literals for each namespaced currency. Each function will have a prefixed name.
joda->bankster-dump
added in 1.0.0
(joda->bankster-dump)
Reads Joda Money CSV files and creates a registry dump named resources/io/randomseed/bankster/registry-dump.edn.
joda->bankster-export
added in 1.0.0
(joda->bankster-export)
Reads Joda Money CSV files and creates a configuration file named resources/io/randomseed/bankster/registry-export.edn.
joda-import
added in 1.0.0
(joda-import)
(joda-import countries-pathname currencies-pathname)
Reads CSV files with countries and currencies definitions (Joda Money format) and returns a registry.
localized->map
added in 1.0.0
(localized->map m)
Takes a localized map entry (1st level) and returns a map suitable for putting into a configuration file.
readers-export
added in 1.0.0
(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 primary 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:
-
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.
-
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.
registry->map
added in 1.0.0
(registry->map)
(registry->map registry)
Takes a registry and returns a map suitable for putting into a configuration file. Extensions fields are ignored. When registry is not given it uses the global one. Extension fields are ignored.