diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-01 20:24:45 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-01 20:24:45 +0200 |
| commit | 92ba0576ebf8aaf770368eba4533d3c4ed4a5e37 (patch) | |
| tree | 51179df29a4ebb77214bf902580da0e619446a72 /examples/gem | |
| parent | e17fbbfb30da394d6abbb91da4a963ff8913ad47 (diff) | |
replace gem example with bundle exec ruby, distinct from rake example
Diffstat (limited to 'examples/gem')
| -rw-r--r-- | examples/gem/Gemfile | 1 | ||||
| -rw-r--r-- | examples/gem/Gemfile.lock | 24 | ||||
| -rw-r--r-- | examples/gem/README.md | 11 | ||||
| -rw-r--r-- | examples/gem/Rakefile | 27 | ||||
| -rwxr-xr-x | examples/gem/config.rb | 21 |
5 files changed, 51 insertions, 33 deletions
diff --git a/examples/gem/Gemfile b/examples/gem/Gemfile index 7e62d34..b1f79ad 100644 --- a/examples/gem/Gemfile +++ b/examples/gem/Gemfile @@ -2,4 +2,3 @@ source 'https://rubygems.org' # Point at the local rcm checkout; change to gem 'rcm' once published. gem 'rcm', path: '../../' -gem 'rake' diff --git a/examples/gem/Gemfile.lock b/examples/gem/Gemfile.lock new file mode 100644 index 0000000..502fccc --- /dev/null +++ b/examples/gem/Gemfile.lock @@ -0,0 +1,24 @@ +PATH + remote: ../.. + specs: + rcm (0.1.0) + erb + toml (~> 0.3) + +GEM + remote: https://rubygems.org/ + specs: + erb (6.0.2) + parslet (2.0.0) + toml (0.3.0) + parslet (>= 1.8.0, < 3.0.0) + +PLATFORMS + ruby + x86_64-linux + +DEPENDENCIES + rcm! + +BUNDLED WITH + 2.6.9 diff --git a/examples/gem/README.md b/examples/gem/README.md index c05b844..3b486df 100644 --- a/examples/gem/README.md +++ b/examples/gem/README.md @@ -1,6 +1,7 @@ # Example: As a Gem -Uses RCM as a Bundler-managed gem inside a Rake project. +Uses RCM as a Bundler-managed gem, without Rake. This is the simplest way to +use RCM from your own Ruby scripts while keeping gem dependencies explicit. ## Setup @@ -12,17 +13,17 @@ bundle install ```sh # Dry run — show what would change, make no changes -bundle exec rake setup -- --dry +bundle exec ruby config.rb --dry # Verbose output -bundle exec rake setup -- --debug +bundle exec ruby config.rb --debug # Apply configuration -bundle exec rake setup +bundle exec ruby config.rb ``` ## What it does - Creates `/tmp/example/wg0.conf` from an inline ERB template -The task only runs when the current hostname is `earth`. +Only runs when the current hostname is `earth`. diff --git a/examples/gem/Rakefile b/examples/gem/Rakefile deleted file mode 100644 index 81a66d4..0000000 --- a/examples/gem/Rakefile +++ /dev/null @@ -1,27 +0,0 @@ -# Example: Using RCM as a gem inside a Bundler-managed project. -# -# Run with: -# bundle install -# bundle exec rake setup -- --dry # dry run, no changes made -# bundle exec rake setup -- --debug # verbose output -# bundle exec rake setup # apply configuration -require 'rcm' - -desc 'Apply system configuration' -task :setup do - configure do - # Only run on the host named 'earth' - given { hostname is :earth } - - # Write a WireGuard config rendered from an inline ERB template. - file '/tmp/example/wg0.conf' do - from template - - <<~TEMPLATE - [Interface] - Address = <%= "10.0.0.1/24" %> - ListenPort = 51820 - TEMPLATE - end - end -end diff --git a/examples/gem/config.rb b/examples/gem/config.rb new file mode 100755 index 0000000..c4bbc23 --- /dev/null +++ b/examples/gem/config.rb @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby +# Example: Using RCM as a gem inside a Bundler-managed project, without Rake. +# +# rcm is declared in the Gemfile and loaded via bundler. +require 'rcm' + +configure do + # Only run on the host named 'earth' + given { hostname is :earth } + + # Write a WireGuard config rendered from an inline ERB template. + file '/tmp/example/wg0.conf' do + from template + + <<~TEMPLATE + [Interface] + Address = <%= "10.0.0.1/24" %> + ListenPort = 51820 + TEMPLATE + end +end |
