[rubygems/rubygems] Fix gem contents
for default gems
A default gem does not always live in the same place. For example, Bundler may be installed to `site_dir` when RubyGems have been upgraded. A more reliable way seems to actually activate the default gem, so that we can know for sure where it lives. https://github.com/rubygems/rubygems/commit/c69f6dfb18
This commit is contained in:
parent
57404e4369
commit
48fdb9faa0
@ -103,16 +103,23 @@ prefix or only the files that are requireable.
|
|||||||
|
|
||||||
def files_in_default_gem(spec)
|
def files_in_default_gem(spec)
|
||||||
spec.files.map do |file|
|
spec.files.map do |file|
|
||||||
case file
|
if file.start_with?("#{spec.bindir}/")
|
||||||
when %r{\A#{spec.bindir}/}
|
[RbConfig::CONFIG["bindir"], file.delete_prefix("#{spec.bindir}/")]
|
||||||
# $' is POSTMATCH
|
|
||||||
[RbConfig::CONFIG["bindir"], $']
|
|
||||||
when /\.so\z/
|
|
||||||
[RbConfig::CONFIG["archdir"], file]
|
|
||||||
else
|
else
|
||||||
[RbConfig::CONFIG["rubylibdir"], file]
|
gem spec.name, spec.version
|
||||||
|
|
||||||
|
require_path = spec.require_paths.find do |path|
|
||||||
|
file.start_with?("#{path}/")
|
||||||
|
end
|
||||||
|
|
||||||
|
requirable_part = file.delete_prefix("#{require_path}/")
|
||||||
|
|
||||||
|
resolve = $LOAD_PATH.resolve_feature_path(requirable_part)&.last
|
||||||
|
next unless resolve
|
||||||
|
|
||||||
|
[resolve.delete_suffix(requirable_part), requirable_part]
|
||||||
end
|
end
|
||||||
end
|
end.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def gem_contents(name)
|
def gem_contents(name)
|
||||||
|
@ -227,7 +227,6 @@ lib/foo.rb
|
|||||||
default_gem_spec = new_default_spec("default", "2.0.0.0",
|
default_gem_spec = new_default_spec("default", "2.0.0.0",
|
||||||
nil, "default/gem.rb")
|
nil, "default/gem.rb")
|
||||||
default_gem_spec.executables = ["default_command"]
|
default_gem_spec.executables = ["default_command"]
|
||||||
default_gem_spec.files += ["default_gem.so"]
|
|
||||||
install_default_gems(default_gem_spec)
|
install_default_gems(default_gem_spec)
|
||||||
|
|
||||||
@cmd.options[:args] = %w[default]
|
@cmd.options[:args] = %w[default]
|
||||||
@ -237,9 +236,8 @@ lib/foo.rb
|
|||||||
end
|
end
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
[RbConfig::CONFIG["bindir"], "default_command"],
|
[File.join(@gemhome, "bin"), "default_command"],
|
||||||
[RbConfig::CONFIG["rubylibdir"], "default/gem.rb"],
|
[File.join(@tempdir, "default_gems", "lib"), "default/gem.rb"],
|
||||||
[RbConfig::CONFIG["archdir"], "default_gem.so"],
|
|
||||||
].sort.map {|a|File.join a }.join "\n"
|
].sort.map {|a|File.join a }.join "\n"
|
||||||
|
|
||||||
assert_equal expected, @ui.output.chomp
|
assert_equal expected, @ui.output.chomp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user