Results for: "tally"

Module File::Constants defines file-related constants.

There are two families of constants here:

File constants defined for the local process may be retrieved with method File::Constants.constants:

File::Constants.constants.take(5)
# => [:RDONLY, :WRONLY, :RDWR, :APPEND, :CREAT]

File Access

File-access constants may be used with optional argument mode in calls to the following methods:

Read/Write Access

Read-write access for a stream may be specified by a file-access constant.

The constant may be specified as part of a bitwise OR of other such constants.

Any combination of the constants in this section may be specified.

File::RDONLY

Flag File::RDONLY specifies the the stream should be opened for reading only:

filepath = '/tmp/t.tmp'
f = File.new(filepath, File::RDONLY)
f.write('Foo') # Raises IOError (not opened for writing).

File::WRONLY

Flag File::WRONLY specifies that the stream should be opened for writing only:

f = File.new(filepath, File::WRONLY)
f.read # Raises IOError (not opened for reading).

File::RDWR

Flag File::RDWR specifies that the stream should be opened for both reading and writing:

f = File.new(filepath, File::RDWR)
f.write('Foo') # => 3
f.rewind       # => 0
f.read         # => "Foo"

File Positioning

File::APPEND

Flag File::APPEND specifies that the stream should be opened in append mode.

Before each write operation, the position is set to end-of-stream. The modification of the position and the following write operation are performed as a single atomic step.

File::TRUNC

Flag File::TRUNC specifies that the stream should be truncated at its beginning. If the file exists and is successfully opened for writing, it is to be truncated to position zero; its ctime and mtime are updated.

There is no effect on a FIFO special file or a terminal device. The effect on other file types is implementation-defined. The result of using File::TRUNC with File::RDONLY is undefined.

Creating and Preserving

File::CREAT

Flag File::CREAT specifies that the stream should be created if it does not already exist.

If the file exists:

- Raise an exception if File::EXCL is also specified.
- Otherwise, do nothing.

If the file does not exist, then it is created. Upon successful completion, the atime, ctime, and mtime of the file are updated, and the ctime and mtime of the parent directory are updated.

File::EXCL

Flag File::EXCL specifies that the stream should not already exist; If flags File::CREAT and File::EXCL are both specified and the stream already exists, an exception is raised.

The check for the existence and creation of the file is performed as an atomic operation.

If both File::EXCL and File::CREAT are specified and the path names a symbolic link, an exception is raised regardless of the contents of the symbolic link.

If File::EXCL is specified and File::CREAT is not specified, the result is undefined.

POSIX File Constants

Some file-access constants are defined only on POSIX-compliant systems; those are:

File::SYNC, File::RSYNC, and File::DSYNC

Flag File::SYNC, File::RSYNC, or File::DSYNC specifies synchronization of I/O operations with the underlying file system.

These flags are valid only for POSIX-compliant systems.

Note that the behavior of these flags may vary slightly depending on the operating system and filesystem being used. Additionally, using these flags can have an impact on performance due to the synchronous nature of the I/O operations, so they should be used judiciously, especially in performance-critical applications.

File::NOCTTY

Flag File::NOCTTY specifies that if the stream is a terminal device, that device does not become the controlling terminal for the process.

Defined only for POSIX-compliant systems.

File::DIRECT

Flag File::DIRECT requests that cache effects of the I/O to and from the stream be minimized.

Defined only for POSIX-compliant systems.

File::NOATIME

Flag File::NOATIME specifies that act of opening the stream should not modify its access time (atime).

Defined only for POSIX-compliant systems.

File::NOFOLLOW

Flag File::NOFOLLOW specifies that if path is a symbolic link, it should not be followed.

Defined only for POSIX-compliant systems.

File::TMPFILE

Flag File::TMPFILE specifies that the opened stream should be a new temporary file.

Defined only for POSIX-compliant systems.

Other File-Access Constants

File::NONBLOCK

When possible, the file is opened in nonblocking mode. Neither the open operation nor any subsequent I/O operations on the file will cause the calling process to wait.

File::BINARY

Flag File::BINARY specifies that the stream is to be accessed in binary mode.

File::SHARE_DELETE (Windows Only)

Flag File::SHARE_DELETE enables other processes to open the stream with delete access.

If the stream is opened for (local) delete access without File::SHARE_DELETE, and another process attempts to open it with delete access, the attempt fails and the stream is not opened for that process.

Locking

Four file constants relate to stream locking; see File#flock:

File::LOCK_EX

Flag File::LOCK_EX specifies an exclusive lock; only one process a a time may lock the stream.

File::LOCK_NB

Flag File::LOCK_NB specifies non-blocking locking for the stream; may be combined with File::LOCK_EX or File::LOCK_SH.

File::LOCK_SH

Flag File::LOCK_SH specifies that multiple processes may lock the stream at the same time.

File::LOCK_UN

Flag File::LOCK_UN specifies that the stream is not to be locked.

Filename Globbing Constants (File::FNM_*)

Filename-globbing constants may be used with optional argument flags in calls to the following methods:

The constants are:

File::FNM_CASEFOLD

Flag File::FNM_CASEFOLD makes patterns case insensitive for File.fnmatch (but not Dir.glob).

File::FNM_DOTMATCH

Flag File::FNM_DOTMATCH makes the '*' pattern match a filename starting with '.'.

File::FNM_EXTGLOB

