diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-01-13 17:04:57 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-03-23 18:24:44 +0000 |
commit | bd8a44bbc3217788ace3c7248ac325a8c7dd38b0 (patch) | |
tree | b7b50ee843bba1979cd6a0a22af240a1174985a7 /lib/alaveteli_external_command.rb | |
parent | a47554c9b4509f2842d609d11191c9e5655ec765 (diff) |
Allow options hash to be passed to ExternalCommand.
Document :timeout as a possible option key.
Diffstat (limited to 'lib/alaveteli_external_command.rb')
-rw-r--r-- | lib/alaveteli_external_command.rb | 5 |
1 files changed, 3 insertions, 2 deletions
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) |