Module: Rigor::Environment::LockfileResolver
- Defined in:
- lib/rigor/environment/lockfile_resolver.rb
Overview
Open item O4 Layer 3 — Gemfile.lock parse.
Parses a target project’s ‘Gemfile.lock` via Bundler’s ‘LockfileParser` and exposes the locked gem set as a frozen `Hash[String, LockfileResolver::LockedGem]` keyed by gem name. Used by BundleSigDiscovery as a filter so the discovered `sig/` directories under the bundler install root are limited to gems the project actually declares (and at the version it declared them).
The resolver is intentionally read-only. It does NOT load the project’s ‘Gemfile`, does NOT resolve dependencies, does NOT touch the network, and does NOT require the target project’s Bundler context. It only reads bytes from the lockfile.
Failure modes are deliberately quiet: a missing or malformed lockfile returns an empty map. The auto-detect path is the configuration default; users who want hard failures should pass an explicit ‘bundler.lockfile:` and check the result via the stats banner.
Defined Under Namespace
Classes: LockedGem
Class Method Summary collapse
-
.locked_gems(lockfile_path:, project_root: Dir.pwd, auto_detect: true) ⇒ Hash{String => LockedGem}
Frozen map of gem name → locked entry.
-
.resolve_lockfile_path(lockfile_path:, project_root: Dir.pwd, auto_detect: true) ⇒ Object
Returns the resolved lockfile path (‘Pathname`) or `nil` when neither explicit nor auto-detect produces one.
Class Method Details
.locked_gems(lockfile_path:, project_root: Dir.pwd, auto_detect: true) ⇒ Hash{String => LockedGem}
Returns frozen map of gem name → locked entry. Returns the empty frozen hash when no lockfile is resolvable, when the file is unreadable, or when Bundler refuses to parse it.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rigor/environment/lockfile_resolver.rb', line 55 def self.locked_gems(lockfile_path:, project_root: Dir.pwd, auto_detect: true) resolved = resolve_lockfile_path( lockfile_path: lockfile_path, project_root: project_root, auto_detect: auto_detect ) return EMPTY unless resolved parse(resolved) end |
.resolve_lockfile_path(lockfile_path:, project_root: Dir.pwd, auto_detect: true) ⇒ Object
Returns the resolved lockfile path (‘Pathname`) or `nil` when neither explicit nor auto-detect produces one. Public so the stats banner can show what rigor picked up.
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rigor/environment/lockfile_resolver.rb', line 69 def self.resolve_lockfile_path(lockfile_path:, project_root: Dir.pwd, auto_detect: true) if lockfile_path path = Pathname.new(File.(lockfile_path.to_s, project_root)) return path if path.file? return nil end return nil unless auto_detect candidate = Pathname.new(File.join(project_root, "Gemfile.lock")) candidate.file? ? candidate : nil end |