Class: Dependabot::Utils::Elixir::Version
- Inherits:
-
Gem::Version
- Object
- Gem::Version
- Dependabot::Utils::Elixir::Version
- Defined in:
- lib/dependabot/utils/elixir/version.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#build_info ⇒ Object
readonly
Returns the value of attribute build_info.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
-
#inspect ⇒ Object
:nodoc:.
- #to_s ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
23 24 25 26 27 28 29 30 31 |
# File 'lib/dependabot/utils/elixir/version.rb', line 23 def initialize(version) @version_string = version.to_s if version.to_s.include?("+") version, @build_info = version.to_s.split("+") end super end |
Instance Attribute Details
#build_info ⇒ Object (readonly)
Returns the value of attribute build_info.
13 14 15 |
# File 'lib/dependabot/utils/elixir/version.rb', line 13 def build_info @build_info end |
Class Method Details
.correct?(version) ⇒ Boolean
18 19 20 21 |
# File 'lib/dependabot/utils/elixir/version.rb', line 18 def self.correct?(version) version = version.to_s.split("+").first if version.to_s.include?("+") super end |
Instance Method Details
#<=>(other) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dependabot/utils/elixir/version.rb', line 41 def <=>(other) version_comparison = super(other) return version_comparison unless version_comparison.zero? unless other.is_a?(Utils::Elixir::Version) return build_info.nil? ? 0 : 1 end # 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 |
#inspect ⇒ Object
:nodoc:
37 38 39 |
# File 'lib/dependabot/utils/elixir/version.rb', line 37 def inspect # :nodoc: "#<#{self.class} #{@version_string}>" end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/dependabot/utils/elixir/version.rb', line 33 def to_s @version_string end |