Class: Homebrew::FormulaTextAuditor Private

Inherits:
Object
  • Object
show all
Defined in:
formula_text_auditor.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.

Auditor for checking common violations in Formula text content.

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FormulaTextAuditor

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 a new instance of FormulaTextAuditor.



7
8
9
10
# File 'formula_text_auditor.rb', line 7

def initialize(path)
  @text = path.open("rb", &:read)
  @lines = @text.lines.to_a
end

Instance Method Details

#=~(other) ⇒ Object

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.



20
21
22
# File 'formula_text_auditor.rb', line 20

def =~(other)
  other =~ @text
end

#include?(string) ⇒ Boolean

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:

  • (Boolean)


24
25
26
# File 'formula_text_auditor.rb', line 24

def include?(string)
  @text.include? string
end

#line_number(regex, skip = 0) ⇒ Object

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.



33
34
35
36
# File 'formula_text_auditor.rb', line 33

def line_number(regex, skip = 0)
  index = @lines.drop(skip).index { |line| line.match?(regex) }
  index ? index + 1 : nil
end

#reverse_line_number(regex) ⇒ Object

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.



38
39
40
41
# File 'formula_text_auditor.rb', line 38

def reverse_line_number(regex)
  index = @lines.reverse.index { |line| line.match?(regex) }
  index ? @lines.count - index : nil
end

#trailing_newline?Boolean

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:

  • (Boolean)


16
17
18
# File 'formula_text_auditor.rb', line 16

def trailing_newline?
  /\Z\n/.match?(@text)
end

#without_patchObject

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.



12
13
14
# File 'formula_text_auditor.rb', line 12

def without_patch
  @text.split("\n__END__").first
end