Class: Homebrew::FormulaTextAuditor Private
- Inherits:
-
Object
- Object
- Homebrew::FormulaTextAuditor
- Defined in:
- brew/Library/Homebrew/formula_text_auditor.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Auditor for checking common violations in Formula text content.
Instance Method Summary collapse
-
#=~(other) ⇒ Object
private
-
#include?(s) ⇒ Boolean
private
-
#initialize(path) ⇒ FormulaTextAuditor
constructor
private
A new instance of FormulaTextAuditor.
-
#line_number(regex, skip = 0) ⇒ Object
private
-
#reverse_line_number(regex) ⇒ Object
private
-
#trailing_newline? ⇒ Boolean
private
-
#without_patch ⇒ Object
private
Constructor Details
#initialize(path) ⇒ FormulaTextAuditor
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of FormulaTextAuditor.
9 10 11 12 |
# File 'brew/Library/Homebrew/formula_text_auditor.rb', line 9 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. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'brew/Library/Homebrew/formula_text_auditor.rb', line 22 def =~(other) other =~ @text end |
#include?(s) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'brew/Library/Homebrew/formula_text_auditor.rb', line 26 def include?(s) @text.include? s end |
#line_number(regex, skip = 0) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 |
# File 'brew/Library/Homebrew/formula_text_auditor.rb', line 30 def line_number(regex, skip = 0) index = @lines.drop(skip).index { |line| line =~ regex } index ? index + 1 : nil end |
#reverse_line_number(regex) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 |
# File 'brew/Library/Homebrew/formula_text_auditor.rb', line 35 def reverse_line_number(regex) index = @lines.reverse.index { |line| line =~ regex } index ? @lines.count - index : nil end |
#trailing_newline? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 |
# File 'brew/Library/Homebrew/formula_text_auditor.rb', line 18 def trailing_newline? /\Z\n/ =~ @text end |
#without_patch ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'brew/Library/Homebrew/formula_text_auditor.rb', line 14 def without_patch @text.split("\n__END__").first end |