# `ArchTest.Pattern`
[🔗](https://github.com/yoavgeva/arch_test/blob/v0.2.0/lib/arch_test/pattern.ex#L1)

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 |

# `compile`

```elixir
@spec compile(String.t()) :: Regex.t()
```

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 `.`.

# `filter`

```elixir
@spec filter([module() | String.t()], String.t()) :: [module() | String.t()]
```

Filters a list of modules/module name strings to those matching `pattern`.

# `matches?`

```elixir
@spec matches?(String.t() | Regex.t(), String.t() | module()) :: boolean()
```

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

# `module_to_string`

```elixir
@spec module_to_string(module()) :: String.t()
```

Converts a module atom to its string representation without the `Elixir.` prefix.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
