One less place where Formula is reopened
This commit is contained in:
parent
16a2220834
commit
89dc0b9787
@ -34,20 +34,13 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Formula extensions for auditing
|
|
||||||
class Formula
|
|
||||||
def text
|
|
||||||
@text ||= FormulaText.new(@path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class FormulaText
|
class FormulaText
|
||||||
def initialize path
|
def initialize path
|
||||||
@text = path.open("rb", &:read)
|
@text = path.open("rb", &:read)
|
||||||
end
|
end
|
||||||
|
|
||||||
def without_patch
|
def without_patch
|
||||||
@text.split("__END__")[0].strip()
|
@text.split("\n__END__").first
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_DATA?
|
def has_DATA?
|
||||||
@ -86,7 +79,7 @@ class FormulaAuditor
|
|||||||
def initialize(formula)
|
def initialize(formula)
|
||||||
@formula = formula
|
@formula = formula
|
||||||
@problems = []
|
@problems = []
|
||||||
@text = formula.text.without_patch
|
@text = FormulaText.new(formula.path)
|
||||||
@specs = %w{stable devel head}.map { |s| formula.send(s) }.compact
|
@specs = %w{stable devel head}.map { |s| formula.send(s) }.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -95,15 +88,15 @@ class FormulaAuditor
|
|||||||
problem "Incorrect file permissions: chmod 644 #{formula.path}"
|
problem "Incorrect file permissions: chmod 644 #{formula.path}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if formula.text.has_DATA? and not formula.text.has_END?
|
if text.has_DATA? and not text.has_END?
|
||||||
problem "'DATA' was found, but no '__END__'"
|
problem "'DATA' was found, but no '__END__'"
|
||||||
end
|
end
|
||||||
|
|
||||||
if formula.text.has_END? and not formula.text.has_DATA?
|
if text.has_END? and not text.has_DATA?
|
||||||
problem "'__END__' was found, but 'DATA' is not used"
|
problem "'__END__' was found, but 'DATA' is not used"
|
||||||
end
|
end
|
||||||
|
|
||||||
unless formula.text.has_trailing_newline?
|
unless text.has_trailing_newline?
|
||||||
problem "File should end with a newline"
|
problem "File should end with a newline"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -556,7 +549,7 @@ class FormulaAuditor
|
|||||||
audit_conflicts
|
audit_conflicts
|
||||||
audit_patches
|
audit_patches
|
||||||
audit_text
|
audit_text
|
||||||
text.split("\n").each_with_index {|line, lineno| audit_line(line, lineno+1) }
|
text.without_patch.split("\n").each_with_index { |line, lineno| audit_line(line, lineno+1) }
|
||||||
audit_installed
|
audit_installed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user