Class: BuildpackSupport::ConfigurationUtils
- Inherits:
-
Object
- Object
- BuildpackSupport::ConfigurationUtils
- Includes:
- DirectoryFinder
- Defined in:
- lib/buildpack_support/configuration_utils.rb
Overview
Utilities for dealing with Configuration files
Instance Method Summary collapse
-
#initialize(should_log = true) ⇒ ConfigurationUtils
constructor
Creates a new instance.
-
#load(identifier) ⇒ Hash
Loads a configuration file from the buildpack configuration directory.
Methods included from DirectoryFinder
Constructor Details
#initialize(should_log = true) ⇒ ConfigurationUtils
Creates a new instance
32 33 34 35 |
# File 'lib/buildpack_support/configuration_utils.rb', line 32 def initialize(should_log = true) @config_directory = load_path_peer 'config' @logger = BuildpackSupport::Logging::LoggerFactory.instance.get_logger ConfigurationUtils if should_log end |
Instance Method Details
#load(identifier) ⇒ Hash
Loads a configuration file from the buildpack configuration directory. If the configuration file does not exist, returns an empty hash.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/buildpack_support/configuration_utils.rb', line 42 def load(identifier) file = @config_directory + "#{identifier}.yml" configuration = {} if file.exist? configuration = YAML.load_file(file) @logger.debug { "Configuration from #{file}: #{configuration}" } if @logger else @logger.debug { "No configuration file #{file} found" } if @logger end configuration end |