Module: ConfigParser

Defined in:
lib/arkana/config_parser.rb

Overview

The config parser is responsible for parsing user CLI arguments, reading the config file and returning a ‘Config` object.

Class Method Summary collapse

Class Method Details

.parse(arguments) ⇒ Config

Parses the config file defined by the user (if any), returning a Config object.

Returns:

  • (Config)

    the config parsed from the user’s options.



12
13
14
15
16
17
18
19
20
21
# File 'lib/arkana/config_parser.rb', line 12

def self.parse(arguments)
  yaml = YAML.load_file(arguments.config_filepath)
  config = Config.new(yaml)
  config.include_environments(arguments.include_environments)
  config.current_flavor = arguments.flavor
  config.current_lang = arguments.lang
  config.dotenv_filepath = arguments.dotenv_filepath
  UI.warn("Dotenv file was specified but couldn't be found at '#{config.dotenv_filepath}'") if config.dotenv_filepath && !File.exist?(config.dotenv_filepath)
  config
end