Sha256: 7012294919de43ca1bcb3cba43706b241852f64ce5d4b38793241b1a223af8b6

Contents?: true

Size: 1.02 KB

Versions: 16

Compression:

Stored size: 1.02 KB

Contents

require 'logger'
require 'yaml'

module CLIUtils
  # Configuration Module
  # Manages any configuration values and the flat YAML file
  # into which they get stored.
  module Configuration
    # Allows easy access to Logger levels.
    LOG_LEVELS = {
      'DEBUG' => Logger::DEBUG,
      'INFO'  => Logger::INFO,
      'WARN'  => Logger::WARN,
      'ERROR' => Logger::ERROR,
      'FATAL' => Logger::FATAL
    }

    # Hook that triggers when this module is included.
    # @param [Object] k The includer object
    # @return [void]
    def self.included(k)
      k.extend(self)
    end

    # Singleton method to return (or initialize, if needed)
    # a Configurator.
    # @return [Configurator]
    def configuration
      @@configuration ||= Configurator.new('~/.default-cliutils')
    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
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cliutils-2.1.1 lib/cliutils/configuration.rb
cliutils-2.1.0 lib/cliutils/configuration.rb
cliutils-2.0.3 lib/cliutils/configuration.rb
cliutils-2.0.2 lib/cliutils/configuration.rb
cliutils-2.0.1 lib/cliutils/configuration.rb
cliutils-2.0.0 lib/cliutils/configuration.rb
cliutils-1.4.2 lib/cliutils/configuration.rb
cliutils-1.4.1 lib/cliutils/configuration.rb
cliutils-1.4.0 lib/cliutils/configuration.rb
cliutils-1.3.1 lib/cliutils/configuration.rb
cliutils-1.3.0 lib/cliutils/configuration.rb
cliutils-1.2.9 lib/cliutils/configuration.rb
cliutils-1.2.8 lib/cliutils/configuration.rb
cliutils-1.2.7 lib/cliutils/configuration.rb
cliutils-1.2.6 lib/cliutils/configuration.rb
cliutils-1.2.5 lib/cliutils/configuration.rb