Core NamingConvention and Context protocols + default
implementations and helpers.
Core `NamingConvention` and `Context` protocols + default implementations and helpers.
IOFactory + things that are missing if we want to be able to discover & move files.
IOFactory + things that are missing if we want to be able to discover & move files.
(delete this)(delete this spec)In the one-arg version, delete the context root after checking that
there's nothing under it. In the two-arg version, delete the file
described by spec.
In the one-arg version, delete the context root after checking that there's nothing under it. In the two-arg version, delete the file described by `spec`.
(info this spec)Whatever information is available. Recommended to include {:size <n bytes> :last-modified <ms timestamp>}
Whatever information is available. Recommended to include
{:size <n bytes>
:last-modified <ms timestamp>}(io this spec)Get an IOFactory for the data described by spec.
Get an IOFactory for the data described by `spec`.
(list this)(list this opts)List the file specifications that can be discovered within this context.
Default implementation accepts a strict? option that defaults to false,
but if true, breaks upon encountering a file that doesn't match the context's
naming convention.
List the file specifications that can be discovered within this context. Default implementation accepts a `strict?` option that defaults to false, but if true, breaks upon encountering a file that doesn't match the context's naming convention.
(resolve this spec)Resolve the spec by rendering its path in a way appropriate for the context. Useful for REPL exploration.
Resolve the spec by rendering its path in a way appropriate for the context. Useful for REPL exploration.
A helper to copy from one Context to another. Allows specific
implementations by Context type, but by default copies from one's
(io/input-stream) to the other's (io/output-stream).
f: (from-spec, to-spec, from-context, to-context) => side effects
A helper to copy from one `Context` to another. Allows specific implementations by `Context` type, but by default copies from one's (io/input-stream) to the other's (io/output-stream). f: (from-spec, to-spec, from-context, to-context) => side effects
(file-convention base-name-convention ext-convention)The naming convention for a file's base name & its extension.
Everything after the first '.' in the last part of the path is considered the extension. E.g. foo.log.gz has the extension log.gz.
The naming convention for a file's base name & its extension. Everything after the first '.' in the last part of the path is considered the extension. E.g. foo.log.gz has the extension log.gz.
(local-context root)(local-context root naming-convention)A Context that discovers files & performs IO on the local filesystem.
If no naming-convention argument is given, takes plain string paths (e.g.
root/foo/bar/baz.log).
The root is a relative path to the directory under which the given
naming-convention applies.
A `Context` that discovers files & performs IO on the local filesystem. If no `naming-convention` argument is given, takes plain string paths (e.g. root/foo/bar/baz.log). The `root` is a relative path to the directory under which the given `naming-convention` applies.
A bidirectional mapping between a file specification and a file path.
The file specification is anything sufficient to precisely describe a file and the path is the thing we need to store or retrieve the file's data within the storage context.
The spec is usually a map and the path is normally a vector of path parts -- e.g. ['user' 'data' 'my-file.log'] -- that can be assembled in different contexts.
A bidirectional mapping between a file specification and a file path. The file specification is anything sufficient to precisely describe a file and the path is the thing we need to store or retrieve the file's data within the storage context. The spec is usually a map and the path is normally a vector of path parts -- e.g. ['user' 'data' 'my-file.log'] -- that can be assembled in different contexts.
(path->spec this path)(spec->path this spec)(path-convention & parts)Create a naming convention from different path parts, the last of which is the file's base name & extension.
Each part is a map with attributes :in and :out, where :in takes a path part string and returns a map of attributes from that part and :out takes an attribute map and produces a string.
Keywords are 'getters/setters' for their attributes, and strings are treated as constants.
Create a naming convention from different path parts, the last of which is the file's base name & extension. Each part is a map with attributes :in and :out, where :in takes a path part string and returns a map of attributes from that part and :out takes an attribute map and produces a string. Keywords are 'getters/setters' for their attributes, and strings are treated as constants.
(split-by d & parts)A part of a path that's split by the character / single character string d.
(Obviously, that means that none of the parts may contain d.)
For example, a path part called 'name_yyyy-MM-dd' is a :name attribute and a timestamp split by the '' character, so we'd define it as: (split-by "" :name (utc :ts "yyyy-MM-dd"))
A part of a path that's split by the character / single character string `d`. (Obviously, that means that none of the `parts` may contain `d`.) For example, a path part called 'name_yyyy-MM-dd' is a :name attribute and a timestamp split by the '_' character, so we'd define it as: (split-by "_" :name (utc :ts "yyyy-MM-dd"))
(test-with {:keys [context spec resolved desc] :as file-a} file-b)Test all of the Context methods on two files of the same or different
contexts. Must be run within a `clojure.test/deftest.
Each file is a map composed of
Note that the given :contexts must be empty (use a test directory).
Test all of the `Context` methods on two files of the same or different contexts. Must be run within a `clojure.test/deftest. Each file is a map composed of - :context A Context implementation. - :spec A file spec for the :context. - :resolved The expected response for (resolve :context :spec). - :desc A quick description, e.g. 'default local context'. Note that the given :contexts must be empty (use a test directory).
(utc attribute format)A bidirectional UTC date formatter/parser, that formats the contents of
attribute as a string using format, or parses the string into attribute
on the way back in.
Only as precise as the format string allows for.
E.g. ((:out (utc :ts "MMM")) {:ts (System/currentTimeMillis)}) ; => "Apr"
((:in (utc :ts "MMM")) "Apr") ; => {:ts 7776000000}
A bidirectional UTC date formatter/parser, that formats the contents of
`attribute` as a string using `format`, or parses the string into `attribute`
on the way back in.
Only as precise as the format string allows for.
E.g.
((:out (utc :ts "MMM")) {:ts (System/currentTimeMillis)})
; => "Apr"
((:in (utc :ts "MMM")) "Apr")
; => {:ts 7776000000}cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |