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

Methods

execute   load_gemspecs   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:     if File.exist?(gemspec)
21:       specs = load_gemspecs(gemspec)
22:       specs.each do |spec|
23:         Gem::Builder.new(spec).build
24:       end
25:     else
26:       alert_error "Gemspec file not found: #{gemspec}"
27:     end
28:   end

[Source]

    # File lib/rubygems/commands/build_command.rb, line 30
30:   def load_gemspecs(filename)
31:     if yaml?(filename)
32:       result = []
33:       open(filename) do |f|
34:         begin
35:           while not f.eof? and spec = Gem::Specification.from_yaml(f)
36:             result << spec
37:           end
38:         rescue Gem::EndOfYAMLException
39:           # OK
40:         end
41:       end
42:     else
43:       result = [Gem::Specification.load(filename)]
44:     end
45:     result
46:   end

[Source]

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

[Validate]