lib/cliutils/configuration.rb in cliutils-2.1.1 vs lib/cliutils/configuration.rb in cliutils-2.1.2
- old
+ new
@@ -1,7 +1,6 @@
require 'logger'
-require 'yaml'
module CLIUtils
# Configuration Module
# Manages any configuration values and the flat YAML file
# into which they get stored.
@@ -13,10 +12,12 @@
'WARN' => Logger::WARN,
'ERROR' => Logger::ERROR,
'FATAL' => Logger::FATAL
}
+ @@configuration = nil
+
# Hook that triggers when this module is included.
# @param [Object] k The includer object
# @return [void]
def self.included(k)
k.extend(self)
@@ -24,10 +25,15 @@
# Singleton method to return (or initialize, if needed)
# a Configurator.
# @return [Configurator]
def configuration
- @@configuration ||= Configurator.new('~/.default-cliutils')
+ if !@@configuration.nil?
+ @@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