lib/rio/ops/dir.rb in rio-0.3.8 vs lib/rio/ops/dir.rb in rio-0.3.9
- old
+ new
@@ -1,8 +1,8 @@
#--
# ===============================================================================
-# Copyright (c) 2005, 2006 Christopher Kleckner
+# Copyright (c) 2005,2006,2007 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
@@ -21,20 +21,19 @@
# ===============================================================================
#++
#
# To create the documentation for Rio run the command
# ruby build_doc.rb
-# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
+# from the distribution directory.
#
# Suggested Reading
# * RIO::Doc::SYNOPSIS
# * RIO::Doc::INTRO
# * RIO::Doc::HOWTO
+# * RIO::Doc::EXAMPLES
# * RIO::Rio
#
-# <b>Rio is pre-alpha software.
-# The documented interface and behavior is subject to change without notice.</b>
require 'rio/grande'
require 'rio/cp'
require 'rio/ops/either'
@@ -229,24 +228,36 @@
return self unless cx.has_key?('skip_args')
args = cx['skip_args'] || []
self.skipentries(*args)
end
def ent_to_rio_(ent,indir)
- if indir
- new_rio_cx(indir.rl,ent)
+ #p "ent_to_rio: #{ent.inspect},#{ent.fs.class} indir=#{indir}"
+ if ent.kind_of?(RIO::Rio)
+ oldpath = ent.to_s
+ ent.rl.urlpath = indir.to_s
+ ent.join!(oldpath)
+ ent.cx = self.cx.bequeath(ent.cx)
+ ent
else
- new_rio_cx(ent)
+ if indir
+ new_rio_cx(indir.rl,ent)
+ else
+ new_rio_cx(ent)
+ end
end
end
def handle_ent_(ent,indir,sel,&block)
begin
erio = ent_to_rio_(ent,indir)
+ #p "handle_ent_1: #{erio.cx.inspect}"
if stream_iter?
+ # case for iterating files in a directory (e.g. rio('adir').lines)
_add_stream_iter_cx(erio).each(&block) if erio.file? and sel.match?(erio)
else
yield _add_iter_cx(erio) if sel.match?(erio)
end
+ #p "handle_ent_2: #{erio.cx.inspect}"
if cx.has_key?('all') and erio.directory?
rsel = Match::Entry::SelectorClassic.new(cx['r_sel'],cx['r_nosel'])
_add_recurse_iter_cx(erio).each(&block) if rsel.match?(erio)
end
@@ -254,10 +265,10 @@
rescue ::Errno::ENOENT, ::URI::InvalidURIError => ex
$stderr.puts(ex.message+". Skipping.")
end
end
def each_(*args,&block)
- #p "#{callstr('each_',*args)} sel=#{cx['sel'].inspect} nosel=#{cx['nosel'].inspect}"
+ #p "#{callstr('each_',*args)} sel=#{cx['entry_sel'].inspect}"
handle_skipped()
sel = Match::Entry::Selector.new(cx['entry_sel'])
indir = (self.to_s == '.' ? nil : self)
self.ioh.each do |ent|
#next if