Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • rubygems/commands/build_command.rb

Class/Module Index [+]

Quicksearch

Gem::Commands::BuildCommand

Public Class Methods

new() click to toggle source
 
               # File rubygems/commands/build_command.rb, line 6
def initialize
  super('build', 'Build a gem from a gemspec')
end
            

Public Instance Methods

execute() click to toggle source
 
               # File 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
            
load_gemspecs(filename) click to toggle source
 
               # File 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 => e
        # OK
      end
    end
  else
    result = [Gem::Specification.load(filename)]
  end
  result
end
            
yaml?(filename) click to toggle source
 
               # File 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
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus