On this page
module Bundler::GemHelpers
Constants
- GENERICS
- GENERIC_CACHE
- PlatformMatch
Public Class Methods
# File lib/bundler/gem_helpers.rb, line 16
def generic(p)
return p if p == Gem::Platform::RUBY
GENERIC_CACHE[p] ||= begin
_, found = GENERICS.find do |match, _generic|
p.os == match.os && (!match.cpu || p.cpu == match.cpu)
end
found || Gem::Platform::RUBY
end
end
# File lib/bundler/gem_helpers.rb, line 28
def generic_local_platform
generic(Bundler.local_platform)
end
# File lib/bundler/gem_helpers.rb, line 33
def platform_specificity_match(spec_platform, user_platform)
spec_platform = Gem::Platform.new(spec_platform)
return PlatformMatch::EXACT_MATCH if spec_platform == user_platform
return PlatformMatch::WORST_MATCH if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY
PlatformMatch.new(
PlatformMatch.os_match(spec_platform, user_platform),
PlatformMatch.cpu_match(spec_platform, user_platform),
PlatformMatch.platform_version_match(spec_platform, user_platform)
)
end
# File lib/bundler/gem_helpers.rb, line 46
def select_best_platform_match(specs, platform)
specs.select {|spec| spec.match_platform(platform) }.
min_by {|spec| platform_specificity_match(spec.platform, platform) }
end
Private Instance Methods
# File lib/bundler/gem_helpers.rb, line 16
def generic(p)
return p if p == Gem::Platform::RUBY
GENERIC_CACHE[p] ||= begin
_, found = GENERICS.find do |match, _generic|
p.os == match.os && (!match.cpu || p.cpu == match.cpu)
end
found || Gem::Platform::RUBY
end
end
# File lib/bundler/gem_helpers.rb, line 28
def generic_local_platform
generic(Bundler.local_platform)
end
# File lib/bundler/gem_helpers.rb, line 33
def platform_specificity_match(spec_platform, user_platform)
spec_platform = Gem::Platform.new(spec_platform)
return PlatformMatch::EXACT_MATCH if spec_platform == user_platform
return PlatformMatch::WORST_MATCH if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY
PlatformMatch.new(
PlatformMatch.os_match(spec_platform, user_platform),
PlatformMatch.cpu_match(spec_platform, user_platform),
PlatformMatch.platform_version_match(spec_platform, user_platform)
)
end
# File lib/bundler/gem_helpers.rb, line 46
def select_best_platform_match(specs, platform)
specs.select {|spec| spec.match_platform(platform) }.
min_by {|spec| platform_specificity_match(spec.platform, platform) }
end
Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.