Class: RubyGem
- Inherits:
-
Object
- Object
- RubyGem
- Defined in:
- lib/ratatui_ruby/devtools/tasks/bump/ruby_gem.rb
Overview
Coordinates version bumping across multiple manifests.
Ruby gems have versions in multiple files: version.rb, Cargo.toml, lockfiles. Bumping manually leads to mismatches. Forgetting the changelog produces incomplete releases.
This class orchestrates the bump. It updates all manifests, refreshes lockfiles, and updates the changelog. One command. Consistent versions.
Use it in rake tasks to bump major, minor, or patch versions.
Instance Method Summary collapse
-
#bump(segment) ⇒ Object
Bumps the version by the given segment.
-
#initialize(manifests:, lockfile:, changelog:) ⇒ RubyGem
constructor
Creates a new RubyGem coordinator.
-
#set(version_string) ⇒ Object
Sets the version to an exact value.
-
#version ⇒ Object
Returns the current version from the primary manifest.
Constructor Details
#initialize(manifests:, lockfile:, changelog:) ⇒ RubyGem
Creates a new RubyGem coordinator.
- manifests
-
Array of Manifest objects. Exactly one must be primary.
- lockfile
-
A lockfile object that responds to
refresh. - changelog
-
A Changelog object for updating release notes.
24 25 26 27 28 29 |
# File 'lib/ratatui_ruby/devtools/tasks/bump/ruby_gem.rb', line 24 def initialize(manifests:, lockfile:, changelog:) raise ArgumentError, "Must have exactly one primary manifest" unless manifests.count(&:primary) == 1 @manifests = manifests @lockfile = lockfile @changelog = changelog end |
Instance Method Details
#bump(segment) ⇒ Object
Bumps the version by the given segment.
Updates all manifests, refreshes lockfiles, and updates the changelog. Prints a suggested commit message.
- segment
-
One of
:major,:minor, or:patch.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ratatui_ruby/devtools/tasks/bump/ruby_gem.rb', line 42 def bump(segment) target = version.next(segment) = @changelog.(target) puts "Bumping #{segment}: #{version} -> #{target}" @changelog.release(target) @manifests.each { |manifest| manifest.write(target) } @lockfile.refresh () end |
#set(version_string) ⇒ Object
Sets the version to an exact value.
Updates all manifests, refreshes lockfiles, and updates the changelog. Prints a suggested commit message.
- version_string
-
A version string like
"1.2.3".
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ratatui_ruby/devtools/tasks/bump/ruby_gem.rb', line 60 def set(version_string) target = SemVer.parse(version_string) = @changelog.(target) puts "Setting version: #{version} -> #{target}" @changelog.release(target) @manifests.each { |manifest| manifest.write(target) } @lockfile.refresh () end |
#version ⇒ Object
Returns the current version from the primary manifest.
32 33 34 |
# File 'lib/ratatui_ruby/devtools/tasks/bump/ruby_gem.rb', line 32 def version @manifests.find(&:primary).version end |