Object
The Builder class processes RubyGem specification files to produce a .gem file.
Constructs a builder instance for the provided specification
| spec |
|
# File lib/rubygems/builder.rb, line 27
27: def initialize(spec)
28: @spec = spec
29: end
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
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
# 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.
Generated with the Darkfish Rdoc Generator 1.1.6.