Class: Stowaway::Sweeper

Inherits:
Object
  • Object
show all
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

Output::RESET

Instance Method Summary collapse

Methods included from Output

#clr_print, #flush, #new_line

Methods included from FSHelpyHelp

#ignore?, #ignore_special_directories, #recursively

Constructor Details

#initialize(matcher = Matcher.new) ⇒ Sweeper

Returns a new instance of Sweeper.



17
18
19
20
# File 'lib/stowaway/sweeper.rb', line 17

def initialize(matcher = Matcher.new)
  @matcher = matcher
  @ignore = [/^\.|\.jpg$|\.jpeg$|\.gif$|\.png$|\.ico$|\.bmp$/i]
end

Instance Method Details

#sweep(target_context, files) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/stowaway/sweeper.rb', line 22

def sweep(target_context, files)
  @context = target_context
  @result = OpenStruct.new({ :files => files, :name_only_matches => []})
  ignore_special_directories(@context.root)
  recursively(@context.root) { |fp| inspect_file(fp) }
  @result
end