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:
parent
dc74ea1206
commit
d1a71275cb
|
|
@ -34,6 +34,17 @@ n8n Workflow 2 (Reporter)
|
||||||
|
|
||||||
## Ruby Notifier Script (`notify_backup.rb`)
|
## 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)
|
**Location:** `~/.local/bin/notify_backup.rb` (on each machine that runs backups)
|
||||||
|
|
||||||
**Called from backup scripts with named arguments:**
|
**Called from backup scripts with named arguments:**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue