NAME

Geo::Coder::Free::Config - Site-independent configuration file for the Versatile Web Framework

VERSION

Version 0.42

SUBROUTINES/METHODS

new

Creates a new Geo::Coder::Free::Config instance with hierarchical configuration loading.

Takes four optional arguments: info (CGI::Info object) logger config_directory - used when the configuration directory can't be worked out config_file - name of the configuration file - otherwise determined dynamically config (ref to hash of values to override in the config file

Values in the file are overridden by what's in the environment

Parameters:

  • info - CGI::Info object (optional, created if not provided)

  • logger - Logger object with debug() method (optional)

  • config_directory - Additional config directory path (optional)

  • config_file - Specific config filename (optional)

  • config - Hash ref of override values (optional)

Configuration Resolution Order: 1. Base configuration files 2. Values from config parameter 3. Environment variable overrides

Directory Search Order: 1. $ENV{CONFIG_DIR} (if set) 2. Provided config_directory 3. ../conf relative to script 4. ../../conf relative to script 5. $DOCUMENT_ROOT/../lib/conf 6. $HOME/lib/conf

Returns: Blessed Geo::Coder::Free::Config object

Throws: Error::Simple on configuration errors

FORMAL SPECIFICATION

[STRING, HASH, LOGGER]

ConfigState ::= ⟨⟨ config_dirs : ℙ STRING;
                  config_data : HASH;
                  logger : LOGGER ⟩⟩

ConfigArgs ::= ⟨⟨ info : CGI_Info;
                 logger : LOGGER;
                 config_directory : STRING;
                 config_file : STRING;
                 config : HASH ⟩⟩

Init : ConfigArgs → ConfigState

∀ params : ConfigArgs •
  let dirs == if env.CONFIG_DIR ≠ ∅
              then {env.CONFIG_DIR}
              else default_dirs ∪ {params.config_directory} fi •
  let valid_dirs == {d : dirs | ∃ f : FILE • readable(d, f)} •
  valid_dirs ≠ ∅ ∧
  config_data ∈ HASH ∧
  config_data = merge(file_config, params.config, env_overrides)

ValidConfigKey == {k : STRING | k ∈ dom config_data}

GetConfigValue : ValidConfigKey → (STRING ∪ HASH ∪ ARRAY)