View Source SayCheezEx.Graphs.Provider behaviour (say_cheez_ex v0.3.1)

The interface for a graph provider.

  • checks if a such a provider is available, given the providers' own configuration
  • renders a graph to some HTML that can be embedded

Link to this section Summary

Functions

Given a recipe s for a graph, first tries a cache and then call a "builder" function to create it.

Runs an external command.

Computes a printable SHA for a string.

Link to this section Callbacks

@callback render(String.t()) :: {:ok, String.t()} | {:ko, any()}

..

Link to this section Functions

Link to this function

rebuild_if_needed(s, extension, fnBuilder)

View Source

Given a recipe s for a graph, first tries a cache and then call a "builder" function to create it.

So if the SVG was already generated, we load it from disk - if not, we build it again.

builder

Builder

The builder expects a file on disk where the source recipe is. This is useful because local commands read from a file and write to a file.

It returns {:ok, svg_text} or {:error, reason} that will be used to display a result.

Link to this function

run_cmd(cmd, parameters)

View Source

Runs an external command.

It returns a binary that captures STDOUT if all went well, or a tuple {:error, e} if something went bonkers.

If it's trying to call a command that does not exist on your local environment, returns {:error, :cmd_not_found}.

Computes a printable SHA for a string.