Glob pattern matching for Elixir module names.
Module names are treated as dot-separated segments, and glob patterns follow these semantics:
| Pattern | Matches |
|---|---|
"MyApp.Orders.*" | Direct children only (MyApp.Orders.Order) |
"MyApp.Orders.**" | All descendants at any depth |
"MyApp.Orders" | Exact match only |
"**.*Service" | Any module whose last segment ends with Service |
"**.*Service*" | Any module whose last segment contains Service |
"MyApp.**.*Repo" | Under MyApp, last segment ends with Repo |
"**" | All modules |
Summary
Functions
Compiles a glob pattern string into a Regex.
** matches one or more dot-separated segments (any depth).
* within a single segment matches any characters except ..
Filters a list of modules/module name strings to those matching pattern.
Returns true if module_name matches pattern.
Accepts either a pattern string or a pre-compiled Regex.
Examples
iex> ArchTest.Pattern.matches?("MyApp.Orders.*", "MyApp.Orders.Order")
true
iex> ArchTest.Pattern.matches?("MyApp.Orders.*", "MyApp.Orders.Schemas.Order")
false
iex> ArchTest.Pattern.matches?("MyApp.Orders.**", "MyApp.Orders.Schemas.Order")
true
iex> ArchTest.Pattern.matches?("**.*Service", "MyApp.Orders.OrderService")
true
iex> ArchTest.Pattern.matches?("**.*Service", "MyApp.Orders.OrderServiceHelper")
false
Converts a module atom to its string representation without the Elixir. prefix.