Class: Dependabot::Version

Inherits:
Gem::Version
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/dependabot/version.rb

Constant Summary collapse

VersionParameter =
T.type_alias { T.nilable(T.any(String, Integer, Gem::Version)) }

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ Version

Returns a new instance of Version.



16
17
18
19
20
# File 'lib/dependabot/version.rb', line 16

def initialize(version)
  @original_version = T.let(version.to_s, String)

  super
end

Class Method Details

.correct?(version) ⇒ Boolean

Returns:

  • (Boolean)


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

def self.correct?(version)
  return false if version.nil?

  version.to_s.match?(ANCHORED_VERSION_PATTERN)
end

.new(version) ⇒ Object



23
24
25
# File 'lib/dependabot/version.rb', line 23

def self.new(version)
  T.cast(super, Dependabot::Version)
end

Instance Method Details

#to_semverObject



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

def to_semver
  @original_version
end