Class: SengiriYaml::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/sengiri_yaml/loader.rb

Instance Method Summary collapse

Instance Method Details

#load_dir(src_dir, permitted_classes: [], aliases: false) ⇒ Hash

load divided yaml files

Parameters:

  • src_dir (String)

    divided yaml dir

Returns:

  • (Hash)

    merged yaml hash



9
10
11
12
13
14
15
16
17
18
# File 'lib/sengiri_yaml/loader.rb', line 9

def load_dir(src_dir, permitted_classes: [], aliases: false)
  merged_content = ""

  Pathname.glob("#{src_dir}/*.yml").sort.each do |yaml_path|
    content = yaml_path.read.gsub(/^---$/, "")
    merged_content << content
  end

  YAML.safe_load(merged_content, permitted_classes: permitted_classes, aliases: aliases)
end