Skip to content

Commit e6f5729

Browse files
committed
Rearrange guard clauses
1 parent 7120179 commit e6f5729

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/spoom/bundler_helper.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@ class << self
1616
def gem_requirement_from_real_bundle(gem_name)
1717
specs = Bundler.load.gems[gem_name]
1818

19-
if 1 < specs.count
19+
if specs.nil? || specs.empty?
20+
raise "Did not find gem #{gem_name.inspect} in the current bundle"
21+
elsif specs.count > 1
2022
raise <<~MSG
2123
Found multiple versions of #{gem_name.inspect} in the current bundle:
2224
#{specs.sort_by(&:version).map { |spec| " - #{spec.name} #{spec.version}" }.join("\n")}
2325
MSG
26+
else
27+
spec = specs.first
28+
%(gem "#{spec.name}", "= #{spec.version}")
2429
end
25-
26-
unless (spec = specs.first)
27-
raise "Did not find gem #{gem_name.inspect} in the current bundle"
28-
end
29-
30-
%(gem "#{spec.name}", "= #{spec.version}")
3130
end
3231
end
3332
end

0 commit comments

Comments
 (0)