From 8ae2053ca15e16c39e9c2aae9cc14c35f213e115 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 26 Nov 2025 23:54:03 +0200 Subject: update readme with some examples --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 1c65f5e..03a5ee2 100644 --- a/README.md +++ b/README.md @@ -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). + -- cgit v1.2.3