Parent

Included Modules

Class Index [+]

Quicksearch

Gem::Builder

The Builder class processes RubyGem specification files to produce a .gem file.

Public Class Methods

new(spec) click to toggle source

Constructs a builder instance for the provided specification

spec
Gem::Specification

The specification instance

    # File lib/rubygems/builder.rb, line 27
27:   def initialize(spec)
28:     @spec = spec
29:   end

Public Instance Methods

build() click to toggle source

Builds the gem from the specification. Returns the name of the file written.

    # File lib/rubygems/builder.rb, line 35
35:   def build
36:     @spec.mark_version
37:     @spec.validate
38:     @signer = sign
39:     write_package
40:     say success if Gem.configuration.verbose
41:     File.basename @spec.cache_file
42:   end
success() click to toggle source
    # File lib/rubygems/builder.rb, line 44
44:   def success
45:       Successfully built RubyGem  Name: #{@spec.name}  Version: #{@spec.version}  File: #{File.basename @spec.cache_file}
46:   end

Private Instance Methods

sign() click to toggle source

If the signing key was specified, then load the file, and swap to the public key (TODO: we should probably just omit the signing key in favor of the signing certificate, but that’s for the future, also the signature algorithm should be configurable)

    # File lib/rubygems/builder.rb, line 61
61:   def sign
62:     signer = nil
63: 
64:     if @spec.respond_to?(:signing_key) and @spec.signing_key then
65:       require 'rubygems/security'
66: 
67:       signer = Gem::Security::Signer.new @spec.signing_key, @spec.cert_chain
68:       @spec.signing_key = nil
69:       @spec.cert_chain = signer.cert_chain.map { |cert| cert.to_s }
70:     end
71: 
72:     signer
73:   end
write_package() click to toggle source
    # File lib/rubygems/builder.rb, line 75
75:   def write_package
76:     file_name = File.basename @spec.cache_file
77:     open file_name, 'wb' do |gem_io|
78:       Gem::Package.open gem_io, 'w', @signer do |pkg|
79:         yaml = @spec.to_yaml
80:         pkg.metadata = yaml
81: 
82:         @spec.files.each do |file|
83:           next if File.directory?(file)
84:           next if file == file_name # Don't add gem onto itself
85: 
86:           stat = File.stat(file)
87:           mode = stat.mode & 0777
88:           size = stat.size
89: 
90:           pkg.add_file_simple file, mode, size do |tar_io|
91:             tar_io.write open(file, "rb") { |f| f.read }
92:           end
93:         end
94:       end
95:     end
96:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.