Skip to content

Conversation

@dentarg
Copy link
Contributor

@dentarg dentarg commented Aug 2, 2025

Gem::SpecFetcher.fetcher.spec_for_dependency returns
Gem::Specification, Gem::Source tuples.

specs_and_sources, _errors = Gem::SpecFetcher.fetcher.spec_for_dependency dep

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:

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"

Close #31

dentarg added 4 commits August 2, 2025 17:48
Removes lots of warnings when running the tests.
`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"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle ERROR: While executing gem ... (Zlib::BufError)?

1 participant