Tayori.Source behaviour (Tayori v0.1.0)

Copy Markdown View Source

Where the changes of the inbox come from: a file of the app, a folder of files, a service. A source is a module with changes/1, named in the :sources of the :inbox config with its options:

inbox: [
  sources: [
    {Tayori.Sources.Changelog, path: {:my_app, "priv/CHANGELOG.md"}},
    {Tayori.Sources.Fragments, path: {:my_app, "priv/news"}},
    {MyApp.ReleaseNotes, url: "https://..."}
  ]
]

Tayori reads them when the app starts (:ingest_on_start) and when Tayori.Inbox.ingest/0 is called. A change a source gives again, with the same :ref, is not added twice, so a source gives all it has each time.

Tayori has two: Tayori.Sources.Changelog (a Keep a Changelog file) and Tayori.Sources.Fragments (a folder of Markdown files, as Changesets and towncrier write them).

Summary

Types

A change as a source gives it: the attributes of Tayori.Change, with string or atom keys. :ref and :title are needed.

Callbacks

The changes the source has now, all of them.

The name of the source, for Tayori.Change's :source (the module's last part, lowercased).

Functions

The path of a source's file or folder: an absolute path; a path relative to the current directory; or {otp_app, path}, relative to the app's directory (Application.app_dir/2), which is where a release keeps priv/.

Types

change()

@type change() :: map()

A change as a source gives it: the attributes of Tayori.Change, with string or atom keys. :ref and :title are needed.

Callbacks

changes(opts)

@callback changes(opts :: keyword()) :: {:ok, [change()]} | {:error, term()}

The changes the source has now, all of them.

name(opts)

(optional)
@callback name(opts :: keyword()) :: String.t()

The name of the source, for Tayori.Change's :source (the module's last part, lowercased).

Functions

path(path)

@spec path(Path.t() | {atom(), Path.t()}) :: Path.t()

The path of a source's file or folder: an absolute path; a path relative to the current directory; or {otp_app, path}, relative to the app's directory (Application.app_dir/2), which is where a release keeps priv/.