Method: Down::Wget::Command.execute

Defined in:
lib/down/wget.rb

.execute(arguments) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/down/wget.rb', line 131

def self.execute(arguments)
  if defined?(POSIX::Spawn)
    pid, stdin_pipe, stdout_pipe, stderr_pipe = POSIX::Spawn.popen4(*arguments)
    status_reaper = Process.detach(pid)
  else
    stdin_pipe, stdout_pipe, stderr_pipe, status_reaper = Open3.popen3(*arguments)
  end

  stdin_pipe.close
  [stdout_pipe, stderr_pipe].each(&:binmode)

  new(stdout_pipe, stderr_pipe, status_reaper)
rescue Errno::ENOENT
  raise Down::Error, "wget is not installed"
end