class Gumdrop::Util::Scanner

Attributes

options[R]

Public Class Methods

new(base_path, opts={}, &block) click to toggle source
# File lib/gumdrop/util/scanner.rb, line 8
def initialize(base_path, opts={}, &block)
  @source_glob= base_path / "**" / "*"
  @options= opts
  @src_path= base_path
  @validator= block || method(:_default_validator)
end

Public Instance Methods

each() { |path, rel_path| ... } click to toggle source
# File lib/gumdrop/util/scanner.rb, line 15
def each
  Dir.glob(@source_glob, File::FNM_DOTMATCH).each do |path|
    rel_path= _relative(path)
    unless should_skip? rel_path, path
      yield path, rel_path
    else
      log.debug " excluding: #{ rel_path }"
    end
  end
end
should_skip?(path, full_path) click to toggle source
# File lib/gumdrop/util/scanner.rb, line 26
def should_skip?(path, full_path)
  return true if File.directory?(full_path)
  @validator.call(path, full_path) || false
end

Private Instance Methods

_default_validator(src,full) click to toggle source
# File lib/gumdrop/util/scanner.rb, line 33
def _default_validator(src,full)
  true
end
_relative(path) click to toggle source
# File lib/gumdrop/util/scanner.rb, line 37
def _relative(path)
  relpath= path.gsub @src_path, ''
  if relpath[0]== '/'
    relpath[1..-1]
  else
    relpath
  end
end