Safely load the yaml string in yaml
. By default, only the following classes are allowed to be deserialized:
Recursive data structures are not allowed by default. Arbitrary classes can be allowed by adding those classes to the permitted_classes
keyword argument. They are additive. For example, to allow Date
deserialization:
Psych.safe_load(yaml, permitted_classes: [Date])
Now the Date
class can be loaded in addition to the classes listed above.
Aliases can be explicitly allowed by changing the aliases
keyword argument. For example:
x = [] x << x yaml = Psych.dump x Psych.safe_load yaml # => raises an exception Psych.safe_load yaml, aliases: true # => loads the aliases
A Psych::DisallowedClass
exception will be raised if the yaml contains a class that isn’t in the permitted_classes
list.
A Psych::BadAlias
exception will be raised if the yaml contains aliases but the aliases
keyword argument is set to false.
filename
will be used in the exception message if any exception is raised while parsing.
When the optional symbolize_names
keyword argument is set to a true value, returns symbols for keys in Hash
objects (default: strings).
Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"} Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
Load multiple documents given in yaml
. Returns the parsed documents as a list. If a block is given, each document will be converted to Ruby and passed to the block during parsing
Example:
Psych.load_stream("--- foo\n...\n--- bar\n...") # => ['foo', 'bar'] list = [] Psych.load_stream("--- foo\n...\n--- bar\n...") do |ruby| list << ruby end list # => ['foo', 'bar']
Load the document contained in filename
. Returns the yaml contained in filename
as a Ruby object, or if the file is empty, it returns the specified fallback
return value, which defaults to false
.
Returns the version of libyaml being used
Returns the full line that is being edited. This is useful from within the complete_proc for determining the context of the completion request.
The length of Readline.line_buffer
and GNU Readline’s rl_end are same.
Raises NotImplementedError
if the using readline library does not support.
Insert text into the line at the current cursor position.
See GNU Readline’s rl_insert_text function.
Raises NotImplementedError
if the using readline library does not support.
Returns the string which represents the version of zlib library.
Combine two Adler-32 check values in to one. alder1
is the first Adler-32 value, adler2
is the second Adler-32 value. len2
is the length of the string used to generate adler2
.
Initiates garbage collection, unless manually disabled.
This method is defined with keyword arguments that default to true:
def GC.start(full_mark: true, immediate_sweep: true); end
Use full_mark: false to perform a minor GC
. Use immediate_sweep: false to defer sweeping (use lazy sweep).
Note: These keyword arguments are implementation and version dependent. They are not guaranteed to be future-compatible, and may be ignored if the underlying implementation does not support them.
Loads YAML, preferring Psych
The version of the Marshal
format for your Ruby.
A Gem::Version
for the currently running Ruby.
Glob pattern for require-able path suffixes.
The home directory for the user.
Find
the ‘rubygems_plugin’ files in the latest installed gems and load them
Looks for a gem dependency file at path
and activates the gems in the file if found. If the file is not found an ArgumentError
is raised.
If path
is not given the RUBYGEMS_GEMDEPS environment variable is used, but if no file is found no exception is raised.
If ‘-’ is given for path
RubyGems searches up from the current working directory for gem dependency files (gem.deps.rb, Gemfile, Isolate) and activates the gems in the first one found.
You can run this automatically when rubygems starts. To enable, set the RUBYGEMS_GEMDEPS
environment variable to either the path of your gem dependencies file or “-” to auto-discover in parent directories.
NOTE: Enabling automatic discovery on multiuser systems can lead to execution of arbitrary code when used from directories outside your control.
Path for gems in the user’s home directory
Start a dRuby server locally.
The new dRuby server will become the primary server, even if another server is currently the primary server.
uri
is the URI
for the server to bind to. If nil, the server will bind to random port on the default local host name and use the default dRuby protocol.
front
is the server’s front object. This may be nil.
config
is the configuration for the new server. This may be nil.
See DRbServer::new
.
Start a dRuby server locally.
The new dRuby server will become the primary server, even if another server is currently the primary server.
uri
is the URI
for the server to bind to. If nil, the server will bind to random port on the default local host name and use the default dRuby protocol.
front
is the server’s front object. This may be nil.
config
is the configuration for the new server. This may be nil.
See DRbServer::new
.
Stop the local dRuby server.
This operates on the primary server. If there is no primary server currently running, it is a noop.
Stop the local dRuby server.
This operates on the primary server. If there is no primary server currently running, it is a noop.
def_e2message
(c, m)
c: exception m: message_form define exception c with message m.
Returns whether or not the given header
file can be found on your system. If found, a macro is passed as a preprocessor constant to the compiler using the header file name, in uppercase, prepended with HAVE_
.
For example, if have_header('foo.h')
returned true, then the HAVE_FOO_H
preprocessor macro would be passed to the compiler.
Instructs mkmf to search for the given header
in any of the paths
provided, and returns whether or not it was found in those paths.
If the header is found then the path it was found on is added to the list of included directories that are sent to the compiler (via the -I
switch).
Returns the convertible integer type of the given type
. You may optionally specify additional headers
to search in for the type
. convertible means actually the same type, or typedef’d from the same type.
If the type
is an integer type and the convertible type is found, the following macros are passed as preprocessor constants to the compiler using the type
name, in uppercase.
TYPEOF_
, followed by the type
name, followed by =X
where “X” is the found convertible type name.
TYP2NUM
and NUM2TYP
, where TYP
is the type
name in uppercase with replacing an _t
suffix with “T”, followed by =X
where “X” is the macro name to convert type
to an Integer
object, and vice versa.
For example, if foobar_t
is defined as unsigned long, then convertible_int("foobar_t")
would return “unsigned long”, and define these macros:
#define TYPEOF_FOOBAR_T unsigned long #define FOOBART2NUM ULONG2NUM #define NUM2FOOBART NUM2ULONG