Class: Dlme::ConfigFinder

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

Overview

Compiles a list of configs to use for the given filepaths

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_data_dir:, data_dir:, mapping_file:) ⇒ ConfigFinder

Returns a new instance of ConfigFinder.


11
12
13
14
15
# File 'lib/config_finder.rb', line 11

def initialize(base_data_dir:, data_dir:, mapping_file:)
  @base_data_dir = base_data_dir
  @data_dir = data_dir
  @mapping_file = mapping_file
end

Class Method Details

.for(base_data_dir:, data_dir:, mapping_file:) ⇒ Object

Raises:

  • RuntimeError if no files are found


5
6
7
8
9
# File 'lib/config_finder.rb', line 5

def self.for(base_data_dir:, data_dir:, mapping_file:)
  new(base_data_dir: base_data_dir,
      data_dir: data_dir,
      mapping_file: mapping_file).find
end

Instance Method Details

#findObject

Raises:

  • RuntimeError if no files are found


18
19
20
21
22
23
# File 'lib/config_finder.rb', line 18

def find
  paths = build_paths
  return paths unless paths.empty?

  raise "File not found: #{data_dir}"
end