Class: Dependabot::GoModules::Version
- Inherits:
-
Version
- Object
- Version
- Dependabot::GoModules::Version
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/go_modules/version.rb
Constant Summary collapse
- VERSION_PATTERN =
'[0-9]+[0-9a-zA-Z]*(?>\.[0-9a-zA-Z]+)*' \ '(-[0-9A-Za-z-]+(\.[0-9a-zA-Z-]+)*)?' \ '(\+incompatible)?'
- ANCHORED_VERSION_PATTERN =
/\A\s*(#{VERSION_PATTERN})?\s*\z/
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.
33 34 35 36 37 38 39 40 41 |
# File 'lib/dependabot/go_modules/version.rb', line 33 def initialize(version) @version_string = T.let(version.to_s.gsub(/^v/, ""), String) version = version.gsub(/^v/, "") if version.is_a?(String) version = version.to_s.split("+").first if version.to_s.include?("+") @prerelease = T.let(nil, T.nilable(String)) version, @prerelease = version.to_s.split("-", 2) if version.to_s.include?("-") super end |
Class Method Details
.correct?(version) ⇒ Boolean
25 26 27 28 29 30 |
# File 'lib/dependabot/go_modules/version.rb', line 25 def self.correct?(version) version = version.gsub(/^v/, "") if version.is_a?(String) version = version.to_s.split("+").first if version.to_s.include?("+") super end |
Instance Method Details
#<=>(other) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/dependabot/go_modules/version.rb', line 54 def <=>(other) result = super return if result.nil? return result unless result.zero? other = self.class.new(other.to_s) unless other.is_a?(Version) compare_prerelease(@prerelease || "", T.unsafe(other).prerelease || "") end |
#inspect ⇒ Object
:nodoc:
44 45 46 |
# File 'lib/dependabot/go_modules/version.rb', line 44 def inspect # :nodoc: "#<#{self.class} #{@version_string.inspect}>" end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/dependabot/go_modules/version.rb', line 49 def to_s @version_string end |