Ragex.Watcher (Ragex v0.37.2)

View Source

Watches directories for file changes and automatically re-analyzes modified files.

Uses FileSystem to monitor for changes and triggers re-analysis on supported files. By default, only monitors directories containing source files (such as lib and test) and ignores non-source directories like .git, _build, and deps.

Configuration

Directories to watch can be configured in your application configuration:

config :ragex, watcher: [dirs: ["lib", "test"]]

Or:

config :ragex, :watcher,
  dirs: ["lib", "test"]

Summary

Functions

Returns a specification to start this module under a supervisor.

Lists all currently watched directories.

Resolves the directories that should be watched for a given path.

Stops watching a directory (and any of its watched subdirectories).

Starts watching a directory for changes.

Checks if a directory or any of its subdirectories is currently watched.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

contains_source_files?(dir, max_depth \\ 3)

@spec contains_source_files?(String.t(), integer()) :: boolean()

default_exclude_dirs()

@spec default_exclude_dirs() :: [String.t()]

default_source_dirs()

@spec default_source_dirs() :: [String.t()]

list_watched()

@spec list_watched() :: [String.t()] | {:error, term()}

Lists all currently watched directories.

resolve_watch_directories(path, opts \\ [])

@spec resolve_watch_directories(String.t(), keyword()) :: [String.t()]

Resolves the directories that should be watched for a given path.

Accepts :dirs via options, or falls back to :ragex, watcher: [dirs: [...]] configuration, or standard source directories (like lib and test).

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

unwatch_directory(path)

@spec unwatch_directory(String.t()) :: :ok | {:error, term()}

Stops watching a directory (and any of its watched subdirectories).

watch_directory(path, opts \\ [])

@spec watch_directory(String.t(), keyword()) :: :ok | {:error, term()}

Starts watching a directory for changes.

By default, if path contains source directories (like lib and test), only those source directories are watched, preventing directories like .git from being monitored.

Options

  • :dirs - Explicit list of subdirectories or paths to watch.
  • :only_source_dirs (or :source_only) - When true (default), only source directories like lib and test are monitored. When false, watches path directly without filtering.

watching?(path)

@spec watching?(String.t()) :: boolean()

Checks if a directory or any of its subdirectories is currently watched.