diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-01 20:28:00 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-01 20:28:00 +0200 |
| commit | ebb268ebb1b5acc8ccc54d92a115896a95e8bbb1 (patch) | |
| tree | bb78af1bfaf6f4f378433118a5e8e1a55af01585 /README.md | |
| parent | 1f5410ae2d117f2904373eedbeb762f7a02b421a (diff) | |
update quickstart examples in README to reflect LoadError fallback and gem usagev0.1.0
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 48 |
1 files changed, 35 insertions, 13 deletions
@@ -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 |
