123456789_123456789_123456789_123456789_123456789_

Module: Bundler::MatchPlatform

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/bundler/match_platform.rb

Class Attribute Summary

Class Method Summary

Instance Method Summary

Class Attribute Details

.generic_local_platform_is_ruby?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/match_platform.rb', line 61

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

Class Method Details

.prefer_content_addressable(matching)

[ GitHub ]

  
# File 'lib/bundler/match_platform.rb', line 29

def self.prefer_content_addressable(matching)
  addressable, non_addressable = matching.partition {|s| Gem::ContentAddress.content_addressed?(s, validate_ruby_abi: false) }
  return matching if addressable.empty?

  compatible = addressable.select(&:matches_current_metadata?)
  return compatible if compatible.any?

  non_addressable.any? ? non_addressable : matching
end

.select_all_content_address_match(specs, content_address)

[ GitHub ]

  
# File 'lib/bundler/match_platform.rb', line 23

def self.select_all_content_address_match(specs, content_address)
  return specs unless Gem::ContentAddress.match?(content_address)

  specs.select {|spec| spec.content_address == content_address }
end

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

[ GitHub ]

  
# File 'lib/bundler/match_platform.rb', line 48

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, locked_platforms: nil)

[ GitHub ]

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

def self.select_best_local_platform_match(specs, force_ruby: false, locked_platforms: nil)
  local = Bundler.local_platform
  matching = select_all_platform_match(specs, local, force_ruby: force_ruby)
  matching = matching.filter_map {|spec| spec.materialized_for_installation(locked_platforms) }
  matching = prefer_content_addressable(matching)

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

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

[ GitHub ]

  
# File 'lib/bundler/match_platform.rb', line 16

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)
  matching = prefer_content_addressable(matching)

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

Instance Method Details

#content_address

[ GitHub ]

  
# File 'lib/bundler/match_platform.rb', line 5

def content_address
  nil
end

#installable_on_platform?(target_platform) ⇒ Boolean

This method is for internal use only.
[ GitHub ]

  
# File 'lib/bundler/match_platform.rb', line 9

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