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:   end

Public Instance methods

[Source]

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

[Source]

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

[Source]

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

[Validate]