Class: DataTaster::Confection

Inherits:
Object
  • Object
show all
Defined in:
lib/data_taster/confection.rb

Overview

Ingests the list of data_taster_export_tables.yml files and processes them through an erb template returns a ruby hash of the data

Instance Method Summary collapse

Instance Method Details

#assembleObject



13
14
15
16
17
# File 'lib/data_taster/confection.rb', line 13

def assemble
  DataTaster.config.list.each_with_object(default_data) do |path, merged_list|
    merged_list.merge!(load_yml(path.to_s))
  end
end

#load_yml(filename) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/data_taster/confection.rb', line 19

def load_yml(filename)
  return {} unless File.exist?(filename)

  erb = ::ERB.new(File.read(filename))
  erb.filename = filename
  flavored_erb = erb.def_class(DataTaster::Flavors, "render()")
  erb_result = flavored_erb.new.render

  YAML.safe_load(erb_result.gsub(/((.|\n)*---)/, "\n---")) || {}
end