Class: DataDepo::YAMLLoader

Inherits:
Loader
  • Object
show all
Defined in:
lib/data_depo/yaml_loader.rb

Instance Attribute Summary

Attributes inherited from Loader

#paths

Instance Method Summary collapse

Methods inherited from Loader

#initialize

Constructor Details

This class inherits a constructor from DataDepo::Loader

Instance Method Details

#filesObject



13
14
15
16
17
18
19
20
21
22
23
# 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

#loadObject



7
8
9
10
11
# File 'lib/data_depo/yaml_loader.rb', line 7

def load
  files.each.inject([]) {|a, file|
    load_file_into_array(file, a); a
  }
end