YAML event parser class. This class parses a YAML document and calls events on the handler that is passed to the constructor. The events can be used for things such as constructing a YAML AST or deserializing YAML documents. It can even be fed back to Psych::Emitter
to emit the same document that was parsed.
See Psych::Handler
for documentation on the events that Psych::Parser
emits.
Here is an example that prints out ever scalar found in a YAML document:
# Handler for detecting scalar values class ScalarHandler < Psych::Handler def scalar value, anchor, tag, plain, quoted, style puts value end end parser = Psych::Parser.new(ScalarHandler.new) parser.parse(yaml_document)
Here is an example that feeds the parser back in to Psych::Emitter
. The YAML document is read from STDIN and written back out to STDERR:
parser = Psych::Parser.new(Psych::Emitter.new($stderr)) parser.parse($stdin)
Psych
uses Psych::Parser
in combination with Psych::TreeBuilder
to construct an AST of the parsed YAML document.
Psych::Stream
is a streaming YAML emitter. It will not buffer your YAML, but send it straight to an IO
.
Here is an example use:
stream = Psych::Stream.new($stdout) stream.start stream.push({:foo => 'bar'}) stream.finish
YAML will be immediately emitted to $stdout with no buffering.
Psych::Stream#start
will take a block and ensure that Psych::Stream#finish
is called, so you can do this form:
stream = Psych::Stream.new($stdout) stream.start do |em| em.push(:foo => 'bar') end
Socket::AncillaryData
represents the ancillary data (control information) used by sendmsg and recvmsg system call. It contains socket family
, control message (cmsg) level
, cmsg type
and cmsg data
.
Subclass of Zlib::Error
when zlib returns a Z_DATA_ERROR.
Usually if a stream was prematurely freed.
Zlib::ZStream
is the abstract class for the stream which handles the compressed data. The operations are defined in the subclasses: Zlib::Deflate
for compression, and Zlib::Inflate
for decompression.
An instance of Zlib::ZStream
has one stream (struct zstream in the source) and two variable-length buffers which associated to the input (next_in) of the stream and the output (next_out) of the stream. In this document, “input buffer” means the buffer for input, and “output buffer” means the buffer for output.
Data
input into an instance of Zlib::ZStream
are temporally stored into the end of input buffer, and then data in input buffer are processed from the beginning of the buffer until no more output from the stream is produced (i.e. until avail_out
> 0 after processing). During processing, output buffer is allocated and expanded automatically to hold all output data.
Some particular instance methods consume the data in output buffer and return them as a String
.
Here is an ascii art for describing above:
+================ an instance of Zlib::ZStream ================+ || || || +--------+ +-------+ +--------+ || || +--| output |<---------|zstream|<---------| input |<--+ || || | | buffer | next_out+-------+next_in | buffer | | || || | +--------+ +--------+ | || || | | || +===|======================================================|===+ | | v | "output data" "input data"
If an error occurs during processing input buffer, an exception which is a subclass of Zlib::Error
is raised. At that time, both input and output buffer keep their conditions at the time when the error occurs.
Method
Catalogue Many of the methods in this class are fairly low-level and unlikely to be of interest to users. In fact, users are unlikely to use this class directly; rather they will be interested in Zlib::Inflate
and Zlib::Deflate
.
The higher level methods are listed below.
Zlib::Deflate
is the class for compressing data. See Zlib::ZStream
for more information.
Zlib:Inflate is the class for decompressing compressed data. Unlike Zlib::Deflate
, an instance of this class is not able to duplicate (clone, dup) itself.
Objects of class File::Stat
encapsulate common status information for File
objects. The information is recorded at the moment the File::Stat
object is created; changes made to the file after that point will not be reflected. File::Stat
objects are returned by IO#stat
, File::stat
, File#lstat
, and File::lstat
. Many of these methods return platform-specific values, and not all values are meaningful on all systems. See also Kernel#test
.
The Specification
class contains the information for a Gem. Typically defined in a .gemspec file or a Rakefile, and looks like this:
Gem::Specification.new do |s| s.name = 'example' s.version = '0.1.0' s.licenses = ['MIT'] s.summary = "This is an example!" s.description = "Much longer explanation of the example!" s.authors = ["Ruby Coder"] s.email = 'rubycoder@example.com' s.files = ["lib/example.rb"] s.homepage = 'https://rubygems.org/gems/example' s.metadata = { "source_code_uri" => "https://github.com/example/example" } end
Starting in RubyGems 2.0, a Specification
can hold arbitrary metadata. See metadata
for restrictions on the format and size of metadata items you may add to a specification.
A Requirement
is a set of one or more version restrictions. It supports a few (=, !=, >, <, >=, <=, ~>
) different restriction operators.
See Gem::Version
for a description on how versions and requirements work together in RubyGems.
Available list of platforms for targeting Gem installations.
See ‘gem help platform` for information on platform matching.
The error thrown when the parser encounters illegal CSV
formatting.
Error raised by a dRuby protocol when it doesn’t support the scheme specified in a URI
. See DRb::DRbProtocol
.
Handler for sending and receiving drb messages.
This takes care of the low-level marshalling and unmarshalling of drb requests and responses sent over the wire between server and client. This relieves the implementor of a new drb protocol layer with having to deal with these details.
The user does not have to directly deal with this object in normal use.
Timer id conversion keeps objects alive for a certain amount of time after their last access. The default time period is 600 seconds and can be changed upon initialization.
To use TimerIdConv:
DRb.install_id_conv TimerIdConv.new 60 # one minute
Raised when the address family is invalid such as an address with an unsupported family, an address with an inconsistent family, or an address who’s family cannot be determined.
Default formatter for log messages.