summaryrefslogtreecommitdiff
path: root/lib/bundler/gem_helper.rb
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-01-14 16:21:54 -0600
committerSamuel Giddins <segiddins@segiddins.me>2016-01-31 22:21:13 -0600
commite85b990916f16dd9a56dbafae6503f7a48d55131 (patch)
treef9244f2ab14db6abf5c0bc38ee5508ccfc94aa30 /lib/bundler/gem_helper.rb
parent9297bcf0135a0bd8c1df29b929267582ca66217d (diff)
downloadbundler-e85b990916f16dd9a56dbafae6503f7a48d55131.tar.gz
[RuboCop] Address Style/GuardClause
Diffstat (limited to 'lib/bundler/gem_helper.rb')
-rw-r--r--lib/bundler/gem_helper.rb31
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index 8cfbeb4df1..30822148b4 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -91,18 +91,17 @@ module Bundler
protected
def rubygem_push(path)
- if Pathname.new("~/.gem/credentials").expand_path.exist?
- allowed_push_host = nil
- gem_command = "gem push '#{path}'"
- if @gemspec.respond_to?(:metadata)
- allowed_push_host = @gemspec.metadata["allowed_push_host"]
- gem_command << " --host #{allowed_push_host}" if allowed_push_host
- end
- sh(gem_command)
- Bundler.ui.confirm "Pushed #{name} #{version} to #{allowed_push_host ? allowed_push_host : "rubygems.org."}"
- else
+ unless Pathname.new("~/.gem/credentials").expand_path.file?
raise "Your rubygems.org credentials aren't set. Run `gem push` to set them."
end
+ allowed_push_host = nil
+ gem_command = "gem push '#{path}'"
+ if @gemspec.respond_to?(:metadata)
+ allowed_push_host = @gemspec.metadata["allowed_push_host"]
+ gem_command << " --host #{allowed_push_host}" if allowed_push_host
+ end
+ sh(gem_command)
+ Bundler.ui.confirm "Pushed #{name} #{version} to #{allowed_push_host ? allowed_push_host : "rubygems.org."}"
end
def built_gem_path
@@ -122,10 +121,9 @@ module Bundler
end
def already_tagged?
- if sh("git tag").split(/\n/).include?(version_tag)
- Bundler.ui.confirm "Tag #{version_tag} has already been created."
- true
- end
+ return false unless sh("git tag").split(/\n/).include?(version_tag)
+ Bundler.ui.confirm "Tag #{version_tag} has already been created."
+ true
end
def guard_clean
@@ -164,11 +162,10 @@ module Bundler
def sh(cmd, &block)
out, code = sh_with_code(cmd, &block)
- if code == 0
- out
- else
+ unless code.zero?
raise(out.empty? ? "Running `#{cmd}` failed. Run this command directly for more detailed output." : out)
end
+ out
end
def sh_with_code(cmd, &block)