RelatonOgc
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
require 'relaton_ogc'
=> true
hits = RelatonOgc::OgcBibliography.search("OGC 19-025r1")
=> <RelatonOgc::HitCollection:0x007fcc8e085ba8 @ref=OGC 19-025r1 @fetched=true>
item = hits[0].fetch
=> #<RelatonOgc::OgcBibliographicItem:0x007fcab3cb4758
...
XML serialization
item.to_xml
=> "<bibitem id="19-025r1" type="standard" schema-version="v1.2.1">
<fetched>2022-12-04</fetched>
<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.ogc.org/files/?artifact_id=88037</uri>
<docidentifier type="OGC" primary="true">19-025r1</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="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.ogc.org/files/?artifact_id=88037</uri>
<docidentifier type="OGC" primary="true">19-025r1</docidentifier>
...
<ext schema-version="v1.0.1">
<doctype>engineering-report</doctype>
<editorialgroup>
<committee>technical</committee>
</editorialgroup>
</ext>
</bibdata>"
Get code, and year
RelatonOgc::OgcBibliography.get "OGC 19-025r1", "2019", {}
[relaton-ogc] (OGC 19-025r1) Fetching from Relaton repository ...
[relaton-ogc] (OGC 19-025r1) Found: `19-025r1`
=> #<RelatonOgc::OgcBibliographicItem:0x007fc322e9aba0
...
Create bibliographic item from XML
RelatonOgc::XMLParser.from_xml File.read('spec/fixtures/12_128r14.xml')
=> #<RelatonOgc::OgcBibliographicItem:0x00007fd2b1078718
...
Typed links
Each OGC document has obp
type link.
item.link
=> [#<RelatonBib::TypedUri:0x00007fc848994568 @content=#<Addressable::URI:0x8e8 URI:https://portal.ogc.org/files/?artifact_id=88037>, @type="obp">]
Create bibliographic item from YAML
hash = YAML.load_file 'spec/fixtures/ogc_bib_item.yml'
=> {"id"=>"19-025r1",
...
RelatonOgc::OgcBibliographicItem.from_hash hash
=> #<RelatonOgc::OgcBibliographicItem:0x007fc322ef8548
...
Fetch data
This gem uses the https://raw.githubusercontent.com/opengeospatial/NamingAuthority/master/incubation/bibliography/bibliography.json dataset as a data source.
The method RelatonOgc::DataFetcher.fetch(output: "data", format: "yaml")
fetches all the documents from the dataset and saves them to the ./data
folder in YAML format.
Arguments:
-
output
- folder to save documents (default './data'). -
format
- the format in which the documents are saved. Possible formats are:yaml
,xml
(defaultyaml
).
RelatonOgc::DataFetcher.fetch
Started at: 2021-09-14 11:21:46 +0200
[relaton-ogc] WARNING Duplicated documents: 15-113r5, 08-094r1, 10-025r1, 12-128r14, 16-079, 16-007r3, 13-026r8, 12-128r12, 15-078r6, 12-176r7, 09-102r3, 14-095, 14-115, 07-147r2, 12-000, 12-006, 09-025r1, 07-036, 07-110r4, 03-105r1, 06-042, 07-165r1, 12-066, 06-104r4, 11-122r1, 09-000, 04-094, 07-006r1, 06-035r1, 03-006r3, 05-134, 04-021r3, 02-058, 01-009
Stopped at: 2021-09-14 11:21:48 +0200
=> nil
Logging
RelatonOgc 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](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).