FeedReader. Collector
(FeedReader v0.3.0)
Copy Markdown
Collectors for local feed parsing.
The collector consumes the event stream produced by FeedReader.Parser and
returns a FeedReader.ParseResult. Callers may provide a positive integer
:max_items to stop after collecting that many accepted items. When omitted,
all accepted items are collected. The parser stops after the feed's root
element, so content appended after a complete feed is not parsed.
Binary and chunk-enumerable inputs are written incrementally to a temporary
file before parsing. The temporary file is owned and removed by the collector;
caller-owned files passed to collect/2 are never removed.
Summary
Functions
Collects events from a caller-owned local feed file.
Collects a session and releases its owned source on every outcome.
Validates an optional collection limit.
Collects XML chunks from an enumerable.
Functions
@spec collect(Path.t(), keyword()) :: {:ok, FeedReader.ParseResult.t()} | {:error, term()}
Collects events from a caller-owned local feed file.
The :item_filter option may contain a one-argument function. It is applied
before items are counted and retained. The result contains normalized feed
metadata and the accepted items. When :max_items is reached, parsing stops
and the result's item_limit_reached? field is set to true.
@spec collect_session(FeedReader.Session.t(), keyword()) :: {:ok, FeedReader.ParseResult.t()} | {:error, term()}
Collects a session and releases its owned source on every outcome.
@spec max_items(keyword()) :: {:ok, pos_integer() | nil} | {:error, term()}
Validates an optional collection limit.
Returns {:ok, max_items} for a positive integer, {:ok, nil} when omitted,
and {:error, {:invalid_option, :max_items}} for all other values.
@spec parse_stream(Enumerable.t(), keyword()) :: {:ok, FeedReader.ParseResult.t()} | {:error, term()}
Collects XML chunks from an enumerable.
Chunks must be binaries. They are written incrementally to a library-owned
temporary file, which is removed on success, parser failure, or write
failure. Collection options have the same meaning as collect/2.