Sha256: 7d29b5ff7fbd21d7ce90e52bcf9d98c3da88199c6ff0f2c6adf675fda5ae25a2

Contents?: true

Size: 590 Bytes

Versions: 2

Compression:

Stored size: 590 Bytes

Contents

require 'yaml'

class ConfigBuilder::Loader::YAML

  # Load configuration from all files in a given directory
  #
  # @param dir_path [String]
  #
  # @return [Hash]
  def yamldir(dir_path)
    glob_path = File.join(dir_path, '*.{yml,yaml}')

    rv = {}
    Dir.glob(glob_path).each do |file|
      contents = ::YAML.load_file(file)
      rv.merge!(contents)
    end

    rv
  end

  # Load configuration from a file
  #
  # @param file_path [String]
  #
  # @return [Hash]
  def yamlfile(file_path)
    ::YAML.load_file(file_path)
  end

  ConfigBuilder::Loader.register(:yaml, self)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-config_builder-0.2.0 lib/config_builder/loader/yaml.rb
vagrant-config_builder-0.1.0 lib/config_builder/loader/yaml.rb