зеркало из https://github.com/github/ruby.git
[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:
Родитель
57404e4369
Коммит
48fdb9faa0
|
@ -103,16 +103,23 @@ prefix or only the files that are requireable.
|
|||
|
||||
def files_in_default_gem(spec)
|
||||
spec.files.map do |file|
|
||||
case file
|
||||
when %r{\A#{spec.bindir}/}
|
||||
# $' is POSTMATCH
|
||||
[RbConfig::CONFIG["bindir"], $']
|
||||
when /\.so\z/
|
||||
[RbConfig::CONFIG["archdir"], file]
|
||||
if file.start_with?("#{spec.bindir}/")
|
||||
[RbConfig::CONFIG["bindir"], file.delete_prefix("#{spec.bindir}/")]
|
||||
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.compact
|
||||
end
|
||||
|
||||
def gem_contents(name)
|
||||
|
|
|
@ -227,7 +227,6 @@ lib/foo.rb
|
|||
default_gem_spec = new_default_spec("default", "2.0.0.0",
|
||||
nil, "default/gem.rb")
|
||||
default_gem_spec.executables = ["default_command"]
|
||||
default_gem_spec.files += ["default_gem.so"]
|
||||
install_default_gems(default_gem_spec)
|
||||
|
||||
@cmd.options[:args] = %w[default]
|
||||
|
@ -237,9 +236,8 @@ lib/foo.rb
|
|||
end
|
||||
|
||||
expected = [
|
||||
[RbConfig::CONFIG["bindir"], "default_command"],
|
||||
[RbConfig::CONFIG["rubylibdir"], "default/gem.rb"],
|
||||
[RbConfig::CONFIG["archdir"], "default_gem.so"],
|
||||
[File.join(@gemhome, "bin"), "default_command"],
|
||||
[File.join(@tempdir, "default_gems", "lib"), "default/gem.rb"],
|
||||
].sort.map {|a|File.join a }.join "\n"
|
||||
|
||||
assert_equal expected, @ui.output.chomp
|
||||
|
|
Загрузка…
Ссылка в новой задаче