Module: ProcessExecuter::Destinations
- Defined in:
- lib/process_executer/destinations.rb,
lib/process_executer/destinations/io.rb,
lib/process_executer/destinations/tee.rb,
lib/process_executer/destinations/close.rb,
lib/process_executer/destinations/stderr.rb,
lib/process_executer/destinations/stdout.rb,
lib/process_executer/destinations/writer.rb,
lib/process_executer/destinations/file_path.rb,
lib/process_executer/destinations/file_path_mode.rb,
lib/process_executer/destinations/monitored_pipe.rb,
lib/process_executer/destinations/file_descriptor.rb,
lib/process_executer/destinations/child_redirection.rb,
lib/process_executer/destinations/file_path_mode_perms.rb
Overview
Collection of destination handler implementations
Defined Under Namespace
Classes: ChildRedirection, Close, FileDescriptor, FilePath, FilePathMode, FilePathModePerms, IO, MonitoredPipe, Stderr, Stdout, Tee, Writer
Class Method Summary collapse
-
.compatible_with_monitored_pipe?(destination) ⇒ Boolean?
Determines if the given destination is compatible with a monitored pipe.
-
.factory(destination) ⇒ DestinationBase
Creates appropriate destination objects based on the given destination.
-
.matching_destination_class(destination) ⇒ Class
private
Determines the destination class that can handle the given destination.
Class Method Details
.compatible_with_monitored_pipe?(destination) ⇒ Boolean?
Determines if the given destination is compatible with a monitored pipe
If true, this destination should not be wrapped in a monitored pipe.
52 53 54 55 |
# File 'lib/process_executer/destinations.rb', line 52 def self.compatible_with_monitored_pipe?(destination) matching_class = matching_destination_class(destination) matching_class&.compatible_with_monitored_pipe? end |
.factory(destination) ⇒ DestinationBase
Creates appropriate destination objects based on the given destination
This factory method dynamically finds and instantiates the appropriate destination class for handling the provided destination.
32 33 34 35 36 37 |
# File 'lib/process_executer/destinations.rb', line 32 def self.factory(destination) matching_class = matching_destination_class(destination) return matching_class.new(destination) if matching_class raise ArgumentError, 'wrong exec redirect action' end |
.matching_destination_class(destination) ⇒ Class
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determines the destination class that can handle the given destination
61 62 63 64 65 66 67 68 |
# File 'lib/process_executer/destinations.rb', line 61 def self.matching_destination_class(destination) destination_classes = ProcessExecuter::Destinations.constants .map { |const| ProcessExecuter::Destinations.const_get(const) } .select { |const| const.is_a?(Class) } destination_classes.find { |klass| klass.handles?(destination) } end |