diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/commands/contents_command.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 807158d9c9..bd0cbce8ba 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -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) |