class Audiothority::Crawler

Public Class Methods

new(dirs, blacklist=[]) click to toggle source
# File lib/audiothority/crawler.rb, line 5
def initialize(dirs, blacklist=[])
  @dirs = dirs
  @blacklist = blacklist
end

Public Instance Methods

crawl() { |path| ... } click to toggle source
# File lib/audiothority/crawler.rb, line 10
def crawl
  @dirs.each do |dir|
    dir.each_child do |path|
      if consider?(path)
        yield path
      end
    end
  end
end

Private Instance Methods

blacklisted?(path) click to toggle source
# File lib/audiothority/crawler.rb, line 26
def blacklisted?(path)
  @blacklist.any? { |r| path.basename.to_s.match(r) }
end
consider?(path) click to toggle source
# File lib/audiothority/crawler.rb, line 22
def consider?(path)
  path.readable? && path.directory? && path.children.any? && !blacklisted?(path)
end