2007-11-10 02:48:56 -05:00
|
|
|
require 'rubygems/command'
|
2012-11-29 01:52:18 -05:00
|
|
|
require 'rubygems/package'
|
2007-11-10 02:48:56 -05:00
|
|
|
|
|
|
|
class Gem::Commands::BuildCommand < Gem::Command
|
|
|
|
|
|
|
|
def initialize
|
2012-04-17 20:04:12 -04:00
|
|
|
super 'build', 'Build a gem from a gemspec'
|
|
|
|
|
|
|
|
add_option '--force', 'skip validation of the spec' do |value, options|
|
|
|
|
options[:force] = true
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def arguments # :nodoc:
|
|
|
|
"GEMSPEC_FILE gemspec file name to build a gem for"
|
|
|
|
end
|
|
|
|
|
|
|
|
def usage # :nodoc:
|
|
|
|
"#{program_name} GEMSPEC_FILE"
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
|
|
|
gemspec = get_one_gem_name
|
2011-05-31 23:45:05 -04:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
if File.exist? gemspec then
|
|
|
|
spec = Gem::Specification.load gemspec
|
2011-05-31 23:45:05 -04:00
|
|
|
|
|
|
|
if spec then
|
2012-11-29 01:52:18 -05:00
|
|
|
Gem::Package.build spec, options[:force]
|
2011-05-31 23:45:05 -04:00
|
|
|
else
|
|
|
|
alert_error "Error loading gemspec. Aborting."
|
|
|
|
terminate_interaction 1
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
else
|
|
|
|
alert_error "Gemspec file not found: #{gemspec}"
|
2011-05-31 23:45:05 -04:00
|
|
|
terminate_interaction 1
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2012-11-29 01:52:18 -05:00
|
|
|
|