class method
Gem.register_default_spec
(::Gem::Specification spec) -> ::Array[::String]
register_default_spec(spec)
lib/rubygems.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems.rb, line 1277
def register_default_spec(spec)
extended_require_paths = spec.require_paths.map {|f| f + "/" }
new_format = extended_require_paths.any? {|path| spec.files.any? {|f| f.start_with? path } }
if new_format
prefix_group = extended_require_paths.join("|")
prefix_pattern = /^(#{prefix_group})/
end
spec.files.each do |file|
if new_format
file = file.sub(prefix_pattern, "")
next unless $~
end
spec.activate if already_loaded?(file)
@path_to_default_spec_map[file] = spec
@path_to_default_spec_map[file.sub(suffix_regexp, "")] = spec
end
end
Register a Gem::Specification for default gem.
Two formats for the specification are supported:
-
MRI 2.0 style, where spec.files contains unprefixed require names. The spec’s filenames will be registered as-is.
-
New style, where spec.files contains files prefixed with paths from spec.require_paths. The prefixes are stripped before registering the spec’s filenames. Unprefixed files are omitted.