Results for: "module_function"

Response class for Unavailable For Legal Reasons responses (status code 451).

A server operator has received a legal demand to deny access to a resource or to a set of resources that includes the requested resource. See 451 Unavailable For Legal Reasons.

Helper methods for both Gem::Installer and Gem::Uninstaller

No documentation available

FIXME: This isn’t documented in Nutshell.

Since MonitorMixin.new_cond returns a ConditionVariable, and the example above calls while_wait and signal, this class should be documented.

Response class for Precondition Failed responses (status code 412).

The server does not meet one of the preconditions specified in the request headers. See 412 Precondition Failed.

Response class for Expectation Failed responses (status code 417).

The server cannot meet the requirements of the Expect request-header field. See 417 Expectation Failed.

The table of LALR actions. Actions are either of Shift, Reduce, Accept and Error.

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
   }
}

Module that defines the default UserInteraction. Any class including this module will have access to the ui method that returns the default UI.

No documentation available
No documentation available
No documentation available

Potentially raised when a specification is validated.

No documentation available

Represents an error communicating via HTTP.

Raised by Resolver when a dependency requests a gem for which there is no spec.

Keyword completion module. This allows partial arguments to be specified and resolved against a list of acceptable values.

No documentation available

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

An Encoding instance represents a character encoding usable in Ruby. It is defined as a constant under the Encoding namespace. It has a name and, optionally, aliases:

Encoding::US_ASCII.name  # => "US-ASCII"
Encoding::US_ASCII.names # => ["US-ASCII", "ASCII", "ANSI_X3.4-1968", "646"]

A Ruby method that accepts an encoding as an argument will accept:

These are equivalent:

'foo'.encode(Encoding::US_ASCII) # Encoding object.
'foo'.encode('US-ASCII')         # Encoding name.
'foo'.encode('ASCII')            # Encoding alias.

For a full discussion of encodings and their uses, see the Encodings document.

Encoding::ASCII_8BIT is a special-purpose encoding that is usually used for a string of bytes, not a string of characters. But as the name indicates, its characters in the ASCII range are considered as ASCII characters. This is useful when you use other ASCII-compatible encodings.

Raised when a feature is not implemented on the current platform. For example, methods depending on the fsync or fork system calls may raise this exception if the underlying operating system or Ruby runtime does not support them.

Note that if fork raises a NotImplementedError, then respond_to?(:fork) returns false.

EncodingError is the base class for encoding errors.

Use the Monitor class when you want to have a lock object for blocks with mutual exclusion.

require 'monitor'

lock = Monitor.new
lock.synchronize do
  # exclusive access
end
No documentation available

Namespace for file utility methods for copying, moving, removing, etc.

What’s Here

First, what’s elsewhere. Module FileUtils:

Here, module FileUtils provides methods that are useful for:

Creating

Deleting

Querying

Setting

Comparing

Copying

Moving

Options

Path Arguments

Some methods in FileUtils accept path arguments, which are interpreted as paths to filesystem entries:

About the Examples

Some examples here involve trees of file entries. For these, we sometimes display trees using the tree command-line utility, which is a recursive directory-listing utility that produces a depth-indented listing of files and directories.

We use a helper method to launch the command and control the format:

def tree(dirpath = '.')
  command = "tree --noreport --charset=ascii #{dirpath}"
  system(command)
end

To illustrate:

tree('src0')
# => src0
#    |-- sub0
#    |   |-- src0.txt
#    |   `-- src1.txt
#    `-- sub1
#        |-- src2.txt
#        `-- src3.txt

Avoiding the TOCTTOU Vulnerability

For certain methods that recursively remove entries, there is a potential vulnerability called the Time-of-check to time-of-use, or TOCTTOU, vulnerability that can exist when:

To avoid that vulnerability, you can use this method to remove entries:

Also available are these methods, each of which calls FileUtils.remove_entry_secure:

Finally, this method for moving entries calls FileUtils.remove_entry_secure if the source and destination are on different file systems (which means that the “move” is really a copy and remove):

Method FileUtils.remove_entry_secure removes securely by applying a special pre-process:

WARNING: You must ensure that ALL parent directories cannot be moved by other untrusted users. For example, parent directories should not be owned by untrusted users, and should not be world writable except when the sticky bit is set.

For details of this security vulnerability, see Perl cases:

Search took: 10ms  ·  Total Results: 3274