Cruise
A fast, OS-native file watcher for Ruby.
A file system watcher built on native OS events, not polling.
Uses FSEvents on macOS and inotify on Linux.
Cruise was originally built to power file watching in the [Herb](https://herb-tools.dev) dev server, none of the existing Ruby watchers were quite reliable enough for the realtime hot reloading that a local development server and workflow needs. It also works standalone for any project that needs to react to file changes.
## Installation
**Add to your Gemfile:**
```ruby
gem "cruise"
```
**Or install directly:**
```bash
gem install cruise
```
Precompiled native gems are available for macOS and Linux. If a precompiled gem isn't available for your platform, it will compile from source (requires Rust).
## Usage
### Basic Example
Watch a directory for changes:
```ruby
require "cruise"
Cruise.watch("app/views") do |event|
puts "#{event.kind}: #{event.path}"
end
```
The callback receives a `Cruise::Event` with two attributes:
| Attribute | Description |
|--------------|----------------------------------------------------------------------------------------|
| `event.path` | Absolute path to the changed file |
| `event.kind` | One of: `"created"`, `"modified"`, `"renamed"`, `"removed"`, `"accessed"`, `"changed"` |
### Multiple Directories
Watch several paths at once:
```ruby
Cruise.watch("app/views", "app/components", "lib/templates") do |event|
puts event.inspect
# => #