Fork me on GitHub

BibTeX-Ruby

BibTeX-Ruby is a fairly complete library and parser for BibTeX bibliography files; it offers an interface to manage, search, or convert BibTeX objects in Ruby. It is designed to support all BibTeX objects (including @comment, string-replacements via @string, as well as string concatenation using '#') and handles all content outside of BibTeX objects as 'meta content' which may or may not be included in post-processing. BibTeX-Ruby also includes a name parser to support comfortable access to the individual tokens of name values.

Quickstart

$ [sudo] gem install bibtex-ruby
$ irb
>> require 'bibtex'
=> true

>> b = BibTeX.open('./ruby.bib')
>> b[:pickaxe]
=> "2009"
>> b[:pickaxe].title
=> "Programming Ruby 1.9: The Pragmatic Programmer's Guide"
>> b[:pickaxe].author.length
=> 3
>> b[:pickaxe].author.to_s
=> "Thomas, Dave and Fowler, Chad and Hunt, Andy"

>> b[:pickaxe].author[2].first
=> "Andy"
>> b['@book'].length
=> 3
>> b['@article'].length
=> 0
>> b['@book[year=2009]'].length
=> 1
				

Installation

If you just want to use it:

$ [sudo] gem install bibtex-ruby
				

If you want to work with the sources:

$ git clone http://github.com/inukshuk/bibtex-ruby.git
$ cd bibtex-ruby
$ [sudo] bundle install
$ rake racc
$ rake rdoc
$ rake features
$ rake test
				

For extra credit, fork the project on GitHub.