Class: Nearline::Models::FileFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/nearline/manifest.rb

Overview

Recuses paths and finds the files to back up

Class Method Summary collapse

Class Method Details

.exclusion_regexes(exclusions) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/nearline/manifest.rb', line 19

def self.exclusion_regexes(exclusions)
  regex_exclusions = []
  for exclusion in exclusions
    regex_exclusions << /#{exclusion}/
  end
  regex_exclusions
end

.recurse(paths, exclusions) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/nearline/manifest.rb', line 7

def self.recurse(paths, exclusions)
  regex_exclusions = exclusion_regexes(exclusions)
  paths.each do |path|
    Find.find(path) do |f|
      regex_exclusions.each do |ex|
        Find.prune if ex.match(f)
      end
      yield f
    end
  end
end