Class: Stellwerk::SourceFileCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/stellwerk/source_file_collector.rb

Constant Summary collapse

EXCLUDED_PATHS =
["db/", "vendor/"]
SOURCE_FILE_EXTENSIONS =
[".rb", ".erb"]

Instance Method Summary collapse

Constructor Details

#initialize(root_path, exclude_paths: EXCLUDED_PATHS) ⇒ SourceFileCollector

Returns a new instance of SourceFileCollector.



8
9
10
11
# File 'lib/stellwerk/source_file_collector.rb', line 8

def initialize(root_path, exclude_paths: EXCLUDED_PATHS)
  @root_path = Pathname.new(root_path)
  @exclude_paths = exclude_paths
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
# File 'lib/stellwerk/source_file_collector.rb', line 13

def call
  absolute_exclude_paths = @exclude_paths.map do |path|
    @root_path.join(path).to_s.delete_suffix(File::SEPARATOR)
  end

  @root_path.find
    .select { |path| source_file?(path) }
    .reject { |path| excluded_path?(path.to_s, absolute_exclude_paths) }
end