How to declare a gemspec dependency as> = 3.1, but less than <4.0

I am making changes to my ruby ​​stone to make it compatible with the conveyor. In my gemspec, I want to say that it requires a version of rails > 3.1and < 4. How to do it.

This is currently what I have.

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

But this is not perfect. This suggests that it will also work with rails 4.0, which may be incorrect.

+5
source share
1 answer

You can use the pessimistic operator ~>

Using the pessimistic operator, you can write

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

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

+11
source

All Articles