class Dependabot::Hex::Version
Constants
- ANCHORED_VERSION_PATTERN
- VERSION_PATTERN
Attributes
build_info[R]
Public Class Methods
correct?(version)
click to toggle source
# File lib/dependabot/hex/version.rb, line 18 def self.correct?(version) return false if version.nil? version.to_s.match?(ANCHORED_VERSION_PATTERN) end
new(version)
click to toggle source
Calls superclass method
# File lib/dependabot/hex/version.rb, line 24 def initialize(version) @version_string = version.to_s version, @build_info = version.to_s.split("+") if version.to_s.include?("+") super end
Public Instance Methods
<=>(other)
click to toggle source
Calls superclass method
# File lib/dependabot/hex/version.rb, line 40 def <=>(other) version_comparison = super(other) return version_comparison unless version_comparison.zero? return build_info.nil? ? 0 : 1 unless other.is_a?(Hex::Version) # Build information comparison lhsegments = build_info.to_s.split(".").map(&:downcase) rhsegments = other.build_info.to_s.split(".").map(&:downcase) limit = [lhsegments.count, rhsegments.count].min lhs = ["1", *lhsegments.first(limit)].join(".") rhs = ["1", *rhsegments.first(limit)].join(".") local_comparison = Gem::Version.new(lhs) <=> Gem::Version.new(rhs) return local_comparison unless local_comparison.zero? lhsegments.count <=> rhsegments.count end
to_s()
click to toggle source
# File lib/dependabot/hex/version.rb, line 32 def to_s @version_string end