class Forspell::FileList
Constants
- EXTENSION_GLOBS
Public Class Methods
new(paths:, exclude_paths:)
click to toggle source
# 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
Public Instance Methods
each(&block)
click to toggle source
# File lib/forspell/file_list.rb, line 25 def each(&block) @files.map{ |path| path.gsub('//', '/')} .each(&block) end
size()
click to toggle source
# File lib/forspell/file_list.rb, line 30 def size @size ||= @files.size end
Private Instance Methods
expand_paths(path)
click to toggle source
# File lib/forspell/file_list.rb, line 36 def expand_paths(path) if File.directory?(path) Dir.glob(File.join(path, '**', "*.{#{EXTENSION_GLOBS.join(',')}}")) elsif File.exists? path path else raise PathLoadError, path end end