Class: LibGems::OldFormat
- Inherits:
 - 
      Object
      
        
- Object
 - LibGems::OldFormat
 
 
- Defined in:
 - lib/libgems/old_format.rb
 
Overview
The format class knows the guts of the RubyGem .gem file format and provides the capability to read gem files
Instance Attribute Summary collapse
- 
  
    
      #file_entries  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute file_entries.
 - 
  
    
      #gem_path  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute gem_path.
 - 
  
    
      #spec  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute spec.
 
Class Method Summary collapse
- 
  
    
      .from_file_by_path(file_path)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Reads the named gem file and returns a Format object, representing the data from the gem file.
 - 
  
    
      .from_io(io, gem_path = "(io)")  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Reads a gem from an io stream and returns a Format object, representing the data from the gem file.
 
Instance Method Summary collapse
- 
  
    
      #initialize(gem_path)  ⇒ OldFormat 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Constructs an instance of a Format object, representing the gem’s data structure.
 
Constructor Details
#initialize(gem_path) ⇒ OldFormat
Constructs an instance of a Format object, representing the gem’s data structure.
- gem
 - String
 - 
The file name of the gem
 
      23 24 25 26 27 28 29  | 
    
      # File 'lib/libgems/old_format.rb', line 23 def initialize(gem_path) require 'fileutils' require 'zlib' LibGems.load_yaml @gem_path = gem_path end  | 
  
Instance Attribute Details
#file_entries ⇒ Object
Returns the value of attribute file_entries.
      15 16 17  | 
    
      # File 'lib/libgems/old_format.rb', line 15 def file_entries @file_entries end  | 
  
#gem_path ⇒ Object
Returns the value of attribute gem_path.
      15 16 17  | 
    
      # File 'lib/libgems/old_format.rb', line 15 def gem_path @gem_path end  | 
  
#spec ⇒ Object
Returns the value of attribute spec.
      15 16 17  | 
    
      # File 'lib/libgems/old_format.rb', line 15 def spec @spec end  | 
  
Class Method Details
.from_file_by_path(file_path) ⇒ Object
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
 
      37 38 39 40 41 42 43 44 45  | 
    
      # File 'lib/libgems/old_format.rb', line 37 def self.from_file_by_path(file_path) unless File.exist?(file_path) raise LibGems::Exception, "Cannot load gem file [#{file_path}]" end File.open(file_path, 'rb') do |file| from_io(file, file_path) end end  | 
  
.from_io(io, gem_path = "(io)") ⇒ Object
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
 
      53 54 55 56 57 58 59 60 61 62  | 
    
      # File 'lib/libgems/old_format.rb', line 53 def self.from_io(io, gem_path="(io)") format = self.new(gem_path) skip_ruby(io) format.spec = read_spec(io) format.file_entries = [] read_files_from_gem(io) do |entry, file_data| format.file_entries << [entry, file_data] end format end  |