Class Gem::Commands::BuildCommand
In: lib/rubygems/commands/build_command.rb
Parent: Gem::Command

Methods

execute   load_gemspec   new   yaml?  

Public Class methods

[Source]

    # File lib/rubygems/commands/build_command.rb, line 6
 6:   def initialize
 7:     super 'build', 'Build a gem from a gemspec'
 8: 
 9:     add_option '--force', 'skip validation of the spec' do |value, options|
10:       options[:force] = true
11:     end
12:   end

Public Instance methods

[Source]

    # File lib/rubygems/commands/build_command.rb, line 22
22:   def execute
23:     gemspec = get_one_gem_name
24: 
25:     if File.exist? gemspec
26:       spec = load_gemspec gemspec
27: 
28:       if spec then
29:         Gem::Builder.new(spec).build options[:force]
30:       else
31:         alert_error "Error loading gemspec. Aborting."
32:         terminate_interaction 1
33:       end
34:     else
35:       alert_error "Gemspec file not found: #{gemspec}"
36:       terminate_interaction 1
37:     end
38:   end

[Source]

    # File lib/rubygems/commands/build_command.rb, line 40
40:   def load_gemspec filename
41:     if yaml?(filename)
42:       open(filename) do |f|
43:         begin
44:           Gem::Specification.from_yaml(f)
45:         rescue Gem::EndOfYAMLException
46:           nil
47:         end
48:       end
49:     else
50:       Gem::Specification.load(filename) # can return nil
51:     end
52:   end

[Source]

    # File lib/rubygems/commands/build_command.rb, line 54
54:   def yaml?(filename)
55:     line = open(filename) { |f| line = f.gets }
56:     result = line =~ %r{!ruby/object:Gem::Specification}
57:     result
58:   end

[Validate]