Class: Gitnesse::ConfigLoader

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

Class Method Summary collapse

Class Method Details

.find_and_loadObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gitnesse/config_loader.rb', line 3

def self.find_and_load
  files = Dir.glob(File.join("**", "gitnesse.rb"))

  files = reject_irrelevant_files files

  files_with_config = files.select do |file_name|
    file_content = File.read(file_name)
    file_content.match("Gitnesse::Config.config do")
  end

  case files_with_config.length
  when 0
    raise_error "Can't find a gitnesse.rb file with Gitnesse configuration."
  when 1
    load(File.absolute_path(files_with_config.first))
  else
    raise_error "Multiple configuration files found:", files_with_config
  end
end