Class: CommandT::FileScanner

Inherits:
Scanner
  • Object
show all
Defined in:
lib/command-t-standalone/scanner/file_scanner.rb

Overview

Reads the current directory recursively for the paths to all regular files.

Defined Under Namespace

Classes: FileLimitExceeded

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = Dir.pwd, options = {}) ⇒ FileScanner

Returns a new instance of FileScanner.



33
34
35
36
37
38
39
40
41
# File 'lib/command-t-standalone/scanner/file_scanner.rb', line 33

def initialize path = Dir.pwd, options = {}
  @paths                = {}
  @paths_keys           = []
  @path                 = path
  @max_depth            = options[:max_depth] || 15
  @max_files            = options[:max_files] || 10_000
  @max_caches           = options[:max_caches] || 1
  @scan_dot_directories = options[:scan_dot_directories] || false
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



31
32
33
# File 'lib/command-t-standalone/scanner/file_scanner.rb', line 31

def path
  @path
end

Instance Method Details

#flushObject



57
58
59
# File 'lib/command-t-standalone/scanner/file_scanner.rb', line 57

def flush
  @paths = {}
end

#pathsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/command-t-standalone/scanner/file_scanner.rb', line 43

def paths
  return @paths[@path] if @paths.has_key?(@path)
  begin
    ensure_cache_under_limit
    @paths[@path] = []
    @depth        = 0
    @files        = 0
    @prefix_len   = @path.chomp('/').length
    add_paths_for_directory @path, @paths[@path]
  rescue FileLimitExceeded
  end
  @paths[@path]
end