diff options
| author | Adam Vandenberg | 2010-08-09 11:59:16 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-08-09 11:59:27 -0700 |
| commit | 65b3f4be916586e0ba9f7a7263b430b5bb2f3f15 (patch) | |
| tree | a5a31083d973aa51ccb7666c5e1a58727391afc1 /Library | |
| parent | fc4f54594a2c7a8765130910da4fa9088e8d016b (diff) | |
| download | homebrew-65b3f4be916586e0ba9f7a7263b430b5bb2f3f15.tar.bz2 | |
brew audit - refactor text checks to make easier to test
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/Contributions/examples/brew-audit.rb | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/Library/Contributions/examples/brew-audit.rb b/Library/Contributions/examples/brew-audit.rb index 7733fdc4e..7e28e99d5 100755 --- a/Library/Contributions/examples/brew-audit.rb +++ b/Library/Contributions/examples/brew-audit.rb @@ -6,12 +6,9 @@ def ff return ARGV.formulae end -ff.each do |f| - text = "" +def audit_formula_text text problems = [] - File.open(f.path, "r") { |afile| text = afile.read } - # Commented-out cmake support from default template if text =~ /# depends_on 'cmake'/ problems << " * Commented cmake support found." @@ -42,8 +39,8 @@ ff.each do |f| problems << " * \"#{$1}\" should be \"\#{#{$2}}\"" end - if text =~ %r[(\#\{prefix\}/share/man/(man[1-8]))] - problems << " * \"#{$1}\" should be \"\#{#{$2}}\"" + if text =~ %r[((\#\{prefix\}/share/man/|\#\{man\}/)(man[1-8]))] + problems << " * \"#{$1}\" should be \"\#{#{$3}}\"" end if text =~ %r[(\#\{prefix\}/share/(info|man))] @@ -66,15 +63,30 @@ ff.each do |f| problems << " * Trailing whitespace was found." end - # Don't depend_on aliases; use full name - aliases = Formula.aliases - f.deps.select {|d| aliases.include? d}.each do |d| - problems << " * Dep #{d} is an alias; switch to the real name." - end + return problems +end + +def audit_some_formulae + ff.each do |f| + problems = [] - unless problems.empty? - puts "#{f.name}:" - puts problems * "\n" - puts + # Don't depend_on aliases; use full name + aliases = Formula.aliases + f.deps.select {|d| aliases.include? d}.each do |d| + problems << " * Dep #{d} is an alias; switch to the real name." + end + + text = "" + File.open(f.path, "r") { |afile| text = afile.read } + + problems += audit_formula_text(text) + + unless problems.empty? + puts "#{f.name}:" + puts problems * "\n" + puts + end end end + +audit_some_formulae |
