0.01
The project is in a healthy, maintained state
RelatonIho: retrieve IHO Standards for bibliographic 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

>= 0
~> 1.19.0
 Project Readme

Relaton for IHO documents

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

RelatonIho is a Ruby gem that implements the IsoBibliographicItem model.

It currently retrieves metadata of IHO Standards from https://github.com/relaton/relaton-data-iho.

Installation

Add this line to your application’s Gemfile:

gem 'relaton-iho'

And then execute:

$ bundle

Or install it yourself as:

$ gem install relaton-iho

Usage

Search for a standard using keywords

Reference can be specified with or without an edition. References without an edition will return the latest edition of the standard. References with an edition will return the standard with the specified edition.

require 'relaton_iho'
=> true

# Search for a standard using a reference without an edition
item = RelatonIho::IhoBibliography.search("IHO B-11")
[relaton-iho] (IHO B-11) Fetching from Relaton repository ...
[relaton-iho] (IHO B-11) Found: `B-11`
=> #<RelatonIho::IhoBibliographicItem:0x007fe74fc80800
...

# Search for a standard using a reference with an edition
item = RelatonIho::IhoBibliography.search("IHO B-11 1.0.0")
[relaton-iho] (IHO B-11 1.0.0) Fetchint from Rlaont repository ...
[relaton-iho] (IHO B-11 1.0.0) Found: `B-11`
=> #<RelatonIho::IhoBibliographicItem:0x00007fe79d0ed698
...

XML serialization

item.to_xml
=> "<bibitem id="B-11" type="standard" schema-version="v1.2.1">
      <fetched>2022-12-04</fetched>
      <title type="main" format="text/plain" language="en">IHO-IOC GEBCO Cook Book</title>
      <title type="main" format="text/plain" language="fr">Livre de recettes GEBCO OHI-COI</title>
      <uri type="pdf">https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf</uri>
      <docidentifier type="IHO" primary="true">B-11</docidentifier>
      ...
    </bibitem>"

With argument bibdata: true it outputs XML wrapped by bibdata element and adds flavor ext element.

item.to_xml bibdata: true
=> "<bibdata type="standard" schema-version="v1.2.1">
      <fetched>2022-12-04</fetched>
      <title type="main" format="text/plain" language="en">IHO-IOC GEBCO Cook Book</title>
      <title type="main" format="text/plain" language="fr">Livre de recettes GEBCO OHI-COI</title>
      <uri type="pdf">https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf</uri>
      <docidentifier type="IHO" primary="true">B-11</docidentifier
      ...
      <ext schema-version="v1.0.0">
        ...
      </ext>
    </bibdata>"

Get code

RelatonIho::IhoBibliography.get "IHO B-11"
[relaton-iho] (IHO B-11) Fetching from Relaton repository ...
[relaton-iho] (IHO B-11) Found: `B-11`
=> #<RelatonIho::IhoBibliographicItem:0x007fe78dbb7c78
...

Each IHO document has html, website, or pdf type link.

item.link
=> [#<RelatonBib::TypedUri:0x00007fb5162d1478 @content=#<Addressable::URI:0x8c0 URI:https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf>, @type="pdf">]

Create bibliographic item from XML

RelatonIho::XMLParser.from_xml File.read('spec/fixtures/iho.xml')
=> #<RelatonIho::IhoBibliographicItem:0x007fc322ea82c8
...

Create bibliographic item from YAML

hash = YAML.load_file 'spec/fixtures/iho.yaml'
=> {"id"=>"B-11",
...

RelatonIho::IhoBibliographicItem.from_hash hash
=> #<RelatonIho::IhoBibliographicItem:0x007fc322ef8548
...

Logging

RelatonIho uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the relaton-logger documentation.

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 tags, and push the .gem file to rubygems.org.

Contributing

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

License

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