123456789_123456789_123456789_123456789_123456789_

Class: Bundler::Materialization

Relationships & Source Files
Inherits: Object
Defined in: lib/bundler/materialization.rb

Overview

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.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(dep, platform, candidates:) ⇒ Materialization

[ GitHub ]

  
# File 'lib/bundler/materialization.rb', line 11

def initialize(dep, platform, candidates:)
  @dep = dep
  @platform = platform
  @candidates = candidates
end

Instance Attribute Details

#complete?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/materialization.rb', line 17

def complete?
  specs.any?
end

#dep (readonly, private)

[ GitHub ]

  
# File 'lib/bundler/materialization.rb', line 57

attr_reader :dep, :platform

#platform (readonly, private)

[ GitHub ]

  
# File 'lib/bundler/materialization.rb', line 57

attr_reader :dep, :platform

Instance Method Details

#completely_missing_specs

[ GitHub ]

  
# File 'lib/bundler/materialization.rb', line 39

def completely_missing_specs
  return [] unless specs.all?(&:missing?)

  specs
end

#dependencies

[ GitHub ]

  
# File 'lib/bundler/materialization.rb', line 31

def dependencies
  specs.first.runtime_dependencies.map {|d| [d, platform] }
end

#incomplete_specs

[ GitHub ]

  
# File 'lib/bundler/materialization.rb', line 49

def incomplete_specs
  return [] if complete?

  @candidates || LazySpecification.new(dep.name, nil, nil)
end

#materialized_spec

[ GitHub ]

  
# File 'lib/bundler/materialization.rb', line 35

def materialized_spec
  specs.reject(&:missing?).first&.materialization
end

#partially_missing_specs

[ GitHub ]

  
# File 'lib/bundler/materialization.rb', line 45

def partially_missing_specs
  specs.select(&:missing?)
end

#specs

[ GitHub ]

  
# File 'lib/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