GithubHelp home page GithubHelp logo

daniels / ruby-marc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ruby-marc/ruby-marc

0.0 2.0 0.0 839 KB

A Ruby library to parse, create and manage MARC records

Home Page: http://marc.rubyforge.org/

License: MIT License

Ruby 100.00%

ruby-marc's Introduction

Gem Version Build Status

marc is a ruby library for reading and writing MAchine Readable Cataloging (MARC). More information about MARC can be found at http://www.loc.gov/marc.

Usage

require 'marc'

# reading records from a batch file
reader = MARC::Reader.new('marc.dat', :external_encoding => "MARC-8")
for record in reader
  # print out field 245 subfield a
  puts record['245']['a']
end

# creating a record 
record = MARC::Record.new()
record.append(MARC::DataField.new('100', '0',  ' ', ['a', 'John Doe']))

# writing a record
writer = MARC::Writer.new('marc.dat')
writer.write(record)
writer.close()

# writing a record as XML
writer = MARC::XMLWriter.new('marc.xml')
writer.write(record)
writer.close()

# encoding a record
MARC::Writer.encode(record) # or record.to_marc

MARC::Record provides #to_hash and #from_hash implementations that deal in ruby hash's that are compatible with the marc-in-json serialization format. You are responsible for serializing the hash to/from JSON yourself.

Installation

gem install marc

Or if you're using bundler, add to your Gemfile

gem 'marc'

Character Encodings in 'binary' ISO-2709 MARC

The Marc binary (ISO 2709) Reader (MARC::Reader) has some features for helping you deal with character encodings in ruby 1.9. It is always recommended to supply an explicit :external_encoding option to MARC::Reader; either any valid ruby encoding, or the string "MARC-8". MARC-8 input will by default be transcoded to a UTF-8 internal representation.

MARC::Reader does not currently have any facilities for guessing encoding from MARC21 leader byte 9, that is ignored.

Consult the MARC::Reader class docs for a more complete discussion and range of options.

The MARC binary Writer (MARC::Writer) does not have any encoding-related features -- it's up to you the developer to make sure you create MARC::Records with consistent and expected char encodings, although MARC::Writer will write out a legal ISO 2709 either way, it just might have corrupted encodings.

Miscellany

Source code at: https://github.com/ruby-marc/ruby-marc/

Find generated API docs at: http://rubydoc.info/gems/marc/frames

Run automated tests in source with rake test.

Developers, release new version of gem to rubygems with rake release (bundler-supplied task). Note that one nice thing this will do is automatically tag the version in git, very important for later figuring out what's going on.

Please send bugs, requests and comments to Code4Lib Mailing list (https://listserv.nd.edu/cgi-bin/wa?A0=CODE4LIB).

Authors

Kevin Clarke [email protected] Bill Dueber [email protected] William Groppe [email protected] Ross Singer [email protected] Ed Summers [email protected]

ruby-marc's People

Contributors

billdueber avatar boutros avatar daniels avatar edsu avatar eocarragain avatar jrochkind avatar rsinger avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.