Class: Gumdrop::Util::Scanner
- Inherits:
-
Object
- Object
- Gumdrop::Util::Scanner
- Includes:
- Loggable
- Defined in:
- lib/gumdrop/util/scanner.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(base_path, opts = {}, &block) ⇒ Scanner
constructor
A new instance of Scanner.
- #should_skip?(path, full_path) ⇒ Boolean
Methods included from Loggable
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
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/gumdrop/util/scanner.rb', line 6 def @options end |
Instance Method Details
#each ⇒ Object
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
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 |