Class: Stowaway::Sweeper
- Inherits:
-
Object
- Object
- Stowaway::Sweeper
- Includes:
- FSHelpyHelp, Output
- Defined in:
- lib/stowaway/sweeper.rb
Overview
Sweeper will sweep through a directory recursively (path) and try to find references to files in the array of FileObjs passed in as the second parameter.
Constant Summary
Constants included from Output
Instance Method Summary collapse
-
#initialize(matcher = Matcher.new, ext_to_ignore = []) ⇒ Sweeper
constructor
A new instance of Sweeper.
- #sweep(path, files = nil) ⇒ Object
Methods included from Output
Methods included from FSHelpyHelp
Constructor Details
#initialize(matcher = Matcher.new, ext_to_ignore = []) ⇒ Sweeper
Returns a new instance of Sweeper.
17 18 19 20 21 |
# File 'lib/stowaway/sweeper.rb', line 17 def initialize(matcher = Matcher.new, ext_to_ignore = []) @matcher = matcher @ignore = ext_to_ignore @ignore << /^\.|\.jpg$|\.jpeg$|\.gif$|\.png$|\.ico$|\.bmp$/i end |
Instance Method Details
#sweep(path, files = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/stowaway/sweeper.rb', line 23 def sweep(path, files=nil) @root ||= path @result ||= OpenStruct.new({ :files => files, :name_only_matches => []}) dir = Dir.new(path) dir.each do |f| next if ignore?(f) file = File.join(dir.path, f) if File.directory?(file) sweep(file) else inspect_file(file) end end @result end |