View Source Transmogrify.Pathname (transmogrify v2.0.1)

Convert Elixir ModuleName to file/paths.

Summary

Functions

Convert an Elixir's Path.ModuleName.String to path/module_name/string, using the following rules

Functions

@spec convert(atom() | String.t()) :: String.t()

Convert an Elixir's Path.ModuleName.String to path/module_name/string, using the following rules:

  • PascalCase to snake_case rules apply
  • dots are converted to slashes
  • "Elixir." prefix that exists on elixir module atoms is removed
iex> convert("Module")
"module"
iex> convert("ModuleName")
"module_name"
iex> convert("MODULENAME")
"modulename"
iex> convert("ModuleName")
"module_name"
iex> convert("ModuleName.Here")
"module_name/here"
iex> convert("path/name/here")
"path/name/here"
iex> convert(Transmogrify.Pathname)
"transmogrify/pathname"
iex> convert("A.AcronymNAME")
"a/acronym_name"

note: Original code from Macro.underscore()