Class

Example using a Gem::Package

Builds a .gem file given a Gem::Specification. A .gem file is a tarball which contains a data.tar.gz, metadata.gz, checksums.yaml.gz and possibly signatures.

require 'rubygems'
require 'rubygems/package'

spec = Gem::Specification.new do |s|
  s.summary = "Ruby based make-like utility."
  s.name = 'rake'
  s.version = PKG_VERSION
  s.requirements << 'none'
  s.files = PKG_FILES
  s.description = <<-EOF
Rake is a Make-like program implemented in Ruby. Tasks
and dependencies are specified in standard Ruby syntax.
  EOF
end

Gem::Package.build spec

Reads a .gem file.

require 'rubygems'
require 'rubygems/package'

the_gem = Gem::Package.new(path_to_dot_gem)
the_gem.contents # get the files in the gem
the_gem.extract_files destination_directory # extract the gem into a directory
the_gem.spec # get the spec out of the gem
the_gem.verify # check the gem is OK (contains valid gem specification, contains a not corrupt contents archive)

files are the files in the .gem tar file, not the Ruby files in the gem extract_files and contents automatically call verify

Attributes
Read

Checksums for the contents of the package

Read

The files in this package. This is not the contents of the gem, just the files in the top-level container.

gem

Read

Reference to the gem being packaged.

Read & Write

The security policy used for verifying the contents of this package.

Write

Sets the Gem::Specification to use to build this package.

Read & Write

Permission for directories

Read & Write

Permission for program files

Read & Write

Permission for other files

Class Methods
No documentation available

Creates a new Gem::Package for the file at gem. gem can also be provided as an IO object.

If gem is an existing file in the old format a Gem::Package::Old will be returned.

Extracts the Gem::Specification and raw metadata from the .gem file at path.

Instance Methods

Adds a checksum for each entry in the gem to checksums.yaml.gz.

Builds this package based on the specification set by spec=

A list of file names contained in this gem

Copies this package to path (if possible)

Extracts the files in this package into destination_dir

If pattern is specified, only entries matching that glob will be extracted.

Gzips content written to gz_io to io.

Creates a new package that will read or write to the file gem.

No documentation available
No documentation available

Reads and loads checksums.yaml.gz from the tar file gem

Prepares the gem for signing and checksum generation. If a signing certificate and key are not present only checksum generation is set up.

The spec for this gem.

If this is a package for a built gem the spec is loaded from the gem and returned. If this is a package for a gem being built the provided spec is returned.

Verifies that this gem:

  • Contains a valid gem specification

  • Contains a contents archive

  • The contents archive is not corrupt

After verification the gem specification from the gem is available from spec

Verifies entry in a .gem file.

Verifies the files of the gem