Class: Gem::Package::IOSource
- Defined in:
 - lib/rubygems/package/io_source.rb
 
Overview
Supports reading and writing gems from/to a generic IO object. This is useful for other applications built on top of rubygems, such as rubygems.org.
This is a private class, do not depend on it directly. Instead, pass an IO object to `Gem::Package.new`.
Instance Attribute Summary collapse
- 
  
    
      #io  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
:nodoc: all.
 
Instance Method Summary collapse
- 
  
    
      #initialize(io)  ⇒ IOSource 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of IOSource.
 - #path ⇒ Object
 - #present? ⇒ Boolean
 - #start ⇒ Object
 - #with_read_io ⇒ Object
 - #with_write_io ⇒ Object
 
Constructor Details
#initialize(io) ⇒ IOSource
Returns a new instance of IOSource.
      13 14 15  | 
    
      # File 'lib/rubygems/package/io_source.rb', line 13 def initialize(io) @io = io end  | 
  
Instance Attribute Details
#io ⇒ Object (readonly)
:nodoc: all
      11 12 13  | 
    
      # File 'lib/rubygems/package/io_source.rb', line 11 def io @io end  | 
  
Instance Method Details
#path ⇒ Object
      45 46  | 
    
      # File 'lib/rubygems/package/io_source.rb', line 45 def path end  | 
  
#present? ⇒ Boolean
      29 30 31  | 
    
      # File 'lib/rubygems/package/io_source.rb', line 29 def present? true end  | 
  
#start ⇒ Object
      17 18 19 20 21 22 23 24 25 26 27  | 
    
      # File 'lib/rubygems/package/io_source.rb', line 17 def start @start ||= begin if io.pos > 0 raise Gem::Package::Error, "Cannot read start unless IO is at start" end value = io.read 20 io.rewind value end end  | 
  
#with_read_io ⇒ Object
      33 34 35 36 37  | 
    
      # File 'lib/rubygems/package/io_source.rb', line 33 def with_read_io yield io ensure io.rewind end  | 
  
#with_write_io ⇒ Object
      39 40 41 42 43  | 
    
      # File 'lib/rubygems/package/io_source.rb', line 39 def with_write_io yield io ensure io.rewind end  |