Class: Dependabot::GithubActions::Version

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ Version

Returns a new instance of Version.



15
16
17
18
# File 'lib/dependabot/github_actions/version.rb', line 15

def initialize(version)
  version = Version.remove_leading_v(version)
  super
end

Class Method Details

.correct?(version) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
# File 'lib/dependabot/github_actions/version.rb', line 38

def self.correct?(version)
  return false if version.to_s.strip.empty?

  version = Version.remove_leading_v(version)
  super
end

.new(version) ⇒ Object



21
22
23
# File 'lib/dependabot/github_actions/version.rb', line 21

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

.path_based?(version) ⇒ Boolean

Returns:

  • (Boolean)


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

def self.path_based?(version)
  version.to_s.match?(%r{\A.+/v?([0-9])})
end

.remove_leading_v(version) ⇒ Object



26
27
28
29
30
# File 'lib/dependabot/github_actions/version.rb', line 26

def self.remove_leading_v(version)
  return version unless version.to_s.match?(%r{\A(?:.*/)?v?([0-9])})

  version.to_s.sub(%r{\A(?:.*/)?v?}, "")
end