diff options
| author | Paul Buetow <paul@buetow.org> | 2025-11-26 23:54:03 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-11-26 23:54:03 +0200 |
| commit | 8ae2053ca15e16c39e9c2aae9cc14c35f213e115 (patch) | |
| tree | 2fd2ec5c36a784987950ef3140e0f1d27d2cdf6d /README.md | |
| parent | b81d86ef9a6e286efdaf7f574a105ab416928551 (diff) | |
update readme with some examples
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 65 |
1 files changed, 65 insertions, 0 deletions
@@ -15,3 +15,68 @@ rake test cd playground rake wireguard -- --debug ``` + +## Examples + +Here are some examples of how to use the DSL. + +### Create a file with content + +```ruby +configure do + file '/tmp/hello_world.txt' do + 'Hello World!' + end +end +``` + +### Create a file from a template + +```ruby +configure do + file '/tmp/calc.txt' do + from template + 'One plus two is <%= 1 + 2 %>!' + end +end +``` + +### Add a line to a file + +```ruby +configure do + file '/tmp/notes.txt' do + line 'Remember to buy milk' + end +end +``` + +### Conditional execution + +```ruby +configure do + given { hostname 'myserver' } + + file '/etc/myserver.conf' do + 'config' + end +end +``` + +### Dependency management + +```ruby +configure do + notify 'service_restart' do + requires file '/etc/config.conf' + # ... logic to restart service + end + + file '/etc/config.conf' do + 'configuration settings' + end +end +``` + +For more examples, check out the [tests](./test/lib/dslkeywords). + |
