Verifies entry
in a .gem file.
Verifies the files of the gem
Resolve the requested dependencies against the gems available via Gem.path
and return an Array
of Specification objects to be activated.
Yields each source in the list.
Return the list of all array-oriented instance variables.
Return the list of all instance variables.
Is name
a required attribute?
Required specification attributes
Sanitize a single string.
Returns the full path to this spec’s ri directory.
True if this gem has the same attributes as other
.
Returns an array of CodeLine
objects from the source string
Invoked by IO#write
or IO::Buffer#write
to write length
bytes to io
from from a specified buffer
(see IO::Buffer
) at the given offset
.
The length
argument is the “minimum length to be written”. If the IO
buffer size is 8KiB, but the length
specified is 1024 (1KiB), at most 8KiB will be written, but at least 1KiB will be. Generally, the only case where less data than length
will be written is if there is an error writing the data.
Specifying a length
of 0 is valid and means try writing at least once, as much data as possible.
Suggested implementation should try to write to io
in a non-blocking manner and call io_wait
if the io
is not ready (which will yield control to other fibers).
See IO::Buffer
for an interface available to get data from buffer efficiently.
Expected to return number of bytes written, or, in case of an error, -errno
(negated number corresponding to system’s error code).
The method should be considered experimental.
Invoked by IO#pwrite
or IO::Buffer#pwrite
to write length
bytes to io
at offset from
into a specified buffer
(see IO::Buffer
) at the given offset
.
This method is semantically the same as io_write
, but it allows to specify the offset to write to and is often better for asynchronous IO
on the same file.
The method should be considered experimental.
Returns the source encoding as an encoding object.
Note that the result may not be equal to the source encoding of the encoding converter if the conversion has multiple steps.
ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP begin ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP. rescue Encoding::UndefinedConversionError p $!.source_encoding #=> #<Encoding:UTF-8> p $!.destination_encoding #=> #<Encoding:EUC-JP> p $!.source_encoding_name #=> "UTF-8" p $!.destination_encoding_name #=> "EUC-JP" end
Returns the source encoding as an encoding object.
Note that the result may not be equal to the source encoding of the encoding converter if the conversion has multiple steps.
ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP begin ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP. rescue Encoding::UndefinedConversionError p $!.source_encoding #=> #<Encoding:UTF-8> p $!.destination_encoding #=> #<Encoding:EUC-JP> p $!.source_encoding_name #=> "UTF-8" p $!.destination_encoding_name #=> "EUC-JP" end
Returns the source encoding as an Encoding
object.
possible opt elements:
hash form: :partial_input => true # source buffer may be part of larger source :after_output => true # stop conversion after output before input integer form: Encoding::Converter::PARTIAL_INPUT Encoding::Converter::AFTER_OUTPUT
possible results:
:invalid_byte_sequence :incomplete_input :undefined_conversion :after_output :destination_buffer_full :source_buffer_empty :finished
primitive_convert
converts source_buffer into destination_buffer.
source_buffer should be a string or nil. nil means an empty string.
destination_buffer should be a string.
destination_byteoffset should be an integer or nil. nil means the end of destination_buffer. If it is omitted, nil is assumed.
destination_bytesize should be an integer or nil. nil means unlimited. If it is omitted, nil is assumed.
opt should be nil, a hash or an integer. nil means no flags. If it is omitted, nil is assumed.
primitive_convert
converts the content of source_buffer from beginning and store the result into destination_buffer.
destination_byteoffset and destination_bytesize specify the region which the converted result is stored. destination_byteoffset specifies the start position in destination_buffer in bytes. If destination_byteoffset is nil, destination_buffer.bytesize is used for appending the result. destination_bytesize specifies maximum number of bytes. If destination_bytesize is nil, destination size is unlimited. After conversion, destination_buffer is resized to destination_byteoffset + actually produced number of bytes. Also destination_buffer’s encoding is set to destination_encoding.
primitive_convert
drops the converted part of source_buffer. the dropped part is converted in destination_buffer or buffered in Encoding::Converter
object.
primitive_convert
stops conversion when one of following condition met.
invalid byte sequence found in source buffer (:invalid_byte_sequence) primitive_errinfo
and last_error
methods returns the detail of the error.
unexpected end of source buffer (:incomplete_input) this occur only when :partial_input is not specified. primitive_errinfo
and last_error
methods returns the detail of the error.
character not representable in output encoding (:undefined_conversion) primitive_errinfo
and last_error
methods returns the detail of the error.
after some output is generated, before input is done (:after_output) this occur only when :after_output is specified.
destination buffer is full (:destination_buffer_full) this occur only when destination_bytesize is non-nil.
source buffer is empty (:source_buffer_empty) this occur only when :partial_input is specified.
conversion is finished (:finished)
example:
ec = Encoding::Converter.new("UTF-8", "UTF-16BE") ret = ec.primitive_convert(src="pi", dst="", nil, 100) p [ret, src, dst] #=> [:finished, "", "\x00p\x00i"] ec = Encoding::Converter.new("UTF-8", "UTF-16BE") ret = ec.primitive_convert(src="pi", dst="", nil, 1) p [ret, src, dst] #=> [:destination_buffer_full, "i", "\x00"] ret = ec.primitive_convert(src, dst="", nil, 1) p [ret, src, dst] #=> [:destination_buffer_full, "", "p"] ret = ec.primitive_convert(src, dst="", nil, 1) p [ret, src, dst] #=> [:destination_buffer_full, "", "\x00"] ret = ec.primitive_convert(src, dst="", nil, 1) p [ret, src, dst] #=> [:finished, "", "i"]
Parses a C prototype signature
If Hash
tymap
is provided, the return value and the arguments from the signature
are expected to be keys, and the value will be the C type to be looked up.
Example:
require 'fiddle/import' include Fiddle::CParser #=> Object parse_signature('double sum(double, double)') #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]] parse_signature('void update(void (*cb)(int code))') #=> ["update", Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP]] parse_signature('char (*getbuffer(void))[80]') #=> ["getbuffer", Fiddle::TYPE_VOIDP, []]
Writes s to the buffer. When the buffer is full or sync
is true the buffer is flushed to the underlying socket.
Writes s in the non-blocking manner.
If there is buffered data, it is flushed first. This may block.
write_nonblock
returns number of bytes written to the SSL
connection.
When no data can be written without blocking it raises OpenSSL::SSL::SSLError
extended by IO::WaitReadable
or IO::WaitWritable
.
IO::WaitReadable
means SSL
needs to read internally so write_nonblock
should be called again after the underlying IO
is readable.
IO::WaitWritable
means SSL
needs to write internally so write_nonblock
should be called again after underlying IO
is writable.
So OpenSSL::Buffering#write_nonblock
needs two rescue clause as follows.
# emulates blocking write. begin result = ssl.write_nonblock(str) rescue IO::WaitReadable IO.select([io]) retry rescue IO::WaitWritable IO.select(nil, [io]) retry end
Note that one reason that write_nonblock
reads from the underlying IO
is when the peer requests a new TLS/SSL handshake. See the openssl FAQ for more details. www.openssl.org/support/faq.html
By specifying a keyword argument exception to false
, you can indicate that write_nonblock
should not raise an IO::Wait*able exception, but return the symbol :wait_writable
or :wait_readable
instead.