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

Relaton::Iho 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 = Relaton::Iho::Bibliography.search("IHO B-11")
[relaton-iho] INFO: (IHO B-11) Fetching from Relaton repository ...
[relaton-iho] INFO: (IHO B-11) Found: `B-11`
=> #<Relaton::Iho::ItemData:0x0000000121f85aa8...

# Search for a standard using a reference with an edition
item = Relaton::Iho::Bibliography.search("IHO B-11 1.0.0")
[relaton-iho] INFO: (IHO B-11 1.0.0) Fetching from Relaton repository ...
[relaton-iho] INFO: (IHO B-11 1.0.0) Found: `B-11`
=> #<Relaton::Iho::ItemData:0x0000000125b5bb90
...

XML serialization

item.to_xml
=> "<bibitem id="B11" type="standard" schema-version="v1.4.1">
      <fetched>2026-02-20</fetched>
      <title language="en" type="main">IHO-IOC GEBCO Cook Book</title>
      <title language="fr" type="main">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.4.1">
      <fetched>2026-02-20</fetched>
      <title language="en" type="main">IHO-IOC GEBCO Cook Book</title>
      <title language="fr" type="main">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">
        <flavor>iho</flavor>
      </ext>
    </bibdata>"

Get code

Relaton::Iho::Bibliography.get "IHO B-11"
[relaton-iho] INFO: (IHO B-11) Fetching from Relaton repository ...
[relaton-iho] INFO: (IHO B-11) Found: `B-11`
=> #<Relaton::Iho::ItemData:0x0000000125f530e0
...

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

item.source.first.type
=> "pdf"

item.source.first.content
=> "https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf"

Create bibliographic item from XML

Relaton::Iho::Item.from_xml File.read('spec/fixtures/bibdata.xml')
=> #<Relaton::Iho::ItemData:0x0000000125f56920
...

Create bibliographic item from YAML

Relaton::Iho::Item.from_yaml File.read('spec/fixtures/item.yaml')
=> #<Relaton::Iho::ItemData:0x000000012274ac98
...

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 update the index test fixture (used by tests), run rake spec:update_index. This downloads the latest index-v1.zip from the relaton-data-iho repository.

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.