DCATR.Manifest.Generator (DCAT-R.ex v0.1.0)

Copy Markdown View Source

Generates DCATR.Manifest files for DCAT-R repositories from EEx templates.

Manifest files define service and repository configuration in RDF files. The generator creates these files from customizable templates, enabling project scaffolding and custom manifest type initialization.

The generator integrates with DCATR.Manifest.LoadPath to determine the target directory and supports EEx templating for dynamic content generation.

Summary

Functions

Returns the default template directory for manifest generation.

Generates the manifest files for a DCATR repository.

Returns the manifest directory path within the project directory.

Functions

default_template_dir()

Returns the default template directory for manifest generation.

Configuration

The default template directory can be configured with the :manifest_template_dir option of the :dcatr application configuration:

config :dcatr, manifest_template_dir: "custom/path"

generate(manifest_type, project_dir, opts \\ [])

@spec generate(DCATR.Manifest.Type.t(), Path.t(), keyword()) :: :ok | {:error, any()}

Generates the manifest files for a DCATR repository.

The project_dir is the root directory of the project where additional directories may be created by custom manifest types. The manifest files themselves will be generated in a subdirectory determined by the last path in the load path.

Options

  • :template - Custom template directory (default: uses manifest_type.generator_template/0)
  • :force - Overwrite existing manifest directory (default: false)
  • :assigns - Keyword list of assigns for EEx templates (e.g., [service_title: "My Service"])

Examples

# Generate default manifests in config/dcatr/
Generator.generate(DCATR.Manifest, "/path/to/project")

# Use custom template with EEx assigns
Generator.generate(
  DCATR.Manifest,
  "/path/to/project",
  template: "/custom/templates",
  assigns: [service_title: "My Service", creator: "http://example.org/me"]
)

manifest_dir(opts \\ [])

@spec manifest_dir(keyword()) :: {:ok, Path.t()} | {:error, any()}

Returns the manifest directory path within the project directory.

The manifest directory is determined from the configured load path. The last path in the load path with the highest precedence is used, since it is the most specific path.

Returns an error if the last path in the load path is absolute, since manifest directories must be relative to the project directory.