Class Gem::OldFormat
In: lib/rubygems/old_format.rb
Parent: Object

The format class knows the guts of the RubyGem .gem file format and provides the capability to read gem files

Methods

Attributes

file_entries  [RW] 
gem_path  [RW] 
spec  [RW] 

Public Class methods

Reads the named gem file and returns a Format object, representing the data from the gem file

file_path:[String] Path to the gem file

[Source]

    # File lib/rubygems/old_format.rb, line 37
37:   def self.from_file_by_path(file_path)
38:     unless File.exist?(file_path)
39:       raise Gem::Exception, "Cannot load gem file [#{file_path}]"
40:     end
41: 
42:     File.open(file_path, 'rb') do |file|
43:       from_io(file, file_path)
44:     end
45:   end

Reads a gem from an io stream and returns a Format object, representing the data from the gem file

io:[IO] Stream from which to read the gem

[Source]

    # File lib/rubygems/old_format.rb, line 53
53:   def self.from_io(io, gem_path="(io)")
54:     format = self.new(gem_path)
55:     skip_ruby(io)
56:     format.spec = read_spec(io)
57:     format.file_entries = []
58:     read_files_from_gem(io) do |entry, file_data|
59:       format.file_entries << [entry, file_data]
60:     end
61:     format
62:   end

Constructs an instance of a Format object, representing the gem‘s data structure.

gem:[String] The file name of the gem

[Source]

    # File lib/rubygems/old_format.rb, line 23
23:   def initialize(gem_path)
24:     require 'fileutils'
25:     require 'zlib'
26:     Gem.load_yaml
27: 
28:     @gem_path = gem_path
29:   end

[Validate]