Class: Gem::Commands::BuildCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::BuildCommand
- Defined in:
- lib/rubygems/commands/build_command.rb
Constant Summary
Constant Summary
Constants inherited from Gem::Command
Instance Attribute Summary
Attributes inherited from Gem::Command
#command, #defaults, #options, #program_name, #summary
Instance Method Summary (collapse)
-
- (Object) arguments
:nodoc:.
- - (Object) execute
-
- (BuildCommand) initialize
constructor
A new instance of BuildCommand.
- - (Object) load_gemspecs(filename)
-
- (Object) usage
:nodoc:.
- - (Boolean) yaml?(filename)
Methods inherited from Gem::Command
add_common_option, #add_extra_args, #add_option, add_specific_extra_args, #begins?, build_args, build_args=, common_options, #defaults_str, #description, extra_args, extra_args=, #get_all_gem_names, #get_one_gem_name, #get_one_optional_argument, #handle_options, #handles?, #invoke, #merge_options, #remove_option, #show_help, #show_lookup_failure, specific_extra_args, specific_extra_args_hash, #when_invoked
Methods included from UserInteraction
Methods included from DefaultUserInteraction
ui, #ui, #ui=, ui=, use_ui, #use_ui
Constructor Details
- (BuildCommand) initialize
A new instance of BuildCommand
6 7 8 |
# File 'lib/rubygems/commands/build_command.rb', line 6 def initialize super('build', 'Build a gem from a gemspec') end |
Instance Method Details
- (Object) arguments
:nodoc:
10 11 12 |
# File 'lib/rubygems/commands/build_command.rb', line 10 def arguments # :nodoc: "GEMSPEC_FILE gemspec file name to build a gem for" end |
- (Object) execute
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubygems/commands/build_command.rb', line 18 def execute gemspec = get_one_gem_name if File.exist?(gemspec) specs = load_gemspecs(gemspec) specs.each do |spec| Gem::Builder.new(spec).build end else alert_error "Gemspec file not found: #{gemspec}" end end |
- (Object) load_gemspecs(filename)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rubygems/commands/build_command.rb', line 30 def load_gemspecs(filename) if yaml?(filename) result = [] open(filename) do |f| begin while not f.eof? and spec = Gem::Specification.from_yaml(f) result << spec end rescue Gem::EndOfYAMLException # OK end end else result = [Gem::Specification.load(filename)] end result end |
- (Object) usage
:nodoc:
14 15 16 |
# File 'lib/rubygems/commands/build_command.rb', line 14 def usage # :nodoc: "#{program_name} GEMSPEC_FILE" end |
- (Boolean) yaml?(filename)
48 49 50 51 52 |
# File 'lib/rubygems/commands/build_command.rb', line 48 def yaml?(filename) line = open(filename) { |f| line = f.gets } result = line =~ %r{!ruby/object:Gem::Specification} result end |