about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-08-26 00:09:32 +0000
committerEric Wong <normalperson@yhbt.net>2013-08-26 00:09:32 +0000
commita1198562c51c5374a85d74e1cfe9e6a695384a3d (patch)
tree0a7cb6480c144da6363a74e8adf75a73b2ba204d
parent5a966a1ec8662d2e0b9035675a770c6f2c739b7d (diff)
downloaddtas-a1198562c51c5374a85d74e1cfe9e6a695384a3d.tar.gz
Shellwords.join is an identical method and there's no reason not to
use it.
-rw-r--r--lib/dtas/format.rb2
-rw-r--r--lib/dtas/process.rb9
-rw-r--r--lib/dtas/source/sox.rb2
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