Subject: [CODE4LIB] A few Ruby MARC announcements

From: Ross Singer <[email-masked]>
Date: Wed, 23 Sep 2009 22:51:32 -0400

Hi everybody,

Apologies for the crossposting.

I wanted to let people know that Ruby MARC 0.3.0 was just released as
a gem.  This version addresses the biggest complaint about Ruby MARC,
which was the fact that it could only parse MARCXML with REXML, Ruby's
native XML parser (which, if you've used it, you hate it).

Now you can use Nokogiri (http://nokogiri.rubyforge.org/) or, if
you're using JRuby, jrexml instead of REXML, if you want.

This release *shouldn't* break anything.

The rubyforge project is here:
http://rubyforge.org/projects/marc
The rdocs are here:
http://marc.rubyforge.org/
The source is here:
http://marc.rubyforge.org/svn/

To install:
sudo gem install marc

While I'm making MARC and Ruby related announcements, I'd like to
point out a project I released a couple of weeks ago that sits on top
of Ruby MARC, called enhanced-marc.  It's basically a domain specific
language for working with the MARC fixed fields and providing a set of
objects and methods to more easily parse what the record is
describing.

For example:

  require 'enhanced_marc'

  reader = MARC::Reader.new('marc.dat')

  records = []

  reader.each do | record |
    records << record
  end

  >> records[0].class
  => MARC::BookRecord

  >> records[0].is_conference?
  => false

  >> records[0].is_manuscript?
  => false

  # Send a boolean true if you want human readable forms, rather than
MARC codes.
  >> records[0].literary_form(true)
  => "Non-fiction"

  >> records[0].nature_of_contents(true)
  => ["Bibliography", "Catalog"]

  >> records[1].class
  => MARC::SoundRecord

  >> records[1].composition_form(true)
  => "Jazz"

  >> records[2].class
  => MARC::MapRecord

  >> records[2].projection(true)
  => ["Cylindrical", "Mercator"]

  >> records[2].relief(true)
  => ["Color"]

The enhanced-marc project is here:
http://github.com/rsinger/enhanced-marc

To install it:
  gem sources -a http://gems.github.com
  sudo gem install rsinger-enhanced_marc

Let me know if you have any problems or suggestions with either of these.

Thanks!
-Ross.

---

From: Ed Summers <[email-masked]>
Date: Thu, 24 Sep 2009 00:48:39 -0400

Nice work Ross! Users of rubymarc might like to see the performance
enhancements that motivated you to do the nokogiri integration:

  http://paste.lisp.org/display/87529

!!!

//Ed

On Wed, Sep 23, 2009 at 10:51 PM, Ross Singer <[email-masked]> wrote:
>  >> records[0].class
>  >> records[0].is_conference?
>  => false
>
>  >> records[0].is_manuscript?
>  => false
>
>  >> records[0].literary_form(true)
>  => "Non-fiction"
>
>  >> records[0].nature_of_contents(true)
>  >> records[1].class
>  >> records[1].composition_form(true)
>  => "Jazz"
>
>  >> records[2].class
>  => MARC::MapRecord
>
>  >> records[2].projection(true)
>  >> records[2].relief(true)
>  => ["Color"]
>

---

From: Ross Singer <[email-masked]>
Date: Thu, 24 Sep 2009 09:39:47 -0400

Thanks for pointing that out, Ed.  Since, of course, the only thing
worse than lies and damn lies are, as we know, statistics, let me give
some context here :)

These benchmarks were run on a 45MB marcxml document with a little
less than 17k records in it that I happened to have on my machine.

Hopefully that helps clear up the numbers a bit (although probably).

I can definitely say that process was not entirely scientific -- it
was run on my work machine, during work hours with other work-related
applications running.  But I ran them a couple of time each and they
are pretty representative of the average.

Thanks Ed (and also Kevin Clarke and Will Groppe) for making rubymarc
in the first place and thanks to Jonathan Rochkind and Bill Dueber for
helping flesh out how these pluggable parsers/serializers should work.

-Ross.