Nick Vanderbilt
Nick Vanderbilt

Reputation: 2535

How do I declare gemspec dependency as >= 3.1 but less than < 4.0

I am making changes to my ruby gem to make it asset pipeline compatible. In my gemspec I want to say that it requires rails version > 3.1 and < 4. How do I do that.

currently this is what I have.

s.add_dependency("rails", ">= 3.1")

But this is not ideal. This is saying that it will also work with rails 4.0 which might not be true.

Upvotes: 6

Views: 2870

Answers (1)

Andrei S
Andrei S

Reputation: 6516

You can use the pessimistic operator ~>

Using the pessimistic operator, you could write

s.add_dependency("rails", "~> 3.1")

which is equivalent to '>= 3.1', '< 4.0'

Upvotes: 12

Related Questions