$ show anteo/redmine_custom_workflows
This is a Redmine plugin that allows administrators to define custom Ruby scripts that execute on lifecycle events (before_save, after_save, before_destroy, after_destroy, etc.) for various Redmine objects such as Issue, User, Group, Project, Attachment, TimeEntry, Version, WikiContent, and more. It uses Rails monkey-patching (prepend) to inject callbacks into Redmine models and controllers, and executes user-defined scripts via `instance_eval` in the context of the observed object. The plugin provides a web UI for managing workflows, supports import/export via XML, and includes a custom mailer for sending emails from workflows. It is well-structured, has comprehensive tests, localization support, and CI integration. The codebase is mature and actively maintained, targeting Redmine 6.x and Rails 8.1.
The LLM identified 2 files worth highlighting for reuse:
Provides a reusable pattern for sending custom emails from within workflow scripts. The `deliver_custom_email` class method accepts a user and headers hash, supporting plain text body, HTML body, or a named template with parameters. This pattern can be extracted to any Rails application that needs to send flexible emails from business logic, decoupling email content from the mailer class.
A simple custom exception class (`RedmineCustomWorkflows::Errors::WorkflowError`) that is raised by user scripts to signal a workflow error. It inherits from StandardError and is caught by the workflow runner to add validation errors to the object. This pattern is a clean way to define domain-specific exceptions that can be reused in any Ruby project.