diff options
| author | Jack Nagel | 2013-08-14 14:13:03 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-08-14 14:13:03 -0500 |
| commit | 030ca6adf5071c7c52020fd4cf5bec4b675a78b5 (patch) | |
| tree | 5bbe3bda9ccb46a0994e9e29dc276284fbf60cc3 /Library/Homebrew | |
| parent | e1695f0e6755a12eb49e9008168d8d9f1c6df8fa (diff) | |
| download | homebrew-030ca6adf5071c7c52020fd4cf5bec4b675a78b5.tar.bz2 | |
Replace long conditional with guard clauses
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/python_helper.rb | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Library/Homebrew/python_helper.rb b/Library/Homebrew/python_helper.rb index 3fd501bb2..c99fce2c7 100644 --- a/Library/Homebrew/python_helper.rb +++ b/Library/Homebrew/python_helper.rb @@ -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` |
