ManageIQ / polisher

Polisher is a Ruby module and set of utilities aimed to assisting the post-publishing packaging process for Ruby gems and applications.
MIT License
14 stars 14 forks source link

Polisher::Gemfile#dependency_versions ignores the Gemfile version constraint #103

Open jrafanie opened 10 years ago

jrafanie commented 10 years ago

Polisher::Gemfile#dependency_versions ignores the Gemfile version constraint and just returns all versions of all gem dependencies from the Gemfile available in koji. It doesn't check the version constraint.

require 'pathname'
require 'polisher/gemfile'

# Only check koji
targets = [:koji]
Polisher::VersionChecker.check(targets)

require 'polisher/koji'

# Write out a basic Gemfile
gemfile = Pathname.new("./Gemfile").expand_path
contents = <<-EOS
source 'https://rubygems.org'
gem 'bundler', '~> 1.6.0'
EOS
File.write(gemfile, contents)

gemfile = Polisher::Gemfile.parse(gemfile)
packages =  gemfile.dependency_versions(:recursive => false, :dev_deps  => false)

puts packages.inspect

Output:

D, [2014-07-02T11:55:50.838449 #60328] DEBUG -- : versions_for<koji>(bundler)...
D, [2014-07-02T11:55:51.627573 #60328] DEBUG -- : ["1.5.2", "1.3.5", "1.3.1", "1.1.4"]
{"bundler"=>{:koji=>["1.5.2", "1.3.5", "1.3.1", "1.1.4"]}}

Even though the Gemfile says ~> 1.6.0, Polisher::Gemfile#dependency_versions ignores this and only returns the versions of all dependencies.

movitto commented 10 years ago

@jrafanie can you elaborate what you are trying to do? This is the intent of the dependency_versions method, it retrieves all the versions of all the specified packages in your configured targets.

If you would like to check to see if any see particular gem / version is built you can use the Koji#has_build and/or Koji#has_build_satisfying? method.

Alternately you can take the result from #dependency_versions and cross reference it w/ your gemfile w/ a simple 'each' loop + the Gem::Dependency#match? method (eg see the #has_build_satisfying? implementation). We can add a helper method to polisher doing this if you'd like (perhaps Polisher::Gemfile#built? or similar)

jrafanie commented 10 years ago

@movitto I'm suggesting that Polisher::Gemfile.parse(gemfile).dependency_versions not discard the version constraint as that's part of parsing a Gemfile.

I should have some PRs for related features soon.