Class: CargoLockfile

Inherits:
Object
  • Object
show all
Defined in:
lib/ratatui_ruby/devtools/tasks/bump/cargo_lockfile.rb

Overview

Refreshes Cargo.lock after version changes.

Rust crates have lockfiles that pin dependency versions. After updating Cargo.toml, the lockfile becomes stale. Running cargo update fixes it.

This class wraps the lockfile refresh operation. It runs cargo update in the crate directory. Use it after bumping Rust extension versions.

path

The path to the Cargo.lock file.

dir

The directory containing the Cargo.toml.

name

The crate name to update.

Instance Method Summary collapse

Instance Method Details

#exists?Boolean

Checks whether the lockfile exists on disk.

Pure Ruby gems have no Cargo.lock. Refreshing a missing file fails. Check this before calling refresh to avoid errors.

Returns:

  • (Boolean)


24
25
26
# File 'lib/ratatui_ruby/devtools/tasks/bump/cargo_lockfile.rb', line 24

def exists?
  File.exist?(path)
end

#refreshObject

Refreshes the lockfile by running cargo update.

Runs cargo update -p {name} --offline in the crate directory.



31
32
33
34
35
36
37
# File 'lib/ratatui_ruby/devtools/tasks/bump/cargo_lockfile.rb', line 31

def refresh
  return unless exists?

  Dir.chdir(dir) do
    system("cargo update -p #{name} --offline")
  end
end