Class: Version::RegexParser Abstract Private

Inherits:
Parser show all
Extended by:
T::Helpers
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 cannot 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)


18
19
20
21
22
# File 'version/parser.rb', line 18

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:



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

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:



25
26
27
28
29
30
31
32
33
34
# File 'version/parser.rb', line 25

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