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
pry(main)> require 'relaton_iho'
=> true
item = RelatonIho::IhoBibliography.search("B-11")
[relaton-iho] ("B-11") fetching...
[relaton-iho] ("B-11") found B-11
=> #<RelatonIho::IhoBibliographicItem:0x007fe74fc80800
...
XML serialization
item.to_xml
=> "<bibitem id="B-11" type="standard">
<fetched>2020-03-29</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">B-11</docidentifier>
...
</bibitem>"
With argument bibdata: true it ouputs XML wrapped by bibdata element and adds flavour ext element.
item.to_xml bibdata: true
=> "<bibdata type="standard">
<fetched>2020-03-29</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">B-11</docidentifier>
...
<ext>
<editorialgroup>
<committee>
<name>Hydrographic Services and Standards Committee</name>
<abbreviation>HSSC</abbreviation>
</committee>
<committee>
<name>Inter-Regional Coordination Committee</name>
<abbreviation>IRCC</abbreviation>
<committee>
<name>JOINT IHO-IOC GUIDING COMMITTEE FOR THE GENERAL BATHYMETRIC CHART OF THE OCEANS</name>
<abbreviation>GEBCO</abbreviation>
</committee>
</committee>
</editorialgroup>
</ext>
</bibdata>"
Get code
RelatonIho::IhoBibliography.get "IHO B-11"
[relaton-iho] ("IHO B-11") fetching...
[relaton-iho] ("IHO B-11") found B-11
=> #<RelatonIho::IhoBibliographicItem:0x007fe78dbb7c78
...
Typed links
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
...
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.