class DataDepo::YAMLLoader

Public Instance Methods

files() click to toggle source
# File lib/data_depo/yaml_loader.rb, line 13
def files
  @paths.each.inject([]) do |a, path|
    Dir.glob(File.join(path, '**', '*.yml')) {|file|
      a << file
    } if File.directory?(path)

    filename = path + '.yml'
    a << filename if File.file?(filename)
    a
  end
end
load() click to toggle source
# File lib/data_depo/yaml_loader.rb, line 7
def load
  files.each.inject([]) {|a, file|
    load_file_into_array(file, a); a
  }
end

Private Instance Methods

load_file_into_array(file, array) click to toggle source
# File lib/data_depo/yaml_loader.rb, line 26
def load_file_into_array(file, array)
  yaml = YAML.load_file(file)
  if yaml.is_a? Array
    array.concat(yaml)
  else
    array << yaml
  end
end