Some time ago I opened a couple of pull requests on ruby-marc on GitHub, but they seem to have gone unnoticed. I probably should have posted here at the time, but never got around to it until now. Hopefully someone can have a look at them and see if they could be included in the project.
The first pull request is labeled [”Use raise (not throw) for errors”].
It is mostly a simple search-and-replace where I’ve switched out `throw` statements for `raise SomeSuitableError`, to make the library more idiomatic and allow for easier error handling. (`throw` is a flow control statement in ruby, a glorified `goto` not intended for error handling). As far as I can tell, the ruby-marc library never catches any of the throws, so internally it shouldn’t make a difference. But maybe someone client code does (even if I find it unlikely), so this *might* be a change that should be made together with a major version bump.
The second pull request is [”Add iterator for raw records”].
I’m a bit more elaborate in the description of that one, but the short version is that it adds an instance method `Marc::Reader#each_raw` that allows for iterating over each unparsed MARC record, doing the decoding part ”manually”. This allows for handling errors in the decoding of each individual record, while errors in the `each` method breaks out of the loop without a reference to the record that caused the error. Now you can log which records caused errors. (I’ve added an example in the rdoc for the new method.)
I hope this can be useful to others as well, and that it might get included in the library so I can get back to use the official gem.
Daniel Sandbecker, Systems Librarian
University of Borås
E-mail: [log in to unmask]
Phone: +46 33 435 40 29