Replace long conditional with guard clauses

This commit is contained in:
Jack Nagel 2013-08-14 14:13:03 -05:00
parent d77240a98c
commit 7ddc432c9e

View File

@ -35,15 +35,11 @@ def python_helper(options={:allowed_major_versions => [2, 3]}, &block)
filtered_python_reqs = []
while !python_reqs.empty?
py = python_reqs.shift
# this is ulgy but Ruby 1.8 has no `uniq! { }`
if !filtered_python_reqs.map{ |fpr| fpr.binary }.include?(py.binary) &&
py.satisfied? &&
options[:allowed_major_versions].include?(py.version.major) &&
# if optional or recommended then check the build.with?
(self.build.with?(py.name) || !(py.optional? || py.recommended?))
then
filtered_python_reqs << py
end
next if filtered_python_reqs.any? { |req| req.binary == py.binary }
next unless py.satisfied?
next unless options[:allowed_major_versions].include?(py.version.major)
next if (py.optional? || py.recommended?) && build.without?(py.name)
filtered_python_reqs << py
end
# Allow to use an else-branch like so: `if python do ... end; else ... end`