View Source CozyPublisher.Adapter behaviour (CozyPublisher v2.0.0)

The specification of adapters.

Link to this section Summary

Types

The attributes parsed from file.

The body parsed from file.

The content of file.

The option for current adapter.

The path of file.

Callbacks

Prepares for future works, such as

Parses the content of files.

Transforms the parsed body.

Link to this section Types

@type attrs() :: map()

The attributes parsed from file.

@type body() :: binary()

The body parsed from file.

@type content() :: binary()

The content of file.

@type opts() :: keyword()

The option for current adapter.

@type path() :: binary()

The path of file.

Link to this section Callbacks

@callback init(opts()) :: :ok

Prepares for future works, such as:

  • checking required dependencies
  • starting necessary applications
Link to this callback

parse(path, content, opts)

View Source
@callback parse(path(), content(), opts()) :: {attrs(), body()} | [{attrs(), body()}]

Parses the content of files.

It must return:

  • a 2 element tuple with attributes and body - {attrs, body}
  • a list of 2 element tuple with attributes and body - [{attrs, body} | _]

Link to this callback

transform(path, body, opts)

View Source
@callback transform(path(), body(), opts()) :: any()

Transforms the parsed body.