ruby - Why does the Gemfile semantic versioning operator (~>) produce inconsistent results with one number? -
the gemspec semantic versioning operator ~> (aka twiddle-wakka, aka pessimistic operator) allows gem version constrained yet allow upgrades.
i have seen can read as:
"~> 3.1" => "any version 3.x, @ least 3.1" "~> 3.1.1" => "any version 3.1.x, @ least 3.1.1"
but 1 number, rule breaks down:
"~> 3" => "any version x, @ least 3" *not true!* "~> 3" => "any version 3.x" *true. why?*
if wanted "any version 3.x", use "~> 3.0", consistent. stands, change of operation @ 1 number inconsistent , undocumented.
moreover, if wanted "any version higher or equal 3" (so 3.x, 4.x etc...) tempted use ">=" operator, told is evil.
is there reason behaviour?
edit:
i'm giving david finding culprit file in rubygems. there "feature" silently expands "3" "3.0" (line 148 in version.rb: "single-digit versions automatically extended 0 give sensible result.")
i must disagree result sensible, breaks expected sequence, , prevents being able "any version x, @ least 3" operator. thus, forced onto >= guides.rubygems.org warns not use. anyway. maybe post serve documentation i'd been looking for...
by peeking rubygems sources (esp. requirement.rb, version.rb) pessimistic operator needs @ least 2 versioning segments.
it make sense. ~> v.r
syntactic sugar inequality
v.r <= current_version.current_release < (v+1).0
what upper bound if there 1 version number ? yep, ∞ (infinity), there no point why should work. can write >= v
.
Comments
Post a Comment