Sha256: 0aad18fa20565e32a8505259848b948911159a0ce44d4f9aa311a67ed4bfc6ad

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

require 'logger'

module CLIUtils
  # Configuration Module
  # Manages any configuration values and the flat YAML file
  # into which they get stored.
  module Configuration
    extend self

    # Allows easy access to Logger levels.
    LOG_LEVELS = {
      'DEBUG' => Logger::DEBUG,
      'INFO'  => Logger::INFO,
      'WARN'  => Logger::WARN,
      'ERROR' => Logger::ERROR,
      'FATAL' => Logger::FATAL
    }

    @@configuration = nil

    # Singleton method to return (or initialize, if needed)
    # a Configurator.
    # @return [Configurator]
    def configuration
      if @@configuration
        @@configuration
      else
        fail 'Attempted to access `configuration` before ' \
        'executing `load_configuration`'
      end
    end

    # Singleton method to return (or initialize, if needed)
    # a Configurator.
    # @param [String] path The filepath to use
    # @return [void]
    def load_configuration(path)
      @@configuration = Configurator.new(path)
    end
    alias_method :filepath=, :load_configuration
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cliutils-2.2.6 lib/cliutils/configuration.rb
cliutils-2.2.5 lib/cliutils/configuration.rb
cliutils-2.2.4 lib/cliutils/configuration.rb
cliutils-2.2.3 lib/cliutils/configuration.rb
cliutils-2.2.2 lib/cliutils/configuration.rb
cliutils-2.2.1 lib/cliutils/configuration.rb