Sow.Graph (Sow v0.1.4)

Copy Markdown View Source

Builds a dependency graph from fixture modules and provides topological sorting for correct sync order.

Dependencies are extracted from:

  • relation/1 and relation/3 calls (must sync before parent)
  • nested/2 calls (must sync after parent, but module itself may have deps)

Summary

Functions

Build the correct sync order for a list of fixture modules. Returns modules in order such that dependencies come before dependents.

Extract all dependencies from a fixture module.

Sync multiple fixture modules in dependency order.

Functions

build_order(modules)

@spec build_order([module()]) :: {:ok, [module()]} | {:error, {:cycle, [module()]}}

Build the correct sync order for a list of fixture modules. Returns modules in order such that dependencies come before dependents.

dependencies(module)

@spec dependencies(module()) :: [module()]

Extract all dependencies from a fixture module.

sync_in_order(modules, repo)

@spec sync_in_order([module()], module()) :: {:ok, map()} | {:error, term()}

Sync multiple fixture modules in dependency order.

Builds a dependency graph, topologically sorts it, and syncs each module.