Module: Bucky::Utils::YamlLoad

Included in:
Core::TestCore::TestCaseLoader, TestEquipment::PageObject::BasePageObject, Tools::Lint, Config
Defined in:
lib/bucky/utils/yaml_load.rb

Instance Method Summary collapse

Instance Method Details

#file_sort_hierarchy(path) ⇒ Array

Sort files to hierarchy

Parameters:

  • path (String)

    of directory

Returns:

  • (Array)

    sorted files



19
20
21
# File 'lib/bucky/utils/yaml_load.rb', line 19

def file_sort_hierarchy(path)
  Dir.glob(path).sort_by { |f| f.split('/').size }
end

#load_yaml(file) ⇒ Hash

Load yaml(include erb)

Parameters:

  • yaml (File)

    file

Returns:

  • (Hash)

    hashed yaml contents



12
13
14
# File 'lib/bucky/utils/yaml_load.rb', line 12

def load_yaml(file)
  YAML.safe_load(ERB.new(File.read(file)).result, [Array, Hash, String, Numeric, Symbol, TrueClass, FalseClass], [], true)
end