Sha256: aac8a6dc3c3305221dc4eb780b98331c0eb423fadb4f2ca99b09b06a7b75a522
Contents?: true
Size: 971 Bytes
Versions: 6
Compression:
Stored size: 971 Bytes
Contents
require 'yaml' require 'deep_merge/core' class ConfigBuilder::Loader::YAML # Load configuration from YAML files in one or more directories # # @overload yamldir(path) # @param path [String] A directory path containing YAML files # @overload yamldir(paths) # @param paths [Array<String>] A list of directory paths containing YAML files # # @return [Hash] def yamldir(input) dirs = Array(input) files = dirs.map do |dir| pattern = File.join(dir, '*.{yml,yaml}') Dir.glob(pattern) end.flatten rv = {} files.each do |file| contents = ::YAML.load_file(file) if contents.is_a? Hash rv = DeepMerge::deep_merge!(contents, rv, {:preserve_unmergables => false}) end 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
6 entries across 6 versions & 1 rubygems