Module: Bundler::MatchPlatform

Included in:
LazySpecification, RemoteSpecification, Gem::BasicSpecification
Defined in:
lib/bundler/match_platform.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.generic_local_platform_is_ruby?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/bundler/match_platform.rb', line 38

def self.generic_local_platform_is_ruby?
  Bundler.generic_local_platform == Gem::Platform::RUBY
end

.select_all_platform_match(specs, platform, force_ruby: false, prefer_locked: false) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/bundler/match_platform.rb', line 25

def self.select_all_platform_match(specs, platform, force_ruby: false, prefer_locked: false)
  matching = specs.select {|spec| spec.installable_on_platform?(force_ruby ? Gem::Platform::RUBY : platform) }

  specs.each(&:force_ruby_platform!) if force_ruby

  if prefer_locked
    locked_originally = matching.select {|spec| spec.is_a?(::Bundler::LazySpecification) }
    return locked_originally if locked_originally.any?
  end

  matching
end

.select_best_local_platform_match(specs, force_ruby: false) ⇒ Object



18
19
20
21
22
23
# File 'lib/bundler/match_platform.rb', line 18

def self.select_best_local_platform_match(specs, force_ruby: false)
  local = Bundler.local_platform
  matching = select_all_platform_match(specs, local, force_ruby: force_ruby).filter_map(&:materialized_for_installation)

  Gem::Platform.sort_best_platform_match(matching, local)
end

.select_best_platform_match(specs, platform, force_ruby: false, prefer_locked: false) ⇒ Object



12
13
14
15
16
# File 'lib/bundler/match_platform.rb', line 12

def self.select_best_platform_match(specs, platform, force_ruby: false, prefer_locked: false)
  matching = select_all_platform_match(specs, platform, force_ruby: force_ruby, prefer_locked: prefer_locked)

  Gem::Platform.sort_and_filter_best_platform_match(matching, platform)
end

Instance Method Details

#installable_on_platform?(target_platform) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


5
6
7
8
9
10
# File 'lib/bundler/match_platform.rb', line 5

def installable_on_platform?(target_platform) # :nodoc:
  return true if [Gem::Platform::RUBY, nil, target_platform].include?(platform)
  return true if Gem::Platform.new(platform) === target_platform

  false
end