Module: Rails::Hyperdrive::InstallPlan
- Defined in:
- lib/rails/hyperdrive/install_plan.rb
Overview
A name shipped by one source installs at its canonical path; a name shipped by several installs every variant, postfixed --<source_gem>.
Defined Under Namespace
Class Method Summary collapse
-
.build(artifacts, lock: nil) ⇒ Object
A collision installs under a postfixed name, so the shipped name disables every variant and a postfixed name disables just one.
-
.disabled_dest?(lock, type, dest, source_gem: nil) ⇒ Boolean
A supporting file is disabled through its owning skill's name.
Class Method Details
.build(artifacts, lock: nil) ⇒ Object
A collision installs under a postfixed name, so the shipped name disables every variant and a postfixed name disables just one. The postfixed form is honored whether or not a collision exists today, so the opt-out survives a collision appearing or resolving.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rails/hyperdrive/install_plan.rb', line 56 def build(artifacts, lock: nil) result = Result.new(entries: [], disabled: []) artifacts.group_by { |a| [a.artifact_type, a.name] }.each do |(type, name), group| collision = group.size > 1 group.each do |artifact| final_name = collision ? InstallLayout.postfixed_name(name, artifact.source_gem) : name entry = Entry.new( type: type, artifact: artifact, final_name: final_name, dest: InstallLayout.dest_for(type, final_name), collision: collision ) dropped = lock && (lock.disabled?(type, name) || lock.disabled?(type, InstallLayout.postfixed_name(name, artifact.source_gem))) (dropped ? result.disabled : result.entries) << entry end end result end |
.disabled_dest?(lock, type, dest, source_gem: nil) ⇒ Boolean
A supporting file is disabled through its owning skill's name. Given the installing gem, a canonically-installed file also answers to the postfixed name that disabled it while it was one of several variants.
80 81 82 83 84 85 86 87 |
# File 'lib/rails/hyperdrive/install_plan.rb', line 80 def disabled_dest?(lock, type, dest, source_gem: nil) name = InstallLayout.installed_name(type, dest) return false unless name lookup = type == :skill_support ? :skill : type base = InstallLayout.base_name(name) return true if lock.disabled?(lookup, name) || lock.disabled?(lookup, base) !source_gem.nil? && lock.disabled?(lookup, InstallLayout.postfixed_name(base, source_gem)) end |