Class: Kibutsu::FixtureLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/kibutsu/fixture_loader.rb

Overview

Loads fixtures from files, optionally with ERB pre-processing and creates Fixture objects from them.

Instance Method Summary collapse

Constructor Details

#initialize(fixture_file_path, database_connection) ⇒ FixtureLoader

Returns a new instance of FixtureLoader.



11
12
13
14
# File 'lib/kibutsu/fixture_loader.rb', line 11

def initialize(fixture_file_path, database_connection)
  @fixture_file_path = fixture_file_path
  @database_connection = database_connection
end

Instance Method Details

#load_fixture_tablesObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/kibutsu/fixture_loader.rb', line 16

def load_fixture_tables
  file_content = File.read(fixture_file_path)
  yaml_content = if fixture_file_path.end_with? '.yml.erb'
                   run_erb(file_content)
                 else
                   file_content
                 end
  fixtures_hash = load_fixture(yaml_content)
  build_fixture_tables(fixtures_hash)
end