Results for: "Logger"

No documentation available

This class works in conjunction with Psych::Parser to build an in-memory parse tree that represents a YAML document.

Example

parser = Psych::Parser.new Psych::TreeBuilder.new
parser.parse('--- foo')
tree = parser.handler.root

See Psych::Handler for documentation on the event methods used in this class.

No documentation available

This class handles only scanner events, which are dispatched in the ‘right’ order (same with input).

No documentation available

Socket::ResolutionError is the error class for hostname resolution.

No documentation available
No documentation available
No documentation available

The superclass for all exceptions raised by Ruby/zlib.

The following exceptions are defined as subclasses of Zlib::Error. These exceptions are raised when zlib library functions return with an error status.

Subclass of Zlib::Error when zlib returns a Z_DATA_ERROR.

Usually if a stream was prematurely freed.

Subclass of Zlib::Error

When zlib returns a Z_STREAM_ERROR, usually if the stream state was inconsistent.

Subclass of Zlib::Error

When zlib returns a Z_MEM_ERROR, usually if there was not enough memory.

Subclass of Zlib::Error when zlib returns a Z_BUF_ERROR.

Usually if no progress is possible.

Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should be used with an instance of IO, or IO-like, object.

Following two example generate the same result.

Zlib::GzipWriter.open('hoge.gz') do |gz|
  gz.write 'jugemu jugemu gokou no surikire...'
end

File.open('hoge.gz', 'w') do |f|
  gz = Zlib::GzipWriter.new(f)
  gz.write 'jugemu jugemu gokou no surikire...'
  gz.close
end

To make like gzip(1) does, run following:

orig = 'hoge.txt'
Zlib::GzipWriter.open('hoge.gz') do |gz|
  gz.mtime = File.mtime(orig)
  gz.orig_name = orig
  gz.write IO.binread(orig)
end

NOTE: Due to the limitation of Ruby’s finalizer, you must explicitly close GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter will be not able to write the gzip footer and will generate a broken gzip file.

Zlib::GzipReader is the class for reading a gzipped file. GzipReader should be used as an IO, or -IO-like, object.

Zlib::GzipReader.open('hoge.gz') {|gz|
  print gz.read
}

File.open('hoge.gz') do |f|
  gz = Zlib::GzipReader.new(f)
  print gz.read
  gz.close
end

Method Catalogue

The following methods in Zlib::GzipReader are just like their counterparts in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an error was found in the gzip file.

Be careful of the footer of the gzip file. A gzip file has the checksum of pre-compressed data in its footer. GzipReader checks all uncompressed data against that checksum at the following cases, and if it fails, raises Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or Zlib::GzipFile::LengthError exception.

The rest of the methods are adequately described in their own documentation.

Can be raised by IO operations when IO#timeout= is set.

exception to wait for reading by EWOULDBLOCK. see IO.select.

exception to wait for writing by EWOULDBLOCK. see IO.select.

exception to wait for reading by EINPROGRESS. see IO.select.

exception to wait for writing by EINPROGRESS. see IO.select.

IO::Buffer is a efficient zero-copy buffer for input/output. There are typical use cases:

Interaction with string and file memory is performed by efficient low-level C mechanisms like ‘memcpy`.

The class is meant to be an utility for implementing more high-level mechanisms like Fiber::Scheduler#io_read and Fiber::Scheduler#io_write and parsing binary protocols.

Examples of Usage

Empty buffer:

buffer = IO::Buffer.new(8)  # create empty 8-byte buffer
# =>
# #<IO::Buffer 0x0000555f5d1a5c50+8 INTERNAL>
# ...
buffer
# =>
# <IO::Buffer 0x0000555f5d156ab0+8 INTERNAL>
# 0x00000000  00 00 00 00 00 00 00 00
buffer.set_string('test', 2) # put there bytes of the "test" string, starting from offset 2
# => 4
buffer.get_string  # get the result
# => "\x00\x00test\x00\x00"

Buffer from string:

string = 'data'
IO::Buffer.for(string) do |buffer|
  buffer
  # =>
  # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
  # 0x00000000  64 61 74 61                                     data

  buffer.get_string(2)  # read content starting from offset 2
  # => "ta"
  buffer.set_string('---', 1) # write content, starting from offset 1
  # => 3
  buffer
  # =>
  # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
  # 0x00000000  64 2d 2d 2d                                     d---
  string  # original string changed, too
  # => "d---"
end

Buffer from file:

File.write('test.txt', 'test data')
# => 9
buffer = IO::Buffer.map(File.open('test.txt'))
# =>
# #<IO::Buffer 0x00007f3f0768c000+9 MAPPED IMMUTABLE>
# ...
buffer.get_string(5, 2) # read 2 bytes, starting from offset 5
# => "da"
buffer.set_string('---', 1) # attempt to write
# in `set_string': Buffer is not writable! (IO::Buffer::AccessError)

# To create writable file-mapped buffer
# Open file for read-write, pass size, offset, and flags=0
buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 9, 0, 0)
buffer.set_string('---', 1)
# => 3 -- bytes written
File.read('test.txt')
# => "t--- data"

The class is experimental and the interface is subject to change, this is especially true of file mappings which may be removed entirely in the future.

The DidYouMean::Formatter is the basic, default formatter for the gem. The formatter responds to the message_for method and it returns a human readable string.

The DidYouMean::Formatter is the basic, default formatter for the gem. The formatter responds to the message_for method and it returns a human readable string.

No documentation available
Search took: 3ms  ·  Total Results: 2090