lib/rio/entrysel.rb in rio-0.3.8 vs lib/rio/entrysel.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/abstract_method'
class ::Object #:nodoc: all
def true?() true end
@@ -86,11 +85,11 @@
def =~(entry)
@match_to =~ entry.to_s
end
end
class Proc < Base
- def =~(entry) @match_to[entry] end
+ def =~(entry) @match_to[entry.clone] end
end
class Symbol < Base
def =~(entry) entry.__send__(@match_to) end
end
class And < Base
@@ -165,46 +164,45 @@
def initialize(entry_sel)
@entry_sel = entry_sel
@sel = @nosel = nil
process_entry_sel() if @entry_sel
end
- def es_args()
- es = @entry_sel
- es['args']
+ def entry_sel_args()
+ @entry_sel['args']
end
def something_selected?
- %w[entries files dirs].any? { |k| es_args.has_key?(k) }
+ %w[entries files dirs].any? { |k| entry_sel_args.has_key?(k) }
end
def something_skipped?
- %w[skipentries skipfiles skipdirs].any? { |k| es_args.has_key?(k) }
+ %w[skipentries skipfiles skipdirs].any? { |k| entry_sel_args.has_key?(k) }
end
def skip_type(skip_args)
end
def process_entry_sel()
- ea = es_args
- raise RuntimeError, "Internal error: entry_sel_args not set" unless ea
+ sel_args = self.entry_sel_args
+ raise RuntimeError, "Internal error: entry_sel_args not set" unless sel_args
if something_selected?
@sel = Match::Entry::Sels.new
- @sel << Match::Entry::List.new(:true?,*ea['entries']) if ea.has_key?('entries')
- @sel << Match::Entry::List.new(:file?,*ea['files']) if ea.has_key?('files')
- @sel << Match::Entry::List.new(:dir?,*ea['dirs']) if ea.has_key?('dirs')
+ @sel << Match::Entry::List.new(:true?,*sel_args['entries']) if sel_args.has_key?('entries')
+ @sel << Match::Entry::List.new(:file?,*sel_args['files']) if sel_args.has_key?('files')
+ @sel << Match::Entry::List.new(:dir?,*sel_args['dirs']) if sel_args.has_key?('dirs')
end
if something_skipped?
@nosel = Match::Entry::Sels.new
- if ea.has_key?('skipentries')
- @nosel << Match::Entry::List.new(:true?,*ea['skipentries'])
+ if sel_args.has_key?('skipentries')
+ @nosel << Match::Entry::List.new(:true?,*sel_args['skipentries'])
end
- if ea.has_key?('skipfiles')
- @nosel << Match::Entry::List.new(:file?,*ea['skipfiles'])
- unless ea['skipfiles'].empty? or ea.has_key?('files')
+ if sel_args.has_key?('skipfiles')
+ @nosel << Match::Entry::List.new(:file?,*sel_args['skipfiles'])
+ unless sel_args['skipfiles'].empty? or sel_args.has_key?('files')
@sel ||= Match::Entry::Sels.new
@sel << Match::Entry::List.new(:file?)
end
end
- if ea.has_key?('skipdirs')
- @nosel << Match::Entry::List.new(:dir?,*ea['skipdirs'])
- unless ea['skipdirs'].empty? or ea.has_key?('dirs')
+ if sel_args.has_key?('skipdirs')
+ @nosel << Match::Entry::List.new(:dir?,*sel_args['skipdirs'])
+ unless sel_args['skipdirs'].empty? or sel_args.has_key?('dirs')
@sel ||= Match::Entry::Sels.new
@sel << Match::Entry::List.new(:dir?)
end
end
end