Class: Gumdrop::Util::Scanner

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/gumdrop/util/scanner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

#log

Constructor Details

#initialize(base_path, opts = {}, &block) ⇒ Scanner

Returns a new instance of Scanner.



8
9
10
11
12
13
# 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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/gumdrop/util/scanner.rb', line 6

def options
  @options
end

Instance Method Details

#eachObject



15
16
17
18
19
20
21
22
23
24
# 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) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
# 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