Simplify valid_formula_location? method

This commit is contained in:
Jack Nagel 2014-06-27 21:58:15 -05:00
parent 982a165e52
commit 346fa5098f

View File

@ -232,13 +232,14 @@ class Report < Hash
end end
def valid_formula_location?(relative_path) def valid_formula_location?(relative_path)
ruby_file = /\A.*\.rb\Z/
parts = relative_path.split('/')[2..-1] parts = relative_path.split('/')[2..-1]
[ return false unless File.extname(parts.last) == ".rb"
parts.length == 1 && parts.first =~ ruby_file, case parts.first
parts.length == 2 && parts.first == 'Formula' && parts.last =~ ruby_file, when "Formula", "HomebrewFormula"
parts.length == 2 && parts.first == 'HomebrewFormula' && parts.last =~ ruby_file, parts.length == 2
].any? else
parts.length == 1
end
end end
def new_tapped_formula def new_tapped_formula