Posexional.File (posexional v1.2.0)

View Source

a Posexional.File is the main struct to manage a positional file

Summary

Types

t()

@type t() :: %Posexional.File{rows: term(), separator: term()}

Functions

find_row(file, name)

@spec find_row(t(), atom()) :: Posexional.Row.t()

get_counters(file)

@spec get_counters(t()) :: [{atom(), pid()}]

manage_counters(file)

@spec manage_counters(t()) :: t()

adds a generator for every progressive_number_field in the file.

The fields are grouped by name, so that you can specify many counters for every row

new(rows, separator \\ nil)

read(file, content)

@spec read(t(), binary()) :: [tuple() | String.t()]

stream(str, file)

@spec stream(Enumerable.t(), t()) :: Enumerable.t()

write(file, values)

@spec write(t(), Keyword.t()) :: binary()

creates a file from values

Examples

iex> write(
...>   Posexional.File.new([ Posexional.Row.new(:row_test, [ Posexional.Field.Value.new(:test1, 5) ]) ]),
...>   [row_test: [test1: "test"], row_test: [test1: "t"]]
...> )
"test \nt    "

iex> write(
...>   Posexional.File.new([ Posexional.Row.new(:row_test, [ Posexional.Field.Value.new(:test1, 5) ]) ]),
...>   [row_test: [test1: "test"], ne: [test1: "t"]]
...> )
** (RuntimeError) row ne not found

write_path!(file, values, path)

@spec write_path!(t(), Keyword.t(), binary()) :: {:ok, binary()} | {:error, any()}