Sha256: 8ef24a60ff94fff0b3ca0dd4ce6b50e9cbfe878f03d506eac0feace2137ce49e

Contents?: true

Size: 767 Bytes

Versions: 24

Compression:

Stored size: 767 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
  end

  def with_write_io
    yield io
  end

  def path
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rubygems-update-3.2.22 lib/rubygems/package/io_source.rb
rubygems-update-3.2.21 lib/rubygems/package/io_source.rb
rubygems-update-3.2.20 lib/rubygems/package/io_source.rb
rubygems-update-3.2.19 lib/rubygems/package/io_source.rb
rubygems-update-3.2.18 lib/rubygems/package/io_source.rb
rubygems-update-3.2.17 lib/rubygems/package/io_source.rb
rubygems-update-3.2.16 lib/rubygems/package/io_source.rb
rubygems-update-3.2.15 lib/rubygems/package/io_source.rb
rubygems-update-3.2.14 lib/rubygems/package/io_source.rb
rubygems-update-3.2.13 lib/rubygems/package/io_source.rb
rubygems-update-3.2.12 lib/rubygems/package/io_source.rb
rubygems-update-3.2.11 lib/rubygems/package/io_source.rb
rubygems-update-3.2.10 lib/rubygems/package/io_source.rb
rubygems-update-3.2.9 lib/rubygems/package/io_source.rb
rubygems-update-3.2.8 lib/rubygems/package/io_source.rb
rubygems-update-3.2.7 lib/rubygems/package/io_source.rb
rubygems-update-3.2.6 lib/rubygems/package/io_source.rb
rubygems-update-3.2.5 lib/rubygems/package/io_source.rb
rubygems-update-3.2.4 lib/rubygems/package/io_source.rb
rubygems-update-3.2.3 lib/rubygems/package/io_source.rb