lib/rio/piper/cp.rb in rio-0.4.2 vs lib/rio/piper/cp.rb in rio-0.5.1
- old
+ new
@@ -1,8 +1,8 @@
#--
-# ===============================================================================
-# Copyright (c) 2005,2006,2007,2008 Christopher Kleckner
+# ===========================================================================
+# Copyright (c) 2005-2012 Christopher Kleckner
# All rights reserved
#
# This file is part of the Rio library for ruby.
#
# Rio is free software; you can redistribute it and/or modify
@@ -16,62 +16,85 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Rio; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# ===============================================================================
+# ===========================================================================
#++
#
-# To create the documentation for Rio run the command
-# ruby build_doc.rb
-# from the distribution directory.
-#
-# Suggested Reading
-# * RIO::Doc::SYNOPSIS
-# * RIO::Doc::INTRO
-# * RIO::Doc::HOWTO
-# * RIO::Doc::EXAMPLES
-# * RIO::Rio
-#
module RIO
module Piper #:nodoc: all
module Cp
module Util
protected
- def process_pipe_arg_(npiper)
- end_rio = npiper.rios[-1]
- case end_rio.scheme
+ def process_pipe_arg0_(npiper)
+ erio = npiper.rios[-1]
+ case erio.scheme
when 'cmdio'
new_rio(:cmdpipe,npiper)
when 'cmdpipe'
- if end_rio.has_output_dest?
+ if erio.has_output_dest?
npiper.run
- end_rio
+ erio
else
new_rio(:cmdpipe,npiper)
end
else
npiper.run
- end_rio
+ erio
end
end
+ def process_pipe_arg_(ario)
+ case ario.scheme
+ when 'cmdio'
+ new_rio(:cmdpipe,ario)
+ when 'cmdpipe'
+ new_rio(:cmdpipe,ario)
+ else
+ new_rio(:cmdpipe,ario)
+ end
+ end
+
end
module Input
include Util
+ #def last_rio(r)
+ # r.scheme == 'cmdpipe' ? last_rio(r.rl.query[-1]) : r
+ #end
+ def last_rio(r)
+ r = r.rl.query[-1] while r.scheme == 'cmdpipe'
+ r
+ end
+ #define_method(:last_rio) do |r|
+ # if r.scheme == 'cmdpipe'
+ # r = r.rl.query[-1]
+ # redo
+ # else
+ # r
+ # end
+ #end
+ def has_output_dest?(nrio)
+ !%w[cmdio cmdpipe].include?(last_rio(nrio).scheme)
+ end
+
def |(arg)
- #p "#{self} | #{arg}"
+ #p 'HERE 3'
ario = ensure_cmd_rio(arg)
- #cp = Rio.new(self.rl)
- #cp.cx = self.cx.clone
- #cp.ioh = self.ioh.clone unless self.ioh.nil?
- cp = clone_rio()
- npiper = Piper::Base.new(cp,ario)
- process_pipe_arg_(npiper)
+ nrio = new_rio(:cmdpipe,self.clone_rio,ario)
+
+ if has_output_dest?(nrio)
+ #p 'nrio.run'
+ nrio.run
+ else
+ #p 'nrio'
+ nrio
+ end
+
end
end
end
end
end