Simmo Simmo - 1 year ago 96
Ruby Question

In a ruby .gemspec file, how do I specify multiple versions of a dependency?

I'm trying to modify a gem which currently has a dependency on activeresource defined as:

s.add_dependency "activeresource", "~> 3.0"

In order to get the gem working with Rails 4, I need to extend the dependency to work with either version 3 or 4 of activeresource. I don't want to simply add the following as it could cause problems later:

s.add_dependency "activeresource", ">= 3.0"

Is there a way to specify a list of acceptable versions? ~> 3.0 or ~> 4.0?

Answer Source

Accordly to the documentation, if you want to have all version between 3 and 4, you can do this :

s.add_dependency "activeresource", ">= 3.0", "< 5.0"

The specifier accepted are : >=, ~>, <=, >, <.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download