Rho.Tools.DynCopy (rho v0.1.0)

Copy Markdown View Source

Core tool: copy a staged Dyn source file to a new path under a new module name (see Rho.Tools.DynTool).

It exists for speed. Starting a screen from a library widget by retyping it costs a whole file of output tokens; a copy costs one call, and the reply is the new file numbered as dyn_read shows it, so the next step is dyn_edit straight away.

The rename is textual: every whole occurrence of the file's first module's full name, Old and Old.Sub alike, becomes the new one. A name that merely starts with it (OldOther) is left alone.

Summary

Functions

The module name for a staged path: screens/date_slider.ex is Dyn.Screens.DateSlider (in the namespace, Rho.Dyn.Config).

source with every whole occurrence of module name old (alone, before ., or root-qualified as Elixir.<old>) replaced by new.

Functions

module_for(path)

@spec module_for(String.t()) :: String.t()

The module name for a staged path: screens/date_slider.ex is Dyn.Screens.DateSlider (in the namespace, Rho.Dyn.Config).

rename(source, old, new)

@spec rename(String.t(), String.t(), String.t()) :: String.t()

source with every whole occurrence of module name old (alone, before ., or root-qualified as Elixir.<old>) replaced by new.