From bd8a44bbc3217788ace3c7248ac325a8c7dd38b0 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 13 Jan 2015 17:04:57 +0000 Subject: Allow options hash to be passed to ExternalCommand. Document :timeout as a possible option key. --- lib/alaveteli_external_command.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/alaveteli_external_command.rb') diff --git a/lib/alaveteli_external_command.rb b/lib/alaveteli_external_command.rb index 79711328c..f28d00d8f 100644 --- a/lib/alaveteli_external_command.rb +++ b/lib/alaveteli_external_command.rb @@ -9,13 +9,14 @@ module AlaveteliExternalCommand # :binary_output - boolean flag for treating the output as binary or text (only significant # ruby 1.9 and above) # :memory_limit - maximum amount of memory (in bytes) available to the process + # :timeout - maximum amount of time (in s) to allow the process to run for def run(program_name, *args) # Run an external program, and return its output. # Standard error is suppressed unless the program # fails (i.e. returns a non-zero exit status). opts = {} - if !args.empty? && args[-1].is_a?(Hash) - opts = args.pop + if !args.empty? && args.last.is_a?(Hash) + opts = args.last end program_path = find_program(program_name) -- cgit v1.2.3