Module: CukeLinter::Configuration

Included in:
CukeLinter
Defined in:
lib/cuke_linter/configuration.rb

Overview

Mix-in module containing methods related to configuring linters

Instance Method Summary collapse

Instance Method Details

#load_configuration(config_file_path: nil, config: nil) ⇒ Object

Configures linters based on the given options



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cuke_linter/configuration.rb', line 7

def load_configuration(config_file_path: nil, config: nil)
  # TODO: define what happens if both a configuration file and a configuration are
  # provided. Merge them or have direct config take precedence? Both?

  unless config || config_file_path
    config_file_path = "#{Dir.pwd}/.cuke_linter"
    message          = 'No configuration or configuration file given and no .cuke_linter file found'
    raise message unless File.exist?(config_file_path)
  end

  config ||= YAML.load_file(config_file_path)
  configure_linters(config, registered_linters)
end