class Bundler::Materialization

This class materializes a set of resolved specifications (‘LazySpecification`) for a given gem into the most appropriate real specifications (`StubSepecification`, `EndpointSpecification`, etc), given a dependency and a target platform.

Attributes

dep[R]
platform[R]

Public Class Methods

new(dep, platform, candidates:) click to toggle source
# File bundler/materialization.rb, line 11
def initialize(dep, platform, candidates:)
  @dep = dep
  @platform = platform
  @candidates = candidates
end

Public Instance Methods

complete?() click to toggle source
# File bundler/materialization.rb, line 17
def complete?
  specs.any?
end
completely_missing_specs() click to toggle source
# File bundler/materialization.rb, line 39
def completely_missing_specs
  return [] unless specs.all?(&:missing?)

  specs
end
dependencies() click to toggle source
# File bundler/materialization.rb, line 31
def dependencies
  specs.first.runtime_dependencies.map {|d| [d, platform] }
end
incomplete_specs() click to toggle source
# File bundler/materialization.rb, line 49
def incomplete_specs
  return [] if complete?

  @candidates || LazySpecification.new(dep.name, nil, nil)
end
materialized_spec() click to toggle source
# File bundler/materialization.rb, line 35
def materialized_spec
  specs.reject(&:missing?).first&.materialization
end
partially_missing_specs() click to toggle source
# File bundler/materialization.rb, line 45
def partially_missing_specs
  specs.select(&:missing?)
end
specs() click to toggle source
# File bundler/materialization.rb, line 21
def specs
  @specs ||= if @candidates.nil?
    []
  elsif platform
    GemHelpers.select_best_platform_match(@candidates, platform, force_ruby: dep.force_ruby_platform)
  else
    GemHelpers.select_best_local_platform_match(@candidates, force_ruby: dep.force_ruby_platform || dep.default_force_ruby_platform)
  end
end