docs(backups): add OOP/Sandi Metz principles to Ruby notifier spec

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jared 2026-05-07 10:33:51 -04:00
parent dc74ea1206
commit d1a71275cb
1 changed files with 11 additions and 0 deletions

View File

@ -34,6 +34,17 @@ n8n Workflow 2 (Reporter)
## Ruby Notifier Script (`notify_backup.rb`)
### Design principles
- **Sandi Metz OOP:** Small, single-purpose objects. Each class has one reason to change. Dependencies injected, not hardcoded. No class does more than one job.
- **Self-documenting:** The script's header comment explains its purpose, all accepted arguments, exit behavior, and required ENV vars — enough for any future backup process to integrate without reading the implementation.
- **Classes:**
- `BackupNotifier` — orchestrates the flow; the only public entry point
- `PayloadBuilder` — converts raw CLI args into a clean hash (formats bytes, validates status)
- `WebhookClient` — handles the HTTP POST with auth header; knows nothing about backup data
- `ByteFormatter` — single responsibility: raw integer → human-readable string
- CLI argument parsing at the top level (OptionParser), outside of classes
**Location:** `~/.local/bin/notify_backup.rb` (on each machine that runs backups)
**Called from backup scripts with named arguments:**