Returns whether or not the constant const
is defined. You may optionally pass the type
of const
as [const, type]
, such as:
have_const(%w[PTHREAD_MUTEX_INITIALIZER pthread_mutex_t], "pthread.h")
You may also pass additional headers
to check against in addition to the common header files, and additional flags to opt
which are then passed along to the compiler.
If found, a macro is passed as a preprocessor constant to the compiler using the type name, in uppercase, prepended with HAVE_CONST_
.
For example, if have_const('foo')
returned true, then the HAVE_CONST_FOO
preprocessor macro would be passed to the compiler.
Returns a Hash
of the defined schemes.
Open3.pipeline_rw
starts a list of commands as a pipeline with pipes which connect to stdin of the first command and stdout of the last command.
Open3.pipeline_rw(cmd1, cmd2, ... [, opts]) {|first_stdin, last_stdout, wait_threads| ... } first_stdin, last_stdout, wait_threads = Open3.pipeline_rw(cmd1, cmd2, ... [, opts]) ... first_stdin.close last_stdout.close
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.
The options to pass to Process.spawn
are constructed by merging opts
, the last hash element of the array, and specifications for the pipes between each of the commands.
Example:
Open3.pipeline_rw("tr -dc A-Za-z", "wc -c") {|i, o, ts| i.puts "All persons more than a mile high to leave the court." i.close p o.gets #=> "42\n" } Open3.pipeline_rw("sort", "cat -n") {|stdin, stdout, wait_thrs| stdin.puts "foo" stdin.puts "bar" stdin.puts "baz" stdin.close # send EOF to sort. p stdout.read #=> " 1\tbar\n 2\tbaz\n 3\tfoo\n" }
Open3.pipeline_rw
starts a list of commands as a pipeline with pipes which connect to stdin of the first command and stdout of the last command.
Open3.pipeline_rw(cmd1, cmd2, ... [, opts]) {|first_stdin, last_stdout, wait_threads| ... } first_stdin, last_stdout, wait_threads = Open3.pipeline_rw(cmd1, cmd2, ... [, opts]) ... first_stdin.close last_stdout.close
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.
The options to pass to Process.spawn
are constructed by merging opts
, the last hash element of the array, and specifications for the pipes between each of the commands.
Example:
Open3.pipeline_rw("tr -dc A-Za-z", "wc -c") {|i, o, ts| i.puts "All persons more than a mile high to leave the court." i.close p o.gets #=> "42\n" } Open3.pipeline_rw("sort", "cat -n") {|stdin, stdout, wait_thrs| stdin.puts "foo" stdin.puts "bar" stdin.puts "baz" stdin.close # send EOF to sort. p stdout.read #=> " 1\tbar\n 2\tbaz\n 3\tfoo\n" }
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.
Adds a post-build hook that will be passed an Gem::Installer
instance when Gem::Installer#install
is called. The hook is called after the gem has been extracted and extensions have been built but before the executables or gemspec has been written. If the hook returns false
then the gem’s files will be removed and the install will be aborted.
Adds a post-installs hook that will be passed a Gem::DependencyInstaller
and a list of installed specifications when Gem::DependencyInstaller#install
is complete
Adds a hook that will get run after Gem::Specification.reset
is run.
Adds a pre-install hook that will be passed an Gem::Installer
instance when Gem::Installer#install
is called. If the hook returns false
then the install will be aborted.
Adds a pre-uninstall hook that will be passed an Gem::Uninstaller
instance and the spec that will be uninstalled when Gem::Uninstaller#uninstall
is called
Safely write a file in binary mode on all platforms.
Returns an estimate of the resolution of a clock_id
using the POSIX clock_getres()
function.
Note the reported resolution is often inaccurate on most platforms due to underlying bugs for this function and therefore the reported resolution often differs from the actual resolution of the clock in practice. Inaccurate reported resolutions have been observed for various clocks including CLOCK_MONOTONIC
and CLOCK_MONOTONIC_RAW
when using Linux, macOS, BSD or AIX platforms, when using ARM processors, or when using virtualization.
clock_id
specifies a kind of clock. See the document of Process.clock_gettime
for details. clock_id
can be a symbol as for Process.clock_gettime
.
If the given clock_id
is not supported, Errno::EINVAL is raised.
unit
specifies the type of the return value. Process.clock_getres
accepts unit
as Process.clock_gettime
. The default value, :float_second
, is also the same as Process.clock_gettime
.
Process.clock_getres
also accepts :hertz
as unit
. :hertz
means the reciprocal of :float_second
.
:hertz
can be used to obtain the exact value of the clock ticks per second for the times() function and CLOCKS_PER_SEC for the clock() function.
Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz)
returns the clock ticks per second.
Process.clock_getres(:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz)
returns CLOCKS_PER_SEC.
p Process.clock_getres(Process::CLOCK_MONOTONIC) #=> 1.0e-09
Indicates whether this DH
instance has a private key associated with it or not. The private key may be retrieved with DH#priv_key.
Indicates whether this DSA
instance has a private key associated with it or not. The private key may be retrieved with DSA#private_key.
Verifies whether the signature is valid given the message digest input. It does so by validating sig using the public key of this DSA
instance.
digest is a message digest of the original input data to be signed
sig is a DSA
signature value
dsa = OpenSSL::PKey::DSA.new(2048) doc = "Sign me" digest = OpenSSL::Digest.digest('SHA1', doc) sig = dsa.syssign(digest) puts dsa.sysverify(digest, sig) # => true
Returns whether this EC
instance has a private key. The private key (BN
) can be retrieved with EC#private_key
.
Does this keypair contain a private key?
The list of cipher suites configured for this context.
Sets the list of available cipher suites for this context. Note in a server context some ciphers require the appropriate certificates. For example, an RSA cipher suite can only be chosen when an RSA certificate is available.
Writes string to the SSL
connection.
Sends “close notify” to the peer and tries to shut down the SSL
connection gracefully.