lib/fynd/criteria.rb in fynd-0.1.2 vs lib/fynd/criteria.rb in fynd-0.1.3
- old
+ new
@@ -5,46 +5,41 @@
module Fynd
class Criteria
extend Forwardable
- attr_accessor :sieve
+ attr_accessor :sieve, :paths
def_delegators :@sieve, :collection, :conditions
def initialize(*paths)
+ @paths = paths
@sieve = Sieve.new
@sieve.collection = []
@sieve.conditions = {}
@sieve.conditions['actions'] = {}
@sieve.conditions['operators'] = {}
@sieve.conditions['tests'] = {}
- # For every path...
- paths.each do |path|
- # Pull out all directories
- # dirs = Dir.glob(File.expand_path(path)).select { |f| File.lstat(f).directory? }
- # Shove all found files into the collection
- # @sieve.collection << Dir.glob(File.expand_path(path))
- @sieve.collection << Find.find(File.expand_path(path)).to_a
- end
-
# Flatten it and strip out non-unique files
- @sieve.collection.flatten!.uniq!
+
end
# def find(*paths)
# where(:paths => paths)
# self
# end
def run
+ @sieve.collection = paths.map do |path|
+ Find.find(File.expand_path(path)).to_a
+ end.flatten.uniq
sieve.run
return sieve.files
end
def files
- files = sieve.run
+ files = run
if block_given?
yield files
else
return files