Reed.Transformers (reed v0.1.0)

Convenient transformer functions to be used during parsing with Reed.Handler.

When composing functions from Reed.Transformers, be aware that order matters and is preserved.

For example, if you use transform_item/2 and collect/2 in your pipeline, in order for collect/2 to collect the transformed version of the item it must come after transform_item/2.

Summary

Functions

Collects all items into a list.

Halt the RSS streaming after the current item.

Keeps track of how many RSS feed items have been processed and will halt the stream after the given # of RSS feed items have been processed.

A convenient macro that will format take your pipeline correctly if you have a pipeline composed entirely of functions with the following function signature: (state::state, opts::list() \ [])

Transforms the current RSS feed item according to the given an arity-1 transformation function.

Types

@type state() :: map()
Link to this type

transformer()

@type transformer() :: (state() -> state())

Functions

Collects all items into a list.

The final list will be under the :items key in the state, and will be in reverse order.

Halt the RSS streaming after the current item.

Link to this function

limit(state, count)

Keeps track of how many RSS feed items have been processed and will halt the stream after the given # of RSS feed items have been processed.

Link to this macro

transform(pipeline)

(macro)

A convenient macro that will format take your pipeline correctly if you have a pipeline composed entirely of functions with the following function signature: (state::state, opts::list() \ [])

This is the function signature that all transformer functions within Reed.Transformers have.

This macro should always be called last in a transformation pipeline.

Example

The following two are equivalent:

Reed.get!(url, transform:
  fn state ->
    state
    |> stop_after(1)
    |> collect()
  end
)
Reed.get!(url, transform:
  stop_after(1)
  |> collect()
  |> transform()
)
Link to this function

transform_item(state, transformer)

Transforms the current RSS feed item according to the given an arity-1 transformation function.