private Method

Fixture.read_fixture_file(fixture_file_path)

There's no documentation for this item.

Source Code

# File active_record/fixtures.rb, line 813
def read_fixture_file(fixture_file_path)
  IO.readlines(fixture_file_path).inject({}) do |fixture, line|
    # Mercifully skip empty lines.
    next if line =~ /^\s*$/

    # Use the same regular expression for attributes as Active Record.
    unless md = /^\s*([a-zA-Z][-_\w]*)\s*=>\s*(.+)\s*$/.match(line)
      raise FormatError, "#{fixture_file_path}: fixture format error at '#{line}'.  Expecting 'key => value'."
    end
    key, value = md.captures

    # Disallow duplicate keys to catch typos.
    raise FormatError, "#{fixture_file_path}: duplicate '#{key}' in fixture." if fixture[key]
    fixture[key] = value.strip
    fixture
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.