Class: CommandT::Scanner::FileScanner

Inherits:
CommandT::Scanner show all
Defined in:
lib/command-t/scanner/file_scanner.rb,
lib/command-t/scanner/file_scanner/git_file_scanner.rb,
lib/command-t/scanner/file_scanner/find_file_scanner.rb,
lib/command-t/scanner/file_scanner/ruby_file_scanner.rb,
lib/command-t/scanner/file_scanner/watchman_file_scanner.rb

Overview

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

This is an abstract superclass; the real work is done by subclasses which obtain file listings via different strategies (for examples, see the RubyFileScanner and FindFileScanner subclasses).

Direct Known Subclasses

FindFileScanner, RubyFileScanner

Defined Under Namespace

Classes: FindFileScanner, GitFileScanner, RubyFileScanner, WatchmanFileScanner

Constant Summary collapse

FileLimitExceeded =
Class.new(::RuntimeError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of FileScanner.



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/command-t/scanner/file_scanner.rb', line 20

def initialize(path = Dir.pwd, options = {})
  @paths                = {}
  @paths_keys           = []
  @path                 = path
  @max_depth            = options[:max_depth] || 15
  @max_files            = options[:max_files] || 100_000
  @max_caches           = options[:max_caches] || 1
  @scan_dot_directories = options[:scan_dot_directories] || false
  @wildignore           = options[:wildignore]
  @scan_submodules      = options[:git_scan_submodules] || false
  @include_untracked    = options[:git_include_untracked] || false
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



18
19
20
# File 'lib/command-t/scanner/file_scanner.rb', line 18

def path
  @path
end

Instance Method Details

#flushObject



41
42
43
# File 'lib/command-t/scanner/file_scanner.rb', line 41

def flush
  @paths = {}
end

#pathsObject



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

def paths
  @paths[@path] ||= begin
    ensure_cache_under_limit
    @prefix_len = @path.chomp('/').length + 1
    paths!
  end
end