class ProcessExecuter::Options
@api public
* ‘:timeout`:
Valid options are those accepted by Process.spawn plus the following additions:
Validate ProcessExecuter::Executer#spawn options and return Process.spawn options
def assert_no_unknown_options(options)
- Api: - private
Raises:
-
(ArgumentError)
- if the options hash contains any unknown options
Returns:
-
(void)
-
Parameters:
-
options
(Hash
) -- the hash of options
def assert_no_unknown_options(options) unknown_options = options.keys.reject { |key| valid_option?(key) } raise ArgumentError, "Unknown options: #{unknown_options.join(', ')}" unless unknown_options.empty? end
def include_spawn_option?(option, value)
- Api: - private
Returns:
-
(Boolean)
- true if the given option should be passed to `Process.spawn`
Parameters:
-
value
(Object
) -- the value of the option -
option
(Symbol, Integer, IO
) -- the option to be tested
def include_spawn_option?(option, value) (option.is_a?(Integer) || option.is_a?(IO) || SPAWN_OPTIONS.include?(option)) && value != NOT_SET end
def initialize(**options)
(**options)
-
:timeout
(Integer, Float, nil
) --
Parameters:
-
options
(Hash
) -- Process.spawn options plus additional options listed below.
def initialize(**options) assert_no_unknown_options(options) @options = DEFAULTS.merge(options) end
def spawn_options
-
(Hash)
-
def spawn_options {}.tap do |spawn_options| options.each do |option, value| spawn_options[option] = value if include_spawn_option?(option, value) end end end
def valid_option?(option)
- Api: - private
Returns:
-
(Boolean)
- true if the given option is a valid option
Parameters:
-
option
(Symbol
) -- the option to be tested
def valid_option?(option) ALL_OPTIONS.include?(option) || option.is_a?(Integer) || option.respond_to?(:fileno) end