RelatonOgc is a Ruby gem that implements the IsoBibliographicItem model.
You can use it to retrieve metadata of OGC Standards from https://raw.githubusercontent.com/opengeospatial/NamingAuthority/master/incubation/bibliography/bibliography.json, and access such metadata through the OgcBibliographicItem
object.
Installation
Add this line to your application’s Gemfile:
gem 'relaton_ogc'
And then execute:
$ bundle
Or install it yourself as:
$ gem install relaton_ogc
Usage
Search for a standard using keywords
hits = RelatonOgc::OgcBibliography.search("OGC 19-025r1")
=> [<RelatonOgc::Hit:0x007fcab6b9aab8 @text="OGC 19-025r1" @fetched="false" @fullIdentifier="" @title="">]
tem = hits[0].fetch
=> #<RelatonOgc::OgcBibliographicItem:0x007fcab3cb4758
...
XML serialization
item.to_xml
=> "<bibitem id="19-025r1" type="standard">
<title type="title-main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
<title type="main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
<uri type="obp">https://portal.opengeospatial.org/files/?artifact_id=88037</uri>
<docidentifier type="OGC">19-025r1</docidentifier>
<date type="published">
<on>2019</on>
</date>
...
</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">
<title type="title-main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
<title type="main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
<uri type="obp">https://portal.opengeospatial.org/files/?artifact_id=88037</uri>
<docidentifier type="OGC">19-025r1</docidentifier>
<date type="published\">
<on>2019</on>
</date>
...
<ext>
<doctype>public-engineering-report</doctype>
</ext>
</bibdata>"
Get code, and year
RelatonOgc::OgcBibliography.get "OGC 19-025r1", "2019", {}
fetching OGC 19-025r1...
=> #<RelatonOgc::OgcBibliographicItem:0x007fc322e9aba0
...
Create bibliographic item from XML
RelatonOgc::XMLParser.from_xml File.read('spec/fixtures/ogc_bib_item.xml')
=> #<RelatonOgc::OgcBibliographicItem:0x007fc322ea82c8
...
Create bibliographic item from YAML
hash = YAML.load_file 'spec/fixtures/ogc_bib_item.yml'
=> {"id"=>"19-025r1",
...
bib_hash = RelatonOgc::HashConverter.hash_to_bib hash
=> {:id=>"19-025r1",
...
RelatonOgc::OgcBibliographicItem.new bib_hash
=> #<RelatonOgc::OgcBibliographicItem: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](https://rubygems.org).
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/calconnenct/relaton_ogc.
License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).