123456789_123456789_123456789_123456789_123456789_

Class: Gem::Package::IOSource

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Source
Instance Chain:
self, Source
Inherits: Gem::Package::Source
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 new.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(io) ⇒ IOSource

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 13

def initialize(io)
  @io = io
end

Instance Attribute Details

#io (readonly)

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 11

attr_reader :io

#present?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 29

def present?
  true
end

Instance Method Details

#path

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 45

def path
end

#start

[ GitHub ]

  
# 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

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 33

def with_read_io
  yield io
ensure
  io.rewind
end

#with_write_io

[ GitHub ]

  
# File 'lib/rubygems/package/io_source.rb', line 39

def with_write_io
  yield io
ensure
  io.rewind
end