Simmo
Simmo

Reputation: 1719

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?

Upvotes: 10

Views: 4237

Answers (2)

Markus
Markus

Reputation: 5807

I think you should write it with < 5.x, because this will prevent beta versions like 5.0.beta1 to be installed.

 s.add_dependency "activeresource", ">= 3.0", "< 5.x"

Because with < 5.0, 5.0.beta1 can be installed - 5.0.beta1 is smaller than 5.0.

Upvotes: 3

Dougui
Dougui

Reputation: 7232

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 : >=, ~>, <=, >, <.

Upvotes: 10

Related Questions