Sha256: 8450ad58efcfc11ad5df0a4b8fa828f1d889b646c10612eca29612f2a408c0c5

Contents?: true

Size: 813 Bytes

Versions: 58

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true
##
# 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`.

class Gem::Package::IOSource < Gem::Package::Source # :nodoc: all
  attr_reader :io

  def initialize(io)
    @io = io
  end

  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

  def present?
    true
  end

  def with_read_io
    yield io
  ensure
    io.rewind
  end

  def with_write_io
    yield io
  ensure
    io.rewind
  end

  def path
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
rubygems-update-3.3.27 lib/rubygems/package/io_source.rb
rubygems-update-3.4.17 lib/rubygems/package/io_source.rb
rubygems-update-3.4.16 lib/rubygems/package/io_source.rb
rubygems-update-3.4.15 lib/rubygems/package/io_source.rb
rubygems-update-3.4.14 lib/rubygems/package/io_source.rb
rubygems-update-3.4.13 lib/rubygems/package/io_source.rb
rubygems-update-3.4.12 lib/rubygems/package/io_source.rb
rubygems-update-3.4.11 lib/rubygems/package/io_source.rb
rubygems-update-3.4.10 lib/rubygems/package/io_source.rb
rubygems-update-3.4.9 lib/rubygems/package/io_source.rb
rubygems-update-3.4.8 lib/rubygems/package/io_source.rb
rubygems-update-3.4.7 lib/rubygems/package/io_source.rb
rubygems-update-3.2.34 lib/rubygems/package/io_source.rb
rubygems-update-3.4.6 lib/rubygems/package/io_source.rb
rubygems-update-3.4.5 lib/rubygems/package/io_source.rb
rubygems-update-3.4.4 lib/rubygems/package/io_source.rb
rubygems-update-3.4.3 lib/rubygems/package/io_source.rb
rubygems-update-3.4.2 lib/rubygems/package/io_source.rb
rubygems-update-3.4.1 lib/rubygems/package/io_source.rb
rubygems-update-3.4.0 lib/rubygems/package/io_source.rb