Ruby plugin¶
The Ruby plugin manages Ruby gems and the Ruby interpreter. It can build and bundle different variants of the interpreter, build gems with tools like rake or Bundler, and install gems.
Keys¶
This plugin provides the following unique keys.
ruby-gems¶
Type
list[str]
Description
The gems to install.
ruby-use-bundler¶
Type
bool
Description
Whether to use Bundler to build the gems.
ruby-flavor¶
Type
RubyFlavor
Description
The Ruby interpreter to build and include.
Values
Value |
Description |
|---|---|
|
The reference (MRI/CRuby) Ruby implementation. |
|
A Ruby implementation that runs on the JVM. |
|
A high-performance Ruby implementation built on GraalVM. |
|
A lightweight Ruby implementation designed for embedding. |
ruby-version¶
Type
str
Description
The version of the Ruby interpreter to build.
ruby-use-jemalloc¶
Type
bool
Description
Whether to build Ruby with support for jemalloc.
ruby-configure-options¶
Type
list[str]
Description
The extra arguments to pass to the configure script when building the Ruby
interpreter.
Attributes¶
This plugin supports the self-contained build attribute. Declaring this attribute
prevents access to remote repositories, such as rubygems.org. All dependencies,
including plugins, must then be provided as packaged gems or in an earlier part.
When used in conjunction with ruby-use-bundler, the build phase invokes
the bundle command with the --local argument.
Dependencies¶
The Ruby plugin needs a Ruby interpreter to run Ruby programs but does not provide it by default, to give you flexibility in the choice of interpreter flavor and version.
A common means of including Ruby is to declare the ruby Ubuntu package,
or any ruby-<gem_name> Ubuntu package, as a stage-package.
Alternatively, if ruby-flavor and ruby-version are declared, this plugin
downloads and runs the ruby-install tool.
If a special Ruby part named ruby-deps is defined, it
creates a shared interpreter that the other Ruby parts can use.
For a Ruby part to use these shared files, it must list ruby-deps in its
after key.
Examples¶
The following example compiles version 3.2.0 of the Ruby interpreter from source, installs the rackup gem, and finally builds the project directory as a Ruby project.
parts:
my-part:
plugin: ruby
source: .
ruby-flavor: ruby
ruby-version: "3.2.0"
ruby-gems:
- rackup
The following example shows how to use a shared Ruby interpreter provided by an
earlier part. Because the ruby-deps part specifies ruby-bundler as a
stage package, both the Bundler and Ruby executables from the Ubuntu archive
are included in the output artifact.
parts:
ruby-deps:
plugin: nil
stage-packages:
- ruby-bundler
my-project:
plugin: ruby
source: .
ruby-use-bundler: true
ruby-gems:
- rackup
after: [ruby-deps]