Class: Dependabot::GoModules::Version

Inherits:
Gem::Version
  • Object
show all
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/.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ Version

Returns a new instance of Version.



24
25
26
27
28
29
# File 'lib/dependabot/go_modules/version.rb', line 24

def initialize(version)
  @version_string = version.to_s.gsub(/^v/, "")
  version = version.gsub(/^v/, "") if version.is_a?(String)
  version = version&.to_s&.split("+")&.first
  super
end

Class Method Details

.correct?(version) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/dependabot/go_modules/version.rb', line 18

def self.correct?(version)
  version = version.gsub(/^v/, "") if version.is_a?(String)
  version = version&.to_s&.split("+")&.first
  super(version)
end

Instance Method Details

#inspectObject

:nodoc:



31
32
33
# File 'lib/dependabot/go_modules/version.rb', line 31

def inspect # :nodoc:
  "#<#{self.class} #{@version_string.inspect}>"
end

#to_sObject



35
36
37
# File 'lib/dependabot/go_modules/version.rb', line 35

def to_s
  @version_string
end