Class: ConfigBuilder::Loader::YAML
- Inherits:
-
Object
- Object
- ConfigBuilder::Loader::YAML
- Defined in:
- lib/config_builder/loader/yaml.rb
Instance Method Summary collapse
-
#yamldir(dir_path) ⇒ Hash
Load configuration from all files in a given directory.
-
#yamlfile(file_path) ⇒ Hash
Load configuration from a file.
Instance Method Details
#yamldir(dir_path) ⇒ Hash
Load configuration from all files in a given directory
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/config_builder/loader/yaml.rb', line 10 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) if contents.is_a? Hash rv.merge! contents else # TODO warn on non-hash YAML end end rv end |
#yamlfile(file_path) ⇒ Hash
Load configuration from a file
32 33 34 |
# File 'lib/config_builder/loader/yaml.rb', line 32 def yamlfile(file_path) ::YAML.load_file(file_path) end |