Dockerignore (Dockerignore v0.1.0)

Copy Markdown View Source

A .dockerignore matcher for Elixir with semantics pinned to moby/patternmatcher v0.6.1.

Examples

iex> source = "_build/\n*.log\n!important.log"
iex> {:ok, patterns} = Dockerignore.parse(source)
iex> Enum.map(patterns, & &1.pattern)
["_build", "*.log", "important.log"]
iex> matcher = Dockerignore.compile!(source)
iex> Dockerignore.ignored?(matcher, "_build/app.beam")
true
iex> Dockerignore.ignored?(matcher, "important.log")
false

Summary

Functions

compile(source)

@spec compile(binary()) ::
  {:ok, Dockerignore.Matcher.t()} | {:error, Dockerignore.Error.t()}

compile!(source)

@spec compile!(binary()) :: Dockerignore.Matcher.t()

explain(matcher, path)

@spec explain(Dockerignore.Matcher.t(), binary()) ::
  {:ignored, Dockerignore.Pattern.t()}
  | {:kept, Dockerignore.Pattern.t() | :no_match}

filter(matcher, paths)

@spec filter(Dockerignore.Matcher.t(), Enumerable.t()) :: [binary()]

ignored?(matcher, path)

@spec ignored?(Dockerignore.Matcher.t(), binary()) :: boolean()

parse(source)

@spec parse(binary()) ::
  {:ok, [Dockerignore.Pattern.t()]} | {:error, Dockerignore.Error.t()}

parse!(source)

@spec parse!(binary()) :: [Dockerignore.Pattern.t()]