Class: Dependabot::Bazel::Version

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

Instance Attribute Summary collapse

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/bazel/version.rb', line 24

def initialize(version)
  @version_string = T.let(version.to_s, String)
  @bcr_suffix = T.let(parse_bcr_suffix(@version_string), T.nilable(Integer))

  super(Dependabot::Bazel::Version.normalize_bazel_version(@version_string))
end

Instance Attribute Details

#bcr_suffixObject (readonly)

Returns the value of attribute bcr_suffix.



43
44
45
# File 'lib/dependabot/bazel/version.rb', line 43

def bcr_suffix
  @bcr_suffix
end

Class Method Details

.correct?(version) ⇒ Boolean

Returns:

  • (Boolean)


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

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

  super(normalize_bazel_version(version.to_s))
end

.normalize_bazel_version(version_string) ⇒ Object



33
34
35
# File 'lib/dependabot/bazel/version.rb', line 33

def self.normalize_bazel_version(version_string)
  version_string.sub(/\.bcr\.\d+$/, "").sub(/^v/i, "")
end

Instance Method Details

#<=>(other) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/dependabot/bazel/version.rb', line 46

def <=>(other)
  other_bazel = convert_to_bazel_version(other)
  return nil unless other_bazel

  base_comparison = super(other_bazel)
  return base_comparison unless base_comparison&.zero?

  compare_bcr_suffixes(@bcr_suffix, other_bazel.bcr_suffix)
end

#to_sObject



38
39
40
# File 'lib/dependabot/bazel/version.rb', line 38

def to_s
  @version_string
end