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.
Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.
Gemspec is basically the Readme for gems. It tells you about the author, version, summary, description, internal dependencies, execution and everything about the Gem. So now it was easy to use gems as all of them were having their specifications with them.
development. RubyGems provides two main “types” of dependencies: runtime and development. Runtime dependencies are what your gem needs to work (such as rails needing activesupport). Development dependencies are useful for when someone wants to make modifications to your gem.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With