Class: Forspell::FileList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/forspell/file_list.rb

Defined Under Namespace

Classes: PathLoadError

Constant Summary collapse

EXTENSION_GLOBS =
%w[
  rb
  c
  cpp
  cxx
  md
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(paths:, exclude_paths:) ⇒ FileList

Returns a new instance of FileList.



16
17
18
19
20
21
22
23
# File 'lib/forspell/file_list.rb', line 16

def initialize(paths:, exclude_paths:)
  @paths = paths
  @exclude_paths = exclude_paths

  to_process = @paths.flat_map(&method(:expand_paths))
  to_exclude = @exclude_paths.flat_map(&method(:expand_paths))
  @files = to_process - to_exclude
end

Instance Method Details

#each(&block) ⇒ Object



25
26
27
28
# File 'lib/forspell/file_list.rb', line 25

def each(&block)
  @files.map{ |path| path.gsub('//', '/')}
    .each(&block)
end

#sizeObject



30
31
32
# File 'lib/forspell/file_list.rb', line 30

def size
  @size ||= @files.size
end