Class: CommandT::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/command_t/scanner.rb

Overview

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

Defined Under Namespace

Classes: FileLimitExceeded

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Scanner.



29
30
31
32
33
34
# File 'lib/command_t/scanner.rb', line 29

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

Instance Method Details

#flushObject



49
50
51
# File 'lib/command_t/scanner.rb', line 49

def flush
  @paths = nil
end

#path=(str) ⇒ Object



53
54
55
56
57
58
# File 'lib/command_t/scanner.rb', line 53

def path= str
  if @path != str
    @path = str
    flush
  end
end

#pathsObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/command_t/scanner.rb', line 36

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