View Source DeepSinker (deep_sinker v0.1.1)

Documentation for DeepSinker.

Link to this section Summary

Functions

Create initial state.

Pop file and update state.

Stream filepaths.

Link to this section Types

@type filepath() :: String.t()
@type handler() :: (item_path() -> item_type())
@type item_path() :: String.t()
@type item_type() :: :file | :directory | :ignore
@type opt() :: [order: :asc | :desc, handler: handler()]
@type order() :: :asc | :desc
@type result() :: {:ok, filepath()} | :done
@type t() :: %DeepSinker{
  found_items: [item_path()],
  handler: handler() | nil,
  order: order(),
  root_items: [item_path()]
}

State of traversing.

Link to this section Functions

Link to this function

new(root_items, opt \\ [])

View Source
@spec new([item_path()], opt()) :: t()

Create initial state.

examples

Examples

iex> DeepSinker.new(["/path/to/dir1", "/path/to/dir2"])
...> |> is_struct(DeepSinker)
true

iex> DeepSinker.new(["/path/to/dir1", "/path/to/dir2"],
...>   order: :desc,
...>   handler: fn item_path ->
...>     cond do
...>       item_path == ".git" -> :ignore
...>       String.contains?(item_path, ".") -> :file
...>       true -> :directory
...>     end
...>   end
...> )
...> |> is_struct(DeepSinker)
true
@spec next(t()) :: {t(), result()}

Pop file and update state.

@spec stream(t()) :: Stream.t(filepath())

Stream filepaths.