Module: Rails::Hyperdrive::AncestorLocator
- Defined in:
- lib/rails/hyperdrive/ancestor_locator.rb
Overview
Best-effort reconstruction of the install-ready body an artifact had at the gem version a lock entry records, read from installed gem directories. The result is sha-gated against the lock entry: anything that does not rebuild to exactly the recorded bytes counts as unavailable.
Class Method Summary collapse
-
.locate(kind:, relpath:, lock_entry:, final_name: nil, gem_paths: Gem.path, resolved: nil) ⇒ Object
Never raises; any failure returns nil (ancestor unavailable).
Class Method Details
.locate(kind:, relpath:, lock_entry:, final_name: nil, gem_paths: Gem.path, resolved: nil) ⇒ Object
Never raises; any failure returns nil (ancestor unavailable).
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails/hyperdrive/ancestor_locator.rb', line 17 def locate(kind:, relpath:, lock_entry:, final_name: nil, gem_paths: Gem.path, resolved: nil) return nil unless lock_entry&.source_gem && lock_entry.source_version && lock_entry.source_sha return nil if relpath.nil? || relpath.to_s.empty? Array(gem_paths).each do |home| gem_root = File.join(home.to_s, "gems", "#{lock_entry.source_gem}-#{lock_entry.source_version}") body = read_candidate(gem_root, relpath.to_s, kind: kind, resolved: resolved) next unless body ready = install_ready(body, kind: kind, final_name: final_name) return ready if DriftVerdict.body_sha(ready) == lock_entry.source_sha rescue StandardError next end nil rescue StandardError nil end |