ruby-marc/ruby-marc — pull request #18 by jrochkind (2013-08-29 17:44:03+00:00)
Title: Doc, spec, and fix how MARC::Writer handles too-long records

In Master, a too-long record written with Marc::Writer winds up
putting all 6 bytes in a space in leader that's supposed to be 5 bytes,
messing up the whole leader, and making the entire record unreadable
by likely most any marc reader.

(I was wrong before, when I thought that it output a record with
truncated length/offset values, that would still be readable
by various forgiving marc readers on various platforms).

Obviously that is a completely corrupt record.

## New tested and doc'd behavior

In this branch, instead, there are two options: allow_oversized records or not.

In strict mode (not allow_oversized), an exception is raised if the marc
record is too long to be serialized in iso 2709 binary.

In allow_oversized mode, if a length/offsets that
takes up too many bytes is encountered, it is written out as "00000" --
obviously impossible, but the right number of digits, to not
make the marc record completely unintelligible.

The MARC::ForgivingReader could ALREADY read
this kind of record, with no changes -- although there were no tests for this,
there are now.

I _think_ Marc4J reader in permissive mode can also read this kind fo record, and maybe
even the python marc record -- I investigated this a couple years ago,
but could be wrong in my memory.

## Default behavior?

Question on what the default behavior should be.

Currently, if you use a Writer to write out a too long record, it does NOT raise, but
writes out a completley unintelligible record.

New beahvior will be two choices: 1) Raise, 2) Write out a record which, while
illegal, is still readable by ForgivingReader.

Which should be default? If we didn't have to care about
backwards compat? For real, where we might have to care about
backwards compat?

I lean toward NOT raising being default, since current behavior does not
raise. That is what this branch does.