aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/commands/build_command.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-22 06:28:04 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-22 06:28:04 +0000
commit3dc6efbe9ca582d6930f25754a16043dedecfa6f (patch)
tree35980c7383e9e12d092e0eff78f5f16eca2fa1fc /lib/rubygems/commands/build_command.rb
parent59a6215af65b3bfade13836681cbacc3294e6e78 (diff)
downloadruby-3dc6efbe9ca582d6930f25754a16043dedecfa6f.tar.gz
Merge rubygems master targeted RubyGems 3.1.0.
https://github.com/rubygems/rubygems/commit/1172320540c8c33c59fc1db5191b021c3b2db487 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/build_command.rb')
-rw-r--r--lib/rubygems/commands/build_command.rb41
1 files changed, 28 insertions, 13 deletions
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index e59471e976..761b80ee94 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -18,6 +18,10 @@ class Gem::Commands::BuildCommand < Gem::Command
add_option '-o', '--output FILE', 'output gem with the given filename' do |value, options|
options[:output] = value
end
+
+ add_option '-C PATH', '', 'Run as if gem build was started in <PATH> instead of the current working directory.' do |value, options|
+ options[:build_path] = value
+ end
end
def arguments # :nodoc:
@@ -60,25 +64,36 @@ Gems can be saved to a specified filename with the output option:
end
if File.exist? gemspec
- Dir.chdir(File.dirname(gemspec)) do
- spec = Gem::Specification.load File.basename(gemspec)
-
- if spec
- Gem::Package.build(
- spec,
- options[:force],
- options[:strict],
- options[:output]
- )
- else
- alert_error "Error loading gemspec. Aborting."
- terminate_interaction 1
+ spec = Gem::Specification.load(gemspec)
+
+ if options[:build_path]
+ Dir.chdir(File.dirname(gemspec)) do
+ spec = Gem::Specification.load File.basename(gemspec)
+ build_package(spec)
end
+ else
+ build_package(spec)
end
+
else
alert_error "Gemspec file not found: #{gemspec}"
terminate_interaction 1
end
end
+ private
+
+ def build_package(spec)
+ if spec
+ Gem::Package.build(
+ spec,
+ options[:force],
+ options[:strict],
+ options[:output]
+ )
+ else
+ alert_error "Error loading gemspec. Aborting."
+ terminate_interaction 1
+ end
+ end
end