Skip to content

Commit 6ca1ff6

Browse files
committed
Use the path returned from Gem::Source#download
`Gem::SpecFetcher.fetcher.spec_for_dependency` returns `Gem::Specification`, `Gem::Source` tuples. https://github.com/fedora-ruby/gem-compare/blob/6b221bcf37b30a9dda05d0a2d7d677bee52ef097/lib/rubygems/comparator.rb#L251 ```ruby irb(main):001> gem_name = "pg" => "pg" irb(main):002> version = "1.6.0" => "1.6.0" irb(main):003> dep = Gem::Dependency.new gem_name, version => Gem::Dependency.new("pg", Gem::Requirement.new(["= 1.6.0"]), :runtime) irb(main):004> specs_and_sources, _errors = Gem::SpecFetcher.fetcher.spec_for_dependency dep => [[[Gem::Specification.new do |s| ... irb(main):017> specs_and_sources.map { it.map(&:class) } => [[Gem::Specification, Gem::Source], [Gem::Specification, Gem::Source]] ``` `Gem::Source#download` will return the local gem file path: ```ruby irb(main):013> specs_and_sources.first.last.download specs_and_sources.first.first Fetching pg-1.6.0-aarch64-linux.gem => "/app/pg-1.6.0-aarch64-linux.gem" ```
1 parent 7c260c6 commit 6ca1ff6

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

lib/rubygems/comparator.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,14 @@ def get_package(gem_name, version)
225225

226226
def download_package(gem_name, version)
227227
spec, source = get_specification(gem_name, version)
228-
gem_file = gem_file_name(gem_name, spec.version.to_s)
229228

230-
Dir.chdir @options[:output] do
229+
gem_file_path = Dir.chdir @options[:output] do
231230
source.download spec
232231
end
233232

234-
package = Gem::Package.new File.join(@options[:output], gem_file)
233+
package = Gem::Package.new(gem_file_path)
235234
use_package(package)
236-
info "#{gem_file} downloaded."
235+
info "#{gem_file_path} downloaded."
237236

238237
package
239238
end

0 commit comments

Comments
 (0)