Class: Homebrew::FormulaNameCaskTokenAuditor Private

Inherits:
Object
  • Object
show all
Defined in:
formula_name_cask_token_auditor.rb

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ 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:



10
11
12
# File 'formula_name_cask_token_auditor.rb', line 10

def initialize(token)
  @token = token
end

Instance Attribute Details

#tokenString (readonly)

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.

Returns:



7
8
9
# File 'formula_name_cask_token_auditor.rb', line 7

def token
  @token
end

Instance Method Details

#errorsArray<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.

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'formula_name_cask_token_auditor.rb', line 15

def errors
  errors = []

  errors << "uppercase letters" if token.match?(/[A-Z]/)
  errors << "whitespace" if token.match?(/\s/)
  errors << "non-ASCII characters" unless token.ascii_only?
  errors << "double hyphens" if token.include?("--")

  errors << "a leading @" if token.start_with?("@")
  errors << "a trailing @" if token.end_with?("@")
  errors << "a leading hyphen" if token.start_with?("-")
  errors << "a trailing hyphen" if token.end_with?("-")

  errors << "multiple @ symbols" if token.count("@") > 1

  errors << "a hyphen followed by an @" if token.include? "-@"
  errors << "an @ followed by a hyphen" if token.include? "@-"

  errors
end