0.0
The project is in a healthy, maintained state
RelatonIsbn: retrieve publications by ISBN for bibliographic use using the BibliographicItem model
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.18.0
 Project Readme

Relaton-ISBN: retrieves bibliographic items using OpenLibrary API

Gem Version Build Status (macOS) Build Status (Windows) Build Status (Ubuntu) Code Climate Pull Requests Commits since latest

RelatonIsbn is a Ruby gem that implements the IsoBibliographicItem model.

You can use it to retrieve metadata of Standards from https://openlibrary.org, and access such metadata through the BibliographicItem object.

Installation

Add this line to your application’s Gemfile:

gem 'relaton-isbn'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install relaton-isbn

Usage

Configuration

Configuration is optional. The available option is logger which is a Logger instance. By default, the logger is Logger.new($stderr) with Logger::WARN level. To change the logger level, use RelatonIsbn.configure block.

require 'relaton_isbn'
=> true

RelatonIsbn.configure do |config|
  config.logger.level = Logger::DEBUG
end

Retrieving bibliographic items using OpenLibrary API

To retrieve bibliographic items, use RelatonIsbn::OpenLibrary.get method with ISBN-10 or ISBN-13 as an argument. Allowed prefixes are ISBN, isbn:. Prefix and hyphens are optional. The method returns RelatonBib::BibliographicItem object.

# get document by ISBN-13
> ibitem = RelatonIsbn::OpenLibrary.get "ISBN 978-0-12-064481-0"
[relaton-isbn] (ISBN 9780120644810) Fetching from OpenLibrary ...
[relaton-isbn] (ISBN 9780120644810) Found: `9780120644810`
=> #<RelatonBib::BibliographicItem:0x0000000113889258
...

# get document by ISBN-10
> RelatonIsbn::OpenLibrary.get "isbn:0120644819"
[relaton-isbn] (isbn:0120644819) Fetching from OpenLibrary ...
[relaton-isbn] (isbn:0120644819) Found: `9780120644810`
=> #<RelatonBib::BibliographicItem:0x00000001098ac960
...

Serializing bibliographic items

# serialize to XML
> puts bibitem.to_xml
<bibitem id="9780120644810" schema-version="v1.2.7">
  <title type="main" format="text/plain">Graphics gems II</title>
  <uri type="src">http://openlibrary.org/books/OL21119585M/Graphics_gems_II</uri>
  <docidentifier type="ISBN" primary="true">9780120644810</docidentifier>
  <date type="published">
    <on>1991</on>
  </date>
  <contributor>
    <role type="author"/>
    <person>
      <name>
        <completename>James Arvo</completename>
      </name>
    </person>
  </contributor>
  <contributor>
    <role type="publisher"/>
    <organization>
      <name>AP Professional</name>
    </organization>
  </contributor>
  <place>
    <city>Boston</city>
  </place>
  <place>
    <city>London</city>
  </place>
</bibitem>

# serialize to bibdata XML
> puts bibitem.to_xml bibdata: true
<bibdata schema-version="v1.2.7">
  <title type="main" format="text/plain">Graphics gems II</title>
  ...

# serialize to hash
> bibitem.to_hash
=> {"schema-version"=>"v1.2.7",
 "id"=>"9780120644810",
 "title"=>[{"content"=>"Graphics gems II", "format"=>"text/plain", "type"=>"main"}],
 "link"=>[{"content"=>"http://openlibrary.org/books/OL21119585M/Graphics_gems_II", "type"=>"src"}],
 "docid"=>[{"id"=>"9780120644810", "type"=>"ISBN", "primary"=>true}],
 "date"=>[{"type"=>"published", "value"=>"1991"}],
 "contributor"=>
  [{"person"=>{"name"=>{"completename"=>{"content"=>"James Arvo"}}, "url"=>"http://openlibrary.org/authors/OL2646519A/James_Arvo"}, "role"=>[{"type"=>"author"}]},
   {"organization"=>{"name"=>[{"content"=>"AP Professional"}]}, "role"=>[{"type"=>"publisher"}]}],
 "revdate"=>"1991",
 "place"=>[{"city"=>"Boston"}, {"city"=>"London"}]}

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/relaton/relaton-isbn.

License

The gem is available as open source under the terms of the MIT License.