module Gem::BUNDLED_GEMS

Constants

ARCHDIR
DLEXT
EXACT
LIBDIR
LIBEXT
PREFIXED
SINCE
WARNED

Public Class Methods

find_gem(path) click to toggle source
# File bundled_gems.rb, line 58
def self.find_gem(path)
  if !path
    return
  elsif path.start_with?(ARCHDIR)
    n = path.delete_prefix(ARCHDIR).sub(DLEXT, "")
  elsif path.start_with?(LIBDIR)
    n = path.delete_prefix(LIBDIR).chomp(".rb")
  else
    return
  end
  EXACT[n] or PREFIXED[n = n[%r[\A[^/]+(?=/)]]] && n
end
warning?(name) click to toggle source
# File bundled_gems.rb, line 71
def self.warning?(name)
  _t, path = $:.resolve_feature_path(name)
  return unless gem = find_gem(path)
  caller = caller_locations(3, 3).find {|c| c&.absolute_path}
  return if find_gem(caller&.absolute_path)
  return if WARNED[name]
  WARNED[name] = true
  if gem == true
    gem = name.sub(LIBEXT, "") # assume "foo.rb"/"foo.so" belongs to "foo" gem
  elsif gem
    return if WARNED[gem]
    WARNED[gem] = true
    "#{name} is found in #{gem}"
  else
    return
  end + " which #{RUBY_VERSION < SINCE[gem] ? "will be" : "is"} not part of the default gems since Ruby #{SINCE[gem]}"
end