CodeStory.Modules (CodeStory v0.1.0)

Copy Markdown View Source

Auto-detects user-defined modules from the host project's mix.exs app name.

Summary

Functions

Converts an app atom to its expected module prefix string.

Detects user-defined modules from the current Mix project.

Filters the given modules to those that are Ecto repos.

Functions

camelize_app_name(app)

Converts an app atom to its expected module prefix string.

Examples

iex> CodeStory.Modules.camelize_app_name(:my_app)
"MyApp"

detect()

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

Detects user-defined modules from the current Mix project.

Returns a list of modules whose top-level namespace matches the app name from Mix.Project.config()[:app], including the app's Web namespace (e.g. :my_app matches MyApp.* and MyAppWeb.*, the conventional Phoenix split).

ecto_repos(modules)

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

Filters the given modules to those that are Ecto repos.

Detection is runtime duck-typing — a repo is any module exporting __adapter__/0 (which use Ecto.Repo defines). CodeStory has no compile-time dependency on Ecto.

Code.ensure_loaded?/1 is required: function_exported?/3 returns false for a merely-loadable-but-unloaded module and will not load it, and detection can run before the tracer forces modules to load.