Class: Spoom::FileCollector

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/spoom/file_collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allow_extensions: [], allow_mime_types: [], exclude_patterns: []) ⇒ FileCollector

Returns a new instance of FileCollector.



26
27
28
29
30
31
# File 'lib/spoom/file_collector.rb', line 26

def initialize(allow_extensions: [], allow_mime_types: [], exclude_patterns: [])
  @files = T.let([], T::Array[String])
  @allow_extensions = allow_extensions
  @allow_mime_types = allow_mime_types
  @exclude_patterns = exclude_patterns
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



9
10
11
# File 'lib/spoom/file_collector.rb', line 9

def files
  @files
end

Instance Method Details

#visit_path(path) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/spoom/file_collector.rb', line 39

def visit_path(path)
  path = clean_path(path)

  return if excluded_path?(path)

  if File.file?(path)
    visit_file(path)
  elsif File.directory?(path)
    visit_directory(path)
  else # rubocop:disable Style/EmptyElse
    # Ignore aliases, sockets, etc.
  end
end

#visit_paths(paths) ⇒ Object



34
35
36
# File 'lib/spoom/file_collector.rb', line 34

def visit_paths(paths)
  paths.each { |path| visit_path(path) }
end