Basically a wrapper for Process.spawn
that:
Creates a child process for each of the given cmds
by calling Process.spawn
.
Does not wait for child processes to exit.
With no block given, returns an array of the wait threads for all of the child processes.
Example:
wait_threads = Open3.pipeline_start('ls', 'grep R') # => [#<Process::Waiter:0x000055e8de9d2bb0 run>, #<Process::Waiter:0x000055e8de9d2890 run>] wait_threads.each do |wait_thread| wait_thread.join end
Output:
Rakefile README.md
With a block given, calls the block with an array of the wait processes:
Open3.pipeline_start('ls', 'grep R') do |wait_threads| wait_threads.each do |wait_thread| wait_thread.join end end
Output:
Rakefile README.md
Like Process.spawn
, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.
If the first argument is a hash, it becomes leading argument env
in each call to Process.spawn
; see Execution Environment.
If the last argument is a hash, it becomes trailing argument options
in each call to Process.spawn
; see Execution Options.
Each remaining argument in cmds
is one of:
A command_line
: a string that begins with a shell reserved word or special built-in, or contains one or more metacharacters.
An exe_path
: the string path to an executable to be called.
An array containing a command_line
or an exe_path
, along with zero or more string arguments for the command.
Returns true if the source parses with errors.
SyntaxSuggest.handle_error
[Public]
Takes a ‘SyntaxError` exception, uses the error message to locate the file. Then the file will be analyzed to find the location of the syntax error and emit that location to stderr.
Example:
begin require 'bad_file' rescue => e SyntaxSuggest.handle_error(e) end
By default it will re-raise the exception unless ‘re_raise: false`. The message output location can be configured using the `io: $stderr` input.
If a valid filename cannot be determined, the original exception will be re-raised (even with ‘re_raise: false`).
The iterator version of the tsort
method. obj.tsort_each
is similar to obj.tsort.each
, but modification of obj during the iteration may lead to unexpected results.
tsort_each
returns nil
. If there is a cycle, TSort::Cyclic
is raised.
class G include TSort def initialize(g) @g = g end def tsort_each_child(n, &b) @g[n].each(&b) end def tsort_each_node(&b) @g.each_key(&b) end end graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) graph.tsort_each {|n| p n } #=> 4 # 2 # 3 # 1
The iterator version of the TSort.tsort
method.
The graph is represented by each_node and each_child. each_node should have call
method which yields for each node in the graph. each_child should have call
method which takes a node argument and yields for each child node.
g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} each_node = lambda {|&b| g.each_key(&b) } each_child = lambda {|n, &b| g[n].each(&b) } TSort.tsort_each(each_node, each_child) {|n| p n } #=> 4 # 2 # 3 # 1
Returns a clock resolution as determined by POSIX function clock_getres():
Process.clock_getres(:CLOCK_REALTIME) # => 1.0e-09
See Process.clock_gettime
for the values of clock_id
and unit
.
Examples:
Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_microsecond) # => 0.001 Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_millisecond) # => 1.0e-06 Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :float_second) # => 1.0e-09 Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :microsecond) # => 0 Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :millisecond) # => 0 Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :nanosecond) # => 1 Process.clock_getres(:CLOCK_PROCESS_CPUTIME_ID, :second) # => 0
In addition to the values for unit
supported in Process.clock_gettime
, this method supports :hertz
, the integer number of clock ticks per second (which is the reciprocal of :float_second
):
Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) # => 100.0 Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :float_second) # => 0.01
Accuracy: Note that the returned resolution may be inaccurate on some platforms due to underlying bugs. Inaccurate resolutions have been reported for various clocks including :CLOCK_MONOTONIC
and :CLOCK_MONOTONIC_RAW
on Linux, macOS, BSD or AIX platforms, when using ARM processors, or when using virtualization.
Returns the octet string representation of the elliptic curve point.
conversion_form specifies how the point is converted. Possible values are:
:compressed
:uncompressed
:hybrid
Returns tokens corresponding to the location of the node. Returns nil
if keep_tokens
is not enabled when parse method is called.
root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2", keep_tokens: true) root.tokens # => [[0, :tIDENTIFIER, "x", [1, 0, 1, 1]], [1, :tSP, " ", [1, 1, 1, 2]], ...] root.tokens.map{_1[2]}.join # => "x = 1 + 2"
Token is an array of:
id
token type
source code text
location [ first_lineno
, first_column
, last_lineno
, last_column
]
Returns AST nodes under this one. Each kind of node has different children, depending on what kind of node it is.
The returned array may contain other nodes or nil
.
Serializes the DH
parameters to a PEM-encoding.
Note that any existing per-session public/private keys will not get encoded, just the Diffie-Hellman parameters will be encoded.
PEM-encoded parameters will look like:
-----BEGIN DH PARAMETERS----- [...] -----END DH PARAMETERS-----
See also public_to_pem
(X.509 SubjectPublicKeyInfo) and private_to_pem
(PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for serialization with the private or public key components.
Serializes the DH
parameters to a PEM-encoding.
Note that any existing per-session public/private keys will not get encoded, just the Diffie-Hellman parameters will be encoded.
PEM-encoded parameters will look like:
-----BEGIN DH PARAMETERS----- [...] -----END DH PARAMETERS-----
See also public_to_pem
(X.509 SubjectPublicKeyInfo) and private_to_pem
(PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for serialization with the private or public key components.
Serializes a private or public key to a PEM-encoding.
Serializes it into an X.509 SubjectPublicKeyInfo. The parameters cipher and password are ignored.
A PEM-encoded key will look like:
-----BEGIN PUBLIC KEY----- [...] -----END PUBLIC KEY-----
Consider using public_to_pem
instead. This serializes the key into an X.509 SubjectPublicKeyInfo regardless of whether it is a public key or a private key.
Serializes it into a traditional OpenSSL DSAPrivateKey.
A PEM-encoded key will look like:
-----BEGIN DSA PRIVATE KEY----- [...] -----END DSA PRIVATE KEY-----
Serializes it into a traditional OpenSSL DSAPrivateKey and encrypts it in OpenSSL’s traditional PEM encryption format. cipher must be a cipher name understood by OpenSSL::Cipher.new
or an instance of OpenSSL::Cipher
.
An encrypted PEM-encoded key will look like:
-----BEGIN DSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0 [...] -----END DSA PRIVATE KEY-----
Note that this format uses MD5 to derive the encryption key, and hence will not be available on FIPS-compliant systems.
This method is kept for compatibility. This should only be used when the traditional, non-standard OpenSSL format is required.
Consider using public_to_pem
(X.509 SubjectPublicKeyInfo) or private_to_pem
(PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
Serializes a private or public key to a PEM-encoding.
Serializes it into an X.509 SubjectPublicKeyInfo. The parameters cipher and password are ignored.
A PEM-encoded key will look like:
-----BEGIN PUBLIC KEY----- [...] -----END PUBLIC KEY-----
Consider using public_to_pem
instead. This serializes the key into an X.509 SubjectPublicKeyInfo regardless of whether it is a public key or a private key.
Serializes it into a traditional OpenSSL DSAPrivateKey.
A PEM-encoded key will look like:
-----BEGIN DSA PRIVATE KEY----- [...] -----END DSA PRIVATE KEY-----
Serializes it into a traditional OpenSSL DSAPrivateKey and encrypts it in OpenSSL’s traditional PEM encryption format. cipher must be a cipher name understood by OpenSSL::Cipher.new
or an instance of OpenSSL::Cipher
.
An encrypted PEM-encoded key will look like:
-----BEGIN DSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0 [...] -----END DSA PRIVATE KEY-----
Note that this format uses MD5 to derive the encryption key, and hence will not be available on FIPS-compliant systems.
This method is kept for compatibility. This should only be used when the traditional, non-standard OpenSSL format is required.
Consider using public_to_pem
(X.509 SubjectPublicKeyInfo) or private_to_pem
(PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
Serializes a private or public key to a PEM-encoding.
Serializes it into an X.509 SubjectPublicKeyInfo. The parameters cipher and password are ignored.
A PEM-encoded key will look like:
-----BEGIN PUBLIC KEY----- [...] -----END PUBLIC KEY-----
Consider using public_to_pem
instead. This serializes the key into an X.509 SubjectPublicKeyInfo regardless of whether it is a public key or a private key.
Serializes it into a SEC 1/RFC 5915 ECPrivateKey.
A PEM-encoded key will look like:
-----BEGIN EC PRIVATE KEY----- [...] -----END EC PRIVATE KEY-----
Serializes it into a SEC 1/RFC 5915 ECPrivateKey and encrypts it in OpenSSL’s traditional PEM encryption format. cipher must be a cipher name understood by OpenSSL::Cipher.new
or an instance of OpenSSL::Cipher
.
An encrypted PEM-encoded key will look like:
-----BEGIN EC PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0 [...] -----END EC PRIVATE KEY-----
Note that this format uses MD5 to derive the encryption key, and hence will not be available on FIPS-compliant systems.
This method is kept for compatibility. This should only be used when the SEC 1/RFC 5915 ECPrivateKey format is required.
Consider using public_to_pem
(X.509 SubjectPublicKeyInfo) or private_to_pem
(PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
Serializes a private or public key to a PEM-encoding.
Serializes it into an X.509 SubjectPublicKeyInfo. The parameters cipher and password are ignored.
A PEM-encoded key will look like:
-----BEGIN PUBLIC KEY----- [...] -----END PUBLIC KEY-----
Consider using public_to_pem
instead. This serializes the key into an X.509 SubjectPublicKeyInfo regardless of whether the key is a public key or a private key.
Serializes it into a PKCS #1 RSAPrivateKey.
A PEM-encoded key will look like:
-----BEGIN RSA PRIVATE KEY----- [...] -----END RSA PRIVATE KEY-----
Serializes it into a PKCS #1 RSAPrivateKey and encrypts it in OpenSSL’s traditional PEM encryption format. cipher must be a cipher name understood by OpenSSL::Cipher.new
or an instance of OpenSSL::Cipher
.
An encrypted PEM-encoded key will look like:
-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0 [...] -----END RSA PRIVATE KEY-----
Note that this format uses MD5 to derive the encryption key, and hence will not be available on FIPS-compliant systems.
This method is kept for compatibility. This should only be used when the PKCS #1 RSAPrivateKey format is required.
Consider using public_to_pem
(X.509 SubjectPublicKeyInfo) or private_to_pem
(PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
Serializes a private or public key to a PEM-encoding.
Serializes it into an X.509 SubjectPublicKeyInfo. The parameters cipher and password are ignored.
A PEM-encoded key will look like:
-----BEGIN PUBLIC KEY----- [...] -----END PUBLIC KEY-----
Consider using public_to_pem
instead. This serializes the key into an X.509 SubjectPublicKeyInfo regardless of whether the key is a public key or a private key.
Serializes it into a PKCS #1 RSAPrivateKey.
A PEM-encoded key will look like:
-----BEGIN RSA PRIVATE KEY----- [...] -----END RSA PRIVATE KEY-----
Serializes it into a PKCS #1 RSAPrivateKey and encrypts it in OpenSSL’s traditional PEM encryption format. cipher must be a cipher name understood by OpenSSL::Cipher.new
or an instance of OpenSSL::Cipher
.
An encrypted PEM-encoded key will look like:
-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0 [...] -----END RSA PRIVATE KEY-----
Note that this format uses MD5 to derive the encryption key, and hence will not be available on FIPS-compliant systems.
This method is kept for compatibility. This should only be used when the PKCS #1 RSAPrivateKey format is required.
Consider using public_to_pem
(X.509 SubjectPublicKeyInfo) or private_to_pem
(PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
This method is called automatically when a new SSLSocket
is created. However, it is not thread-safe and must be called before creating SSLSocket
objects in a multi-threaded program.
Reads length bytes from the SSL
connection. If a pre-allocated buffer is provided the data will be written into it.
A description of the current connection state. This is for diagnostic purposes only.