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 22 22: def initialize(spec) 23: require "yaml" 24: require "rubygems/package" 25: require "rubygems/security" 26: 27: @spec = spec 28: end
Builds the gem from the specification. Returns the name of the file written.
# File lib/rubygems/builder.rb, line 34 34: def build 35: @spec.mark_version 36: @spec.validate 37: @signer = sign 38: write_package 39: say success if Gem.configuration.verbose 40: @spec.file_name 41: 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 60 60: def sign 61: signer = nil 62: 63: if @spec.respond_to?(:signing_key) and @spec.signing_key then 64: signer = Gem::Security::Signer.new @spec.signing_key, @spec.cert_chain 65: @spec.signing_key = nil 66: @spec.cert_chain = signer.cert_chain.map { |cert| cert.to_s } 67: end 68: 69: signer 70: end
# File lib/rubygems/builder.rb, line 72 72: def write_package 73: open @spec.file_name, 'wb' do |gem_io| 74: Gem::Package.open gem_io, 'w', @signer do |pkg| 75: pkg.metadata = @spec.to_yaml 76: 77: @spec.files.each do |file| 78: next if File.directory? file 79: next if file == @spec.file_name # Don't add gem onto itself 80: 81: stat = File.stat file 82: mode = stat.mode & 0777 83: size = stat.size 84: 85: pkg.add_file_simple file, mode, size do |tar_io| 86: tar_io.write open(file, "rb") { |f| f.read } 87: end 88: end 89: end 90: end 91: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.