lib/tty/command/execute.rb in tty-command-0.3.2 vs lib/tty/command/execute.rb in tty-command-0.3.3
- old
+ new
@@ -4,12 +4,10 @@
require 'securerandom'
module TTY
class Command
module Execute
- extend self
-
# Execute command in a child process
#
# The caller should ensure that all IO objects are closed
# when the child process is finished. However, when block
# is provided this will be taken care of automatically.
@@ -60,11 +58,11 @@
if fd?(key)
process_key = fd_to_process_key(key)
if process_key.to_s == 'in'
value = convert_to_fd(value)
end
- opts[process_key]= value
+ opts[process_key] = value
end
opts
end
end
@@ -75,11 +73,11 @@
true
when STDIN, STDOUT, STDERR, $stdin, $stdout, $stderr, ::IO
true
when ::IO
true
- when ::Fixnum
+ when ::Integer
object >= 0
when respond_to?(:to_i) && !object.to_io.nil?
true
else
false
@@ -97,11 +95,11 @@
end
def convert_to_fd(object)
return object if fd?(object)
- if object.is_a?(::String) && ::File.exists?(object)
+ if object.is_a?(::String) && ::File.exist?(object)
return object
end
tmp = ::Tempfile.new(::SecureRandom.uuid.split('-')[0])
@@ -117,10 +115,10 @@
:in
when STDOUT, $stdout, :out, :stdout, 1
:out
when STDERR, $stderr, :err, :stderr, 2
:err
- when Fixnum
+ when Integer
object >= 0 ? IO.for_fd(object) : nil
when IO
object
when respond_to?(:to_io)
object.to_io