Class: SemanticPuppet::VersionRange::AbstractRange Private
- Inherits:
-
Object
- Object
- SemanticPuppet::VersionRange::AbstractRange
- Defined in:
- lib/semantic_puppet/version_range.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Instance Method Summary collapse
- #==(other) ⇒ Object private
- #begin ⇒ Object private
- #end ⇒ Object private
- #eql?(other) ⇒ Boolean private
- #exclude_begin? ⇒ Boolean private
- #exclude_end? ⇒ Boolean private
- #include?(_) ⇒ Boolean private
-
#intersection(range) ⇒ AbstractRange?
private
Merge two ranges so that the result matches the intersection of all matching versions.
- #lower_bound? ⇒ Boolean private
-
#merge(other) ⇒ AbastractRange?
private
Merge two ranges so that the result matches the sum of all matching versions.
-
#test_prerelease?(_) ⇒ Boolean
private
Checks if this matcher accepts a prerelease with the same major, minor, patch triple as the given version.
- #upper_bound? ⇒ Boolean private
Instance Method Details
#==(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
387 388 389 |
# File 'lib/semantic_puppet/version_range.rb', line 387 def ==(other) eql?(other) end |
#begin ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
367 368 369 |
# File 'lib/semantic_puppet/version_range.rb', line 367 def begin Version::MIN end |
#end ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
371 372 373 |
# File 'lib/semantic_puppet/version_range.rb', line 371 def end Version::MAX end |
#eql?(other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
383 384 385 |
# File 'lib/semantic_puppet/version_range.rb', line 383 def eql?(other) other.class.eql?(self.class) end |
#exclude_begin? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
375 376 377 |
# File 'lib/semantic_puppet/version_range.rb', line 375 def exclude_begin? false end |
#exclude_end? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
379 380 381 |
# File 'lib/semantic_puppet/version_range.rb', line 379 def exclude_end? false end |
#include?(_) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
363 364 365 |
# File 'lib/semantic_puppet/version_range.rb', line 363 def include?(_) true end |
#intersection(range) ⇒ AbstractRange?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Merge two ranges so that the result matches the intersection of all matching versions.
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/semantic_puppet/version_range.rb', line 405 def intersection(range) cmp = self.begin <=> range.end if cmp > 0 nil elsif cmp == 0 exclude_begin? || range.exclude_end? ? nil : EqRange.new(self.begin) else cmp = range.begin <=> self.end if cmp > 0 nil elsif cmp == 0 range.exclude_begin? || exclude_end? ? nil : EqRange.new(range.begin) else cmp = self.begin <=> range.begin min = if cmp < 0 range elsif cmp > 0 self else self.exclude_begin? ? self : range end cmp = self.end <=> range.end max = if cmp > 0 range elsif cmp < 0 self else self.exclude_end? ? self : range end if !max.upper_bound? min elsif !min.lower_bound? max else MinMaxRange.new(min, max) end end end end |
#lower_bound? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
391 392 393 |
# File 'lib/semantic_puppet/version_range.rb', line 391 def lower_bound? false end |
#merge(other) ⇒ AbastractRange?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Merge two ranges so that the result matches the sum of all matching versions. A merge is only possible when the ranges are either adjacent or have an overlap.
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
# File 'lib/semantic_puppet/version_range.rb', line 454 def merge(other) if include?(other.begin) || other.include?(self.begin) cmp = self.begin <=> other.begin if cmp < 0 min = self.begin excl_begin = exclude_begin? elsif cmp > 0 min = other.begin excl_begin = other.exclude_begin? else min = self.begin excl_begin = exclude_begin? && other.exclude_begin? end cmp = self.end <=> other.end if cmp > 0 max = self.end excl_end = self.exclude_end? elsif cmp < 0 max = other.end excl_end = other.exclude_end? else max = self.end excl_end = exclude_end? && other.exclude_end? end MinMaxRange.create(excl_begin ? GtRange.new(min) : GtEqRange.new(min), excl_end ? LtRange.new(max) : LtEqRange.new(max)) elsif exclude_end? && !other.exclude_begin? && self.end == other.begin # Adjacent, self before other from_to(self, other) elsif other.exclude_end? && !exclude_begin? && other.end == self.begin # Adjacent, other before self from_to(other, self) elsif !exclude_end? && !other.exclude_begin? && self.end.next(:patch) == other.begin # Adjacent, self before other from_to(self, other) elsif !other.exclude_end? && !exclude_begin? && other.end.next(:patch) == self.begin # Adjacent, other before self from_to(other, self) else # No overlap nil end end |
#test_prerelease?(_) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Checks if this matcher accepts a prerelease with the same major, minor, patch triple as the given version. Only matchers
where this has been explicitly stated will respond true
to this method
503 504 505 |
# File 'lib/semantic_puppet/version_range.rb', line 503 def test_prerelease?(_) false end |
#upper_bound? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
395 396 397 |
# File 'lib/semantic_puppet/version_range.rb', line 395 def upper_bound? false end |