Class: Dependabot::Terraform::Version

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ Version

Returns a new instance of Version.



20
21
22
23
24
25
26
# File 'lib/dependabot/terraform/version.rb', line 20

def initialize(version)
  @version_string = T.let(version.to_s, String)
  version = Version.remove_leading_v(version)
  version = Version.remove_backport(version)

  super
end

Class Method Details

.correct?(version) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
46
# File 'lib/dependabot/terraform/version.rb', line 39

def self.correct?(version)
  version = Version.remove_leading_v(version)
  version = Version.remove_backport(version)

  return false if version.to_s.strip.empty?

  super
end

.new(version) ⇒ Object



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

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

.remove_backport(version) ⇒ Object



56
57
58
59
60
# File 'lib/dependabot/terraform/version.rb', line 56

def self.remove_backport(version)
  return version.split("+").first if version.is_a?(String) && version.include?("+")

  version
end

.remove_leading_v(version) ⇒ Object



49
50
51
52
53
# File 'lib/dependabot/terraform/version.rb', line 49

def self.remove_leading_v(version)
  return version.gsub(/^v/, "") if version.is_a?(String)

  version
end

Instance Method Details

#to_sObject



34
35
36
# File 'lib/dependabot/terraform/version.rb', line 34

def to_s
  @version_string
end