Class: Yalphabetize::YamlFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/yalphabetize/yaml_finder.rb

Constant Summary collapse

YAML_EXTENSIONS =
%w[.yml .yaml].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeYamlFinder

Returns a new instance of YamlFinder.



17
18
19
# File 'lib/yalphabetize/yaml_finder.rb', line 17

def initialize
  @files = []
end

Class Method Details

.paths(only:, exclude:) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/yalphabetize/yaml_finder.rb', line 9

def self.paths(only:, exclude:)
  if exclude.any?
    new.paths(only) - new.paths(exclude)
  else
    new.paths(only)
  end
end

Instance Method Details

#paths(paths) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/yalphabetize/yaml_finder.rb', line 21

def paths(paths)
  if paths.empty?
    files << files_in_dir
  else
    process_paths(paths)
  end

  files.flatten.select { |file| valid?(file) }.map { |f| File.expand_path(f) }.uniq
end