Installation
Requirements
- Ruby 3.2 or higher
- Optional: ActiveRecord (for database persistence)
Install via Gemfile
Add Ruleur to your Gemfile:
ruby
gem 'ruleur'Then run:
bash
bundle installInstall via gem command
bash
gem install ruleurVerify Installation
Create a test file test_ruleur.rb:
ruby
require 'ruleur'
engine = Ruleur.define do
rule 'hello' do
conditions do
any?(truthy?(true))
end
actions do
set :greeting, 'Hello Ruleur!'
end
end
end
ctx = engine.run
puts ctx[:greeting] # => "Hello Ruleur!"Run it:
bash
ruby test_ruleur.rbIf you see "Hello Ruleur!", you're ready to go!
Optional: Database Setup
If you plan to store rules in a database with version tracking, you'll need ActiveRecord:
ruby
# Gemfile
gem 'activerecord'
gem 'pg' # or your database adapterGenerate migrations:
ruby
require 'ruleur/generators/migration_generator'
Ruleur::Generators::MigrationGenerator.write_migrations('db/migrate')This creates:
create_ruleur_rules.rb- Main rules tablecreate_ruleur_rule_versions.rb- Version history table
Run migrations:
bash
bundle exec rake db:migrateProject Structure
For a typical Rails project:
your_app/
├── app/
├── config/
│ └── rules/ # YAML rule files
│ ├── permissions/
│ └── workflows/
├── lib/
│ └── rules/ # Ruby DSL rules (if not using YAML)
└── spec/
└── rules/ # Rule testsFor non-Rails projects:
your_project/
├── rules/
│ ├── dsl/ # Ruby DSL rule definitions
│ └── yaml/ # YAML rule files
├── lib/
└── spec/Next Steps
Now that Ruleur is installed, let's create your first rule: