Sets the date-time format.
Argument datetime_format
should be either of these:
A string suitable for use as a format for method Time#strftime
.
nil
: the logger uses '%Y-%m-%dT%H:%M:%S.%6N'
.
Returns the date-time format; see datetime_format=
.
Ruby tries to load the library named string relative to the directory containing the requiring file. If the file does not exist a LoadError
is raised. Returns true
if the file was loaded and false
if the file was already loaded before.
Leaves exclusive section.
Enters exclusive section and executes the block. Leaves the exclusive section automatically when the block exits. See example under MonitorMixin
.
Constant time memory comparison. Inputs are hashed using SHA-256 to mask the length of the secret. Returns true
if the strings are identical, false
otherwise.
Parse a file at filename
. Returns the Psych::Nodes::Document
.
Raises a Psych::SyntaxError
when a YAML
syntax error is detected.
Parse a YAML
string in yaml
. Returns the Psych::Nodes::Stream
. This method can handle multiple YAML
documents contained in yaml
. filename
is used in the exception message if a Psych::SyntaxError
is raised.
If a block is given, a Psych::Nodes::Document
node will be yielded to the block as it’s being parsed.
Raises a Psych::SyntaxError
when a YAML
syntax error is detected.
Example:
Psych.parse_stream("---\n - a\n - b") # => #<Psych::Nodes::Stream:0x00> Psych.parse_stream("--- a\n--- b") do |node| node # => #<Psych::Nodes::Document:0x00> end begin Psych.parse_stream("--- `", filename: "file.txt") rescue Psych::SyntaxError => ex ex.file # => 'file.txt' ex.message # => "(file.txt): found character that cannot start any token" end
Raises a TypeError
when NilClass
is passed.
See Psych::Nodes
for more information about YAML
AST.
Returns the version of libyaml being used
Returns the string which represents the version of zlib library.
Return measured GC total time in nano seconds.
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
.
Returns true
if the contents of files a
and b
are identical, false
otherwise.
Arguments a
and b
should be interpretable as a path.
FileUtils.identical?
and FileUtils.cmp
are aliases for FileUtils.compare_file
.
Related: FileUtils.compare_stream
.
Returns true
if the contents of files a
and b
are identical, false
otherwise.
Arguments a
and b
should be interpretable as a path.
FileUtils.identical?
and FileUtils.cmp
are aliases for FileUtils.compare_file
.
Related: FileUtils.compare_stream
.
Returns true
if the contents of streams a
and b
are identical, false
otherwise.
Arguments a
and b
should be interpretable as a path.
Related: FileUtils.compare_file
.
Returns true
if the contents of streams a
and b
are identical, false
otherwise.
Arguments a
and b
should be interpretable as a path.
Related: FileUtils.compare_file
.
Tests for the presence of a --with-
config or --without-
config option. Returns true
if the with option is given, false
if the without option is given, and the default value otherwise.
This can be useful for adding custom definitions, such as debug information.
Example:
if with_config("debug") $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG" end
Notify observers of a change in state if this object’s changed state is true
.
This will invoke the method named in add_observer
, passing *arg
. The changed state is then set to false
.
*arg
Any arguments to pass to the observers.
Open3.pipeline_start
starts a list of commands as a pipeline. No pipes are created for stdin of the first command and stdout of the last command.
Open3.pipeline_start(cmd1, cmd2, ... [, opts]) {|wait_threads| ... } wait_threads = Open3.pipeline_start(cmd1, cmd2, ... [, opts]) ...
Each cmd is a string or an array. If it is an array, the elements are passed to Process.spawn
.
cmd: commandline command line string which is passed to a shell [env, commandline, opts] command line string which is passed to a shell [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell) [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell) Note that env and opts are optional, as for Process.spawn.
Example:
# Run xeyes in 10 seconds. Open3.pipeline_start("xeyes") {|ts| sleep 10 t = ts[0] Process.kill("TERM", t.pid) p t.value #=> #<Process::Status: pid 911 SIGTERM (signal 15)> } # Convert pdf to ps and send it to a printer. # Collect error message of pdftops and lpr. pdf_file = "paper.pdf" printer = "printer-name" err_r, err_w = IO.pipe Open3.pipeline_start(["pdftops", pdf_file, "-"], ["lpr", "-P#{printer}"], :err=>err_w) {|ts| err_w.close p err_r.read # error messages of pdftops and lpr. }
Open3.pipeline_start
starts a list of commands as a pipeline. No pipes are created for stdin of the first command and stdout of the last command.
Open3.pipeline_start(cmd1, cmd2, ... [, opts]) {|wait_threads| ... } wait_threads = Open3.pipeline_start(cmd1, cmd2, ... [, opts]) ...
Each cmd is a string or an array. If it is an array, the elements are passed to Process.spawn
.
cmd: commandline command line string which is passed to a shell [env, commandline, opts] command line string which is passed to a shell [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell) [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell) Note that env and opts are optional, as for Process.spawn.
Example:
# Run xeyes in 10 seconds. Open3.pipeline_start("xeyes") {|ts| sleep 10 t = ts[0] Process.kill("TERM", t.pid) p t.value #=> #<Process::Status: pid 911 SIGTERM (signal 15)> } # Convert pdf to ps and send it to a printer. # Collect error message of pdftops and lpr. pdf_file = "paper.pdf" printer = "printer-name" err_r, err_w = IO.pipe Open3.pipeline_start(["pdftops", pdf_file, "-"], ["lpr", "-P#{printer}"], :err=>err_w) {|ts| err_w.close p err_r.read # error messages of pdftops and lpr. }
Try to activate a gem containing path
. Returns true if activation succeeded or wasn’t needed because it was already activated. Returns false if it can’t find the path in a gem.
Reset the dir
and path
values. The next time dir
or path
is requested, the values will be calculated from scratch. This is mainly used by the unit tests to provide test isolation.