Class: Version::RegexParser Abstract Private

Inherits:
Parser
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
version/parser.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

This class is abstract.

It cannont be directly instantiated. Subclasses must implement the abstract methods below.

Direct Known Subclasses

StemParser, UrlParser

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regex, &block) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • regex (Regexp)
  • block (T.proc.params(arg0: String).returns(String), nil)


22
23
24
25
26
# File 'version/parser.rb', line 22

def initialize(regex, &block)
  super()
  @regex = regex
  @block = block
end

Class Method Details

.process_spec(spec) ⇒ String

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method is abstract.

Parameters:

Returns:



41
# File 'version/parser.rb', line 41

def self.process_spec(spec); end

Instance Method Details

#parse(spec) ⇒ String?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:



29
30
31
32
33
34
35
36
37
38
# File 'version/parser.rb', line 29

def parse(spec)
  match = @regex.match(self.class.process_spec(spec))
  return if match.blank?

  version = match.captures.first
  return if version.blank?
  return @block.call(version) if @block.present?

  version
end