How to do an “OR” when requiring a Gem version
문제
Currently I have a Gemspec that requires a specific version of Rails 3.x with Rails > 3.1:
Gem::Specification.new do |s|
# (...)
s.add_dependency "railties", "~> 3.1"
# (...)
end
I am looking to update this statement to require ~> 3.1
OR ~> 4.0.0
. I had tried already:
~> 3.1, ~> 4.0.0
~> 3.1 OR ~> 4.0.0
~> 3.1 || ~> 4.0.0
~> 3.1 ~> 4.0.0
None have worked. Is that possible with the current RubyGems version?
For now I am using > 3.1, but the real question is if that's possible.
해결책
Since you are using ~>
, it seems as if you are willing to use any version of the gem that is after 3.1, that is, any 3.x OR any 4.0.x, but not a 4.x where x is greater than 1.
If that is your intention, then according to the rubygems guide, you'll want to use a pattern like:
spec.add_dependency 'library', ['>= 3.1', '< 4.1']
I think it might be the addition of brackets that you need.
제휴하지 않습니다 StackOverflow