Class: Homebrew::FormulaTextAuditor Private
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
-
#=~(other) ⇒ Object
private
-
#include?(string) ⇒ 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
-
#to_s ⇒ Object
private
-
#trailing_newline? ⇒ Boolean
private
-
#without_patch ⇒ Object
private
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.
9 10 11 12 |
# File '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. 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.
22 23 24 |
# File 'formula_text_auditor.rb', line 22 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.
26 27 28 |
# File 'formula_text_auditor.rb', line 26 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.
34 35 36 37 |
# File 'formula_text_auditor.rb', line 34 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. 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.
39 40 41 42 |
# File 'formula_text_auditor.rb', line 39 def reverse_line_number(regex) index = @lines.reverse.index { |line| line =~ regex } index ? @lines.count - index : nil end |
#to_s ⇒ 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.
30 31 32 |
# File 'formula_text_auditor.rb', line 30 def to_s @text 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.
18 19 20 |
# File 'formula_text_auditor.rb', line 18 def trailing_newline? /\Z\n/ =~ @text end |
#without_patch ⇒ 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.
14 15 16 |
# File 'formula_text_auditor.rb', line 14 def without_patch @text.split("\n__END__").first end |