Class: Bundler::Materialization

Inherits:
Object
  • Object
show all
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.

Instance Method Summary collapse

Constructor Details

#initialize(dep, platform, candidates:) ⇒ Materialization

Returns a new instance of Materialization.



11
12
13
14
15
# File 'lib/bundler/materialization.rb', line 11

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

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


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

def complete?
  specs.any?
end

#completely_missing_specsObject



39
40
41
42
43
# File 'lib/bundler/materialization.rb', line 39

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

  specs
end

#dependenciesObject



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

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

#incomplete_specsObject



49
50
51
52
53
# File 'lib/bundler/materialization.rb', line 49

def incomplete_specs
  return [] if complete?

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

#materialized_specObject



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

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

#partially_missing_specsObject



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

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

#specsObject



21
22
23
24
25
26
27
28
29
# 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