ruby.star¶
Bump gem versions, the Ruby version and Bundler, and set RuboCop's target Ruby.
Edits are line-based, so comments and layout in Gemfiles and gemspecs
stay as they were. Gemfile.lock isn't re-resolved; follow with a run
step such as bundle lock --update <gem> when the lockfile is committed.
load("@fleet//ruby.star", "gemfiles", "set_gem", "set_ruby", "set_required_ruby", "set_bundler", "set_rubocop_target")
| Function | What it does |
|---|---|
gemfiles |
Lists the Gemfiles and gemspecs. |
set_gem |
Sets a gem's version requirement wherever a Gemfile or gemspec lists it. |
set_ruby |
Sets the Ruby version a Gemfile pins with ruby "x". |
set_required_ruby |
Sets required_ruby_version in every gemspec that declares it. |
set_bundler |
Sets the Bundler version a Gemfile.lock was BUNDLED WITH. |
set_rubocop_target |
Sets AllCops: TargetRubyVersion in .rubocop.yml. |
gemfiles¶
Lists the Gemfiles and gemspecs.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
Returns: The sorted paths of every Gemfile, gems.rb and *.gemspec outside vendor directories.
Example
set_gem¶
Sets a gem's version requirement wherever a Gemfile or gemspec lists it.
A newer version already there is kept, so a campaign never lowers one.
Covers gem "x", "~> 1.0" with any options after it, and gemspec
add_dependency, add_runtime_dependency and
add_development_dependency. Gems listed without a version are left
alone, since that is a deliberate choice to follow the lockfile.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
name |
The gem name. |
requirement |
The requirement, such as ~> 7.2, or a list for several, such as [">= 1.5", "< 2"]. |
Returns: The list of paths that changed.
Example
Used in: ruby-rails-bump
set_ruby¶
Sets the Ruby version a Gemfile pins with ruby "x".
A newer version already there is kept, so a campaign never lowers one.
ruby file: ".ruby-version" lines are left alone; use
runtime.set_version(repo, "ruby", ...) for the version file.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
version |
The Ruby version or requirement, such as 3.3.5 or ~> 3.3. |
Returns: The list of paths that changed.
Example
set_required_ruby¶
Sets required_ruby_version in every gemspec that declares it.
A newer version already there is kept, so a campaign never lowers one.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
requirement |
The requirement, such as >= 3.1. |
Returns: The list of paths that changed.
Example
set_bundler¶
Sets the Bundler version a Gemfile.lock was BUNDLED WITH.
A newer version already there is kept, so a campaign never lowers one.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
version |
The Bundler version, such as 2.5.22. |
Returns: The list of paths that changed.
Example
set_rubocop_target¶
Sets AllCops: TargetRubyVersion in .rubocop.yml.
A newer version already there is kept, so a campaign never lowers one.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
version |
The Ruby version RuboCop should target, such as 3.3. |
Returns: True when the file changed; False when the repo has no .rubocop.yml.
Example