From ebb268ebb1b5acc8ccc54d92a115896a95e8bbb1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 1 Mar 2026 20:28:00 +0200 Subject: update quickstart examples in README to reflect LoadError fallback and gem usage --- README.md | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c2c480d..7d8dfe8 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,30 @@ This software has been written by a human by 90%, and only the last 10% were AI See [examples/rake/](examples/rake/) for a working example. +```ruby +# Rakefile +begin + require 'rcm' +rescue LoadError + require_relative '/path/to/rcm/lib/dsl' +end + +task :setup do + configure do + given { hostname is :earth } + + file '/tmp/wg0.conf' do + from template + 'interface = <%= "wg0" %>' + end + end +end +``` + ```sh -cd playground -rake wireguard -- --dry -rake wireguard -- --debug +cd examples/rake +rake setup -- --dry +rake setup -- --debug ``` ### As a Gem (from any directory) @@ -58,24 +78,22 @@ gem 'rcm', path: '~/git/rcm' ``` ```ruby -# Rakefile +# config.rb require 'rcm' -task :setup do - configure do - given { hostname is :earth } +configure do + given { hostname is :earth } - file '/tmp/wg0.conf' do - from template - 'interface = <%= "wg0" %>' - end + file '/tmp/wg0.conf' do + from template + 'interface = <%= "wg0" %>' end end ``` ```sh bundle install -bundle exec rake setup -- --dry +bundle exec ruby config.rb --dry ``` ### Plain Ruby Script @@ -84,7 +102,11 @@ See [examples/plain_ruby/](examples/plain_ruby/) for a working example. ```ruby #!/usr/bin/env ruby -require 'rcm' +begin + require 'rcm' +rescue LoadError + require_relative '/path/to/rcm/lib/dsl' +end configure do file '/tmp/hello.txt' do -- cgit v1.2.3