Represents a find pattern in pattern matching.
foo in *bar, baz, *qux ^^^^^^^^^^^^^^^ foo in [*bar, baz, *qux] ^^^^^^^^^^^^^^^^^ foo in Foo(*bar, baz, *qux) ^^^^^^^^^^^^^^^^^^^^
Represents a hash pattern in pattern matching.
foo => { a: 1, b: 2 } ^^^^^^^^^^^^^^ foo => { a: 1, b: 2, **c } ^^^^^^^^^^^^^^^^^^^
Represents a regular expression literal that contains interpolation that is being used in the predicate of a conditional to implicitly match against the last line read by an IO
object.
if /foo #{bar} baz/ then end ^^^^^^^^^^^^^^^^
Represents a set of statements contained within some scope.
foo; bar; baz ^^^^^^^^^^^^^
A pattern is an object that wraps a Ruby pattern matching expression. The expression would normally be passed to an ‘in` clause within a `case` expression or a rightward assignment expression. For example, in the following snippet:
case node in ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]] end
the pattern is the ConstantPathNode[...]
expression.
The pattern gets compiled into an object that responds to call by running the compile
method. This method itself will run back through Prism
to parse the expression into a tree, then walk the tree to generate the necessary callable objects. For example, if you wanted to compile the expression above into a callable, you would:
callable = Prism::Pattern.new("ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]]").compile callable.call(node)
The callable object returned by compile
is guaranteed to respond to call with a single argument, which is the node to match against. It also is guaranteed to respond to ===
, which means it itself can be used in a ‘case` expression, as in:
case node when callable end
If the query given to the initializer cannot be compiled into a valid matcher (either because of a syntax error or because it is using syntax we do not yet support) then a Prism::Pattern::CompilationError
will be raised.
Note: This integration is not finished, and therefore still has many inconsistencies with Ripper
. If you’d like to help out, pull requests would be greatly appreciated!
This class is meant to provide a compatibility layer between prism and Ripper
. It functions by parsing the entire tree first and then walking it and executing each of the Ripper
callbacks as it goes.
This class is going to necessarily be slower than the native Ripper
API. It is meant as a stopgap until developers migrate to using prism. It is also meant as a test harness for the prism parser.
To use this class, you treat ‘Prism::RipperCompat` effectively as you would treat the `Ripper` class.
Generated when trying to lookup a gem to indicate that the gem was found, but that it isn’t usable on the current platform.
fetch and install read these and report them to the user to aid in figuring out why a gem couldn’t be installed.
Provides classes and methods to request, create and validate RFC3161-compliant timestamps. Request
may be used to either create requests from scratch or to parse existing requests that again can be used to request timestamps from a timestamp server, e.g. via the net/http. The resulting timestamp response may be parsed using Response
.
Please note that Response
is read-only and immutable. To create a Response
, an instance of Factory
as well as a valid Request
are needed.
#Assumes ts.p12 is a PKCS#12-compatible file with a private key #and a certificate that has an extended key usage of 'timeStamping' p12 = OpenSSL::PKCS12.new(File.binread('ts.p12'), 'pwd') md = OpenSSL::Digest.new('SHA1') hash = md.digest(data) #some binary data to be timestamped req = OpenSSL::Timestamp::Request.new req.algorithm = 'SHA1' req.message_imprint = hash req.policy_id = "1.2.3.4.5" req.nonce = 42 fac = OpenSSL::Timestamp::Factory.new fac.gen_time = Time.now fac.serial_number = 1 timestamp = fac.create_timestamp(p12.key, p12.certificate, req)
#Assume we have a timestamp token in a file called ts.der ts = OpenSSL::Timestamp::Response.new(File.binread('ts.der')) #Assume we have the Request for this token in a file called req.der req = OpenSSL::Timestamp::Request.new(File.binread('req.der')) # Assume the associated root CA certificate is contained in a # DER-encoded file named root.cer root = OpenSSL::X509::Certificate.new(File.binread('root.cer')) # get the necessary intermediate certificates, available in # DER-encoded form in inter1.cer and inter2.cer inter1 = OpenSSL::X509::Certificate.new(File.binread('inter1.cer')) inter2 = OpenSSL::X509::Certificate.new(File.binread('inter2.cer')) ts.verify(req, root, inter1, inter2) -> ts or raises an exception if validation fails
An error class raised when dynamic parts are found while computing a constant path’s full name. For example: Foo::Bar::Baz -> does not raise because all parts of the constant path are simple constants var::Bar::Baz -> raises because the first part of the constant path is a local variable
An X.509 name represents a hostname, email address or other entity associated with a public key.
You can create a Name
by parsing a distinguished name String
or by supplying the distinguished name as an Array
.
name = OpenSSL::X509::Name.parse_rfc2253 'DC=example,CN=nobody' name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']]
A representation of a DNS
name.
Passwd
is a placeholder Struct
for user database on Unix systems.
contains the short login name of the user as a String
.
contains the encrypted password of the user as a String
. an 'x'
is returned if shadow passwords are in use. An '*'
is returned if the user cannot log in using a password.
contains the integer user ID (uid) of the user.
contains the integer group ID (gid) of the user’s primary group.
contains the path to the home directory of the user as a String
.
contains the path to the login shell of the user as a String
.
contains a longer String
description of the user, such as a full name. Some Unix systems provide structured information in the gecos field, but this is system-dependent.
password change time(integer).
quota value(integer).
password age(integer).
user access class(string).
comment(string).
account expiration time(integer).
This exception is raised if a parser error occurs.