Class: SimpleNavigation::ConfigFileFinder

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

Overview

Internal: Encapsulates the configuration file finding logic.

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ ConfigFileFinder

Internal: Initializes a ConfigFileFinder.

paths - an enumerable list of paths in which to look for configuration

files.


10
11
12
# File 'lib/simple_navigation/config_file_finder.rb', line 10

def initialize(paths)
  @paths = paths
end

Instance Method Details

#find(context) ⇒ Object

Internal: Searches a configuration file for the given context in the initialization paths.

context - The navigation context for which to look the configuration file.

Returns a String representing the full path of the configuation file. Raises StandardError if no file is found.



21
22
23
24
25
26
27
# File 'lib/simple_navigation/config_file_finder.rb', line 21

def find(context)
  config_file_name = config_file_name_for_context(context)

  find_config_file(config_file_name) ||
  fail("Config file '#{config_file_name}' not found in " \
       "path(s) #{paths.join(', ')}!")
end