Spec-Zone.ru › Homebrew

Class: Version::RegexParser Abstract Private

Inherits:
Parser
  • Object
  • Parser
  • Version::RegexParser
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

  • .process_spec(spec) ⇒ String abstract private

Instance Method Summary collapse

  • #initialize(regex, &block) ⇒ void constructor private
  • #parse(spec) ⇒ String? private

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)


20
21
22
23
24
# File 'version/parser.rb', line 20

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:

  • spec (Pathname)

Returns:

  • (String)


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

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:

  • spec (Pathname)

Returns:

  • (String, nil)


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

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

© 2009–present Homebrew contributors
Licensed under the BSD 2-Clause License.
https://docs.brew.sh/rubydoc/Version/RegexParser.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API