Raised by Gem::WebauthnListener when an error occurs during security device verification.
Raised to indicate that a system exit should occur with the specified exit_code
The installer installs the files contained in the .gem into the Gem.home.
Gem::Installer
does the work of putting files in all the right places on the filesystem including unpacking the gem into its gem dir, installing the gemspec in the specifications dir, storing the cached gem in the cache dir, and installing either wrappers or symlinks for executables.
The installer invokes pre and post install hooks. Hooks can be added either through a rubygems_plugin.rb file in an installed gem or via a rubygems/defaults/#{RUBY_ENGINE}.rb or rubygems/defaults/operating_system.rb file. See Gem.pre_install
and Gem.post_install
for details.
A RequestSet
groups a request to activate a set of dependencies.
nokogiri = Gem::Dependency.new 'nokogiri', '~> 1.6' pg = Gem::Dependency.new 'pg', '~> 0.14' set = Gem::RequestSet.new nokogiri, pg requests = set.resolve p requests.map { |r| r.full_name } #=> ["nokogiri-1.6.0", "mini_portile-0.5.1", "pg-0.17.0"]
S3URISigner
implements AWS SigV4 for S3 Source to avoid a dependency on the aws-sdk-* gems More on AWS SigV4: docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
The SourceList
represents the sources rubygems has been configured to use. A source may be created from an array of sources:
Gem::SourceList.from %w[https://rubygems.example https://internal.example]
Or by adding them:
sources = Gem::SourceList.new sources << 'https://rubygems.example'
The most common way to get a SourceList
is Gem.sources
.
Gem::StubSpecification
reads the stub: line from the gemspec. This prevents us having to eval the entire gemspec in order to find out certain information.
A TargetConfig is a wrapper around an RbConfig object that provides a consistent interface for querying configuration for *deployment target platform*, where the gem being installed is intended to run on.
The TargetConfig is typically created from the RbConfig of the running Ruby process, but can also be created from an RbConfig file on disk for cross- compiling gems.
An Uninstaller
.
The uninstaller fires pre and post uninstall hooks. Hooks can be added either through a rubygems_plugin.rb file in an installed gem or via a rubygems/defaults/#{RUBY_ENGINE}.rb or rubygems/defaults/operating_system.rb file. See Gem.pre_uninstall
and Gem.post_uninstall
for details.
The UriFormatter
handles URIs from user-input and escaping.
uf = Gem::UriFormatter.new 'example.com' p uf.normalize #=> 'http://example.com'
Scans up/down from the given block
You can try out a change, stash it, or commit it to save for later
Example:
scanner = ScanHistory.new(code_lines: code_lines, block: block) scanner.scan( up: ->(_, _, _) { true }, down: ->(_, _, _) { true } ) scanner.changed? # => true expect(scanner.lines).to eq(code_lines) scanner.stash_changes expect(scanner.lines).to_not eq(code_lines)
Not a URI
.
URI
is valid, bad usage is not.
YAML::Store
provides the same functionality as PStore
, except it uses YAML
to dump objects instead of Marshal
.
require 'yaml/store' Person = Struct.new :first_name, :last_name people = [Person.new("Bob", "Smith"), Person.new("Mary", "Johnson")] store = YAML::Store.new "test.store" store.transaction do store["people"] = people store["greeting"] = { "hello" => "world" } end
After running the above code, the contents of “test.store” will be:
--- people: - !ruby/struct:Person first_name: Bob last_name: Smith - !ruby/struct:Person first_name: Mary last_name: Johnson greeting: hello: world
A Process::Status
contains information about a system process.
Thread-local variable $?
is initially nil
. Some methods assign to it a Process::Status
object that represents a system process (either running or terminated):
`ruby -e "exit 99"` stat = $? # => #<Process::Status: pid 1262862 exit 99> stat.class # => Process::Status stat.to_i # => 25344 stat.stopped? # => false stat.exited? # => true stat.exitstatus # => 99
ConditionVariable
objects augment class Mutex
. Using condition variables, it is possible to suspend while in the middle of a critical section until a resource becomes available.
Example:
mutex = Thread::Mutex.new resource = Thread::ConditionVariable.new a = Thread.new { mutex.synchronize { # Thread 'a' now needs the resource resource.wait(mutex) # 'a' can now have the resource } } b = Thread.new { mutex.synchronize { # Thread 'b' has finished using the resource resource.signal } }
An internal representation of the backtrace. The user will never interact with objects of this class directly, but class methods can be used to get backtrace settings of the current session.
Module File::Constants
defines file-related constants.
There are two families of constants here:
Those having to do with file access.
Those having to do with filename globbing.
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 constants may be used with optional argument mode
in calls to the following methods:
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.
Flag File::RDONLY specifies 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).
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).
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"
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.
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.
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.
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.
Some file-access constants are defined only on POSIX-compliant systems; those are:
File::SYNC.
File::DSYNC.
File::RSYNC.
File::DIRECT.
File::NOATIME.
File::NOCTTY.
File::NOFOLLOW.
File::TMPFILE.
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.
File::SYNC specifies that all write operations (both data and metadata) are immediately to be flushed to the underlying storage device. This means that the data is written to the storage device, and the file’s metadata (e.g., file size, timestamps, permissions) are also synchronized. This guarantees that data is safely stored on the storage medium before returning control to the calling program. This flag can have a significant impact on performance since it requires synchronous writes, which can be slower compared to asynchronous writes.
File::RSYNC specifies that any read operations on the file will not return until all outstanding write operations (those that have been issued but not completed) are also synchronized. This is useful when you want to read the most up-to-date data, which may still be in the process of being written.
File::DSYNC specifies that all data write operations are immediately to be flushed to the underlying storage device; this differs from File::SYNC, which requires that metadata also be synchronized.
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.
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.
Flag File::DIRECT requests that cache effects of the I/O to and from the stream be minimized.
Defined only for POSIX-compliant systems.
Flag File::NOATIME specifies that act of opening the stream should not modify its access time (atime).
Defined only for POSIX-compliant systems.
Flag File::NOFOLLOW specifies that if path is a symbolic link, it should not be followed.
Defined only for POSIX-compliant systems.
Flag File::TMPFILE specifies that the opened stream should be a new temporary file.
Defined only for POSIX-compliant systems.
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.
Flag File::BINARY specifies that the stream is to be accessed in binary mode.
Flag File::SHARE_DELETE enables other processes to open the stream with delete access.
Windows only.
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.
Four file constants relate to stream locking; see File#flock
:
Flag File::LOCK_EX specifies an exclusive lock; only one process a a time may lock the stream.
Flag File::LOCK_NB specifies non-blocking locking for the stream; may be combined with File::LOCK_EX or File::LOCK_SH.
Flag File::LOCK_SH specifies that multiple processes may lock the stream at the same time.
Flag File::LOCK_UN specifies that the stream is not to be locked.
Filename-globbing constants may be used with optional argument flags
in calls to the following methods:
The constants are:
Flag File::FNM_CASEFOLD makes patterns case insensitive for File.fnmatch
(but not Dir.glob
).
Flag File::FNM_DOTMATCH makes the '*'
pattern match a filename starting with '.'
.
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>]
Flag File::FNM_NOESCAPE disables '\'
escaping.
Flag File::FNM_PATHNAME specifies that patterns '*'
and '?'
do not match the directory separator (the value of constant File::SEPARATOR).
Flag File::FNM_SHORTNAME allows patterns to match short names if they exist.
Windows only.
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
.
Flag File::NULL contains the string value of the null device:
On a Unix-like OS, '/dev/null'
.
On Windows, 'NUL'
.
This module provides instance methods for a digest implementation object to calculate message digest values.
OpenSSL
IO
buffering mix-in module.
This module allows an OpenSSL::SSL::SSLSocket
to behave like an IO
.
You typically won’t use this module directly, you can see it implemented in OpenSSL::SSL::SSLSocket
.