square / maximum-awesome

Config files for vim and tmux.
Other
5.71k stars 969 forks source link

More robust version checking #232

Closed rudle closed 7 years ago

rudle commented 7 years ago

We only care about the major version, so we filter out extraneous information.

Fixes #230

I'm not super happy with the ruby regexp API. Any tips to clean up this code would be welcomed.

@ggilder

ggilder commented 7 years ago

👍

ggilder commented 7 years ago

Idea to simplify: get rid of the regex code. Gem::Dependency already handles this:

Gem::Dependency.new('', '>= 2.1').match?('', '2.2a')
#=> true

So the implementation could just be

def version_match?(requirement, version)
  Gem::Dependency.new('', requirement).match?('', version)
end
rudle commented 7 years ago

PRs welcome