Class: Templatecop::PathFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/templatecop/path_finder.rb

Overview

Collect file paths from given path patterns.

Instance Method Summary collapse

Constructor Details

#initialize(default_patterns:, exclude_patterns:, patterns:) ⇒ PathFinder

Returns a new instance of PathFinder.

Parameters:

  • default_patterns (Array<String>)
  • patterns (Array<String>)

    Patterns normally given as CLI arguments (e.g. ‘[“app/views/*/.html.template”]`).



11
12
13
14
15
16
17
18
19
# File 'lib/templatecop/path_finder.rb', line 11

def initialize(
  default_patterns:,
  exclude_patterns:,
  patterns:
)
  @default_patterns = default_patterns
  @exclude_patterns = exclude_patterns || []
  @patterns = patterns
end

Instance Method Details

#callArray<String>

Returns:

  • (Array<String>)


22
23
24
25
26
# File 'lib/templatecop/path_finder.rb', line 22

def call
  matching_paths(patterns) do |path|
    !excluded?(path)
  end.sort
end