From a1198562c51c5374a85d74e1cfe9e6a695384a3d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 26 Aug 2013 00:09:32 +0000 Subject: process: remove redundant "xs" method Shellwords.join is an identical method and there's no reason not to use it. --- lib/dtas/format.rb | 2 +- lib/dtas/process.rb | 9 +-------- lib/dtas/source/sox.rb | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/dtas/format.rb b/lib/dtas/format.rb index 6da5675..98aa9db 100644 --- a/lib/dtas/format.rb +++ b/lib/dtas/format.rb @@ -64,7 +64,7 @@ class DTAS::Format # :nodoc: end def inspect - "<#{self.class}(#{xs(to_sox_arg)})>" + "<#{self.class}(#{Shellwords.join(to_sox_arg)})>" end def to_hsh diff --git a/lib/dtas/process.rb b/lib/dtas/process.rb index 3f1dc07..c19b5c5 100644 --- a/lib/dtas/process.rb +++ b/lib/dtas/process.rb @@ -18,12 +18,6 @@ module DTAS::Process # :nodoc: end while true end - # a convienient way to display commands so it's easy to - # read, copy and paste to a shell - def xs(cmd) - cmd.map { |w| Shellwords.escape(w) }.join(' ') - end - # for long-running processes (sox/play/ecasound filters) def dtas_spawn(env, cmd, opts) opts = { close_others: true, pgroup: true }.merge!(opts) @@ -87,10 +81,9 @@ module DTAS::Process # :nodoc: r.close _, status = Process.waitpid2(pid) return res if status.success? - raise RuntimeError, "`#{xs(cmd)}' failed: #{status.inspect}" + raise RuntimeError, "`#{Shellwords.join(cmd)}' failed: #{status.inspect}" end # XXX only for DTAS::Source::{Sox,Av}.try module_function :qx - module_function :xs end diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb index 235cbbc..086b923 100644 --- a/lib/dtas/source/sox.rb +++ b/lib/dtas/source/sox.rb @@ -77,7 +77,7 @@ class DTAS::Source::Sox # :nodoc: end rescue => e if /FAIL formats: no handler for file extension/ =~ err - warn("#{xs(cmd)}: #{err}") + warn("#{Shellwords.escape(cmd)}: #{err}") else warn("#{e.message} (#{e.class})") end -- cgit v1.2.3-24-ge0c7