Flag File::FNM_EXTGLOB enables pattern '{a,b}', which matches pattern ‘a’ and pattern ‘b’; behaves like a regexp union (e.g., '(?:a|b)'):

pattern = '{LEGAL,BSDL}'
Dir.glob(pattern)      # => ["LEGAL", "BSDL"]
Pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]
pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]

File::FNM_NOESCAPE

Flag File::FNM_NOESCAPE disables '\' escaping.

File::FNM_PATHNAME

Flag File::FNM_PATHNAME specifies that patterns '*' and '?' do not match the directory separator (the value of constant File::SEPARATOR).

File::FNM_SHORTNAME (Windows Only)

Flag File::FNM_SHORTNAME Allows patterns to match short names if they exist.

File::FNM_SYSCASE

Flag File::FNM_SYSCASE specifies that case sensitivity is the same as in the underlying operating system; effective for File.fnmatch, but not Dir.glob.

Other Constants

File::NULL

Flag File::NULL contains the string value of the null device:

This module provides instance methods for a digest implementation object to calculate message digest values.

No documentation available

exception to wait for writing. see IO.select.

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.

Create a Response:

#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)

Verify a timestamp response:

#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

Socket::Constants provides socket-related constants. All possible socket constants are listed in the documentation but they may not all be present on your platform.

If the underlying platform doesn’t define a constant the corresponding Ruby constant is not defined.

No documentation available
No documentation available

Mixin for holding meta-information.

Acceptable argument classes. Now contains DecimalInteger, OctalInteger and DecimalNumeric. See Acceptable argument classes (in source code).

A module responsible for deserializing parse results.

Mixin methods for local and remote Gem::Command options.

This module is used for safely loading Marshal specs from a gem. The ‘safe_load` method defined on this module is specifically designed for loading Gem specifications.

A stub yaml serializer that can handle only hashes and strings (as of now).

No documentation available
No documentation available

The top-level class representing any ASN.1 object. When parsed by ASN1.decode, tagged values are always represented by an instance of ASN1Data.

The role of ASN1Data for parsing tagged values

When encoding an ASN.1 type it is inherently clear what original type (e.g. INTEGER, OCTET STRING etc.) this value has, regardless of its tagging. But opposed to the time an ASN.1 type is to be encoded, when parsing them it is not possible to deduce the “real type” of tagged values. This is why tagged values are generally parsed into ASN1Data instances, but with a different outcome for implicit and explicit tagging.

Example of a parsed implicitly tagged value

An implicitly 1-tagged INTEGER value will be parsed as an ASN1Data with

This implies that a subsequent decoding step is required to completely decode implicitly tagged values.

Example of a parsed explicitly tagged value

An explicitly 1-tagged INTEGER value will be parsed as an ASN1Data with

Example - Decoding an implicitly tagged INTEGER

int = OpenSSL::ASN1::Integer.new(1, 0, :IMPLICIT) # implicit 0-tagged
seq = OpenSSL::ASN1::Sequence.new( [int] )
der = seq.to_der
asn1 = OpenSSL::ASN1.decode(der)
# pp asn1 => #<OpenSSL::ASN1::Sequence:0x87326e0
#              @indefinite_length=false,
#              @tag=16,
#              @tag_class=:UNIVERSAL,
#              @tagging=nil,
#              @value=
#                [#<OpenSSL::ASN1::ASN1Data:0x87326f4
#                   @indefinite_length=false,
#                   @tag=0,
#                   @tag_class=:CONTEXT_SPECIFIC,
#                   @value="\x01">]>
raw_int = asn1.value[0]
# manually rewrite tag and tag class to make it an UNIVERSAL value
raw_int.tag = OpenSSL::ASN1::INTEGER
raw_int.tag_class = :UNIVERSAL
int2 = OpenSSL::ASN1.decode(raw_int)
puts int2.value # => 1

Example - Decoding an explicitly tagged INTEGER

int = OpenSSL::ASN1::Integer.new(1, 0, :EXPLICIT) # explicit 0-tagged
seq = OpenSSL::ASN1::Sequence.new( [int] )
der = seq.to_der
asn1 = OpenSSL::ASN1.decode(der)
# pp asn1 => #<OpenSSL::ASN1::Sequence:0x87326e0
#              @indefinite_length=false,
#              @tag=16,
#              @tag_class=:UNIVERSAL,
#              @tagging=nil,
#              @value=
#                [#<OpenSSL::ASN1::ASN1Data:0x87326f4
#                   @indefinite_length=false,
#                   @tag=0,
#                   @tag_class=:CONTEXT_SPECIFIC,
#                   @value=
#                     [#<OpenSSL::ASN1::Integer:0x85bf308
#                        @indefinite_length=false,
#                        @tag=2,
#                        @tag_class=:UNIVERSAL
#                        @tagging=nil,
#                        @value=1>]>]>
int2 = asn1.value[0].value[0]
puts int2.value # => 1
No documentation available

Generic exception class of the Timestamp module.

This class represents a YAML Alias. It points to an anchor.

A Psych::Nodes::Alias is a terminal node and may have no children.

This class represents a YAML Scalar.

This node type is a terminal node and should not have any children.

No documentation available
No documentation available

TimeStamp struct

Raised if you try to access a buffer slice which no longer references a valid memory range of the underlying source.

Search took: 7ms  ·  Total Results: 1651