DEPRECATION NOTICE
This gem is deprecated and no longer maintained. The code now lives in
the relaton monogem — relaton/relaton
(RubyGems: relaton >= 3.0) — which
bundles every former relaton-* flavor gem. This repository is archived
and read-only; issues and pull requests are disabled.
How to do what this gem did, with relaton
Install once:
# Gemfile
gem "relaton", "~> 3.0"Fetch bibliographic data — one entry point routes to the right dataset automatically; you never pick a flavor:
require "relaton"
db = Relaton::Db.new(nil, nil) # (global_cache, local_cache)
item = db.fetch("ISO 8601-1", "2019")
# [relaton-iso] INFO: (ISO 8601-1:2019) Found: `ISO 8601-1:2019`
item.docidentifier.first.content # => "ISO 8601-1:2019"
db.fetch("IEC 60050-112:2020") # => routed to the IEC dataset
db.fetch("ITU-T G.711") # => routed to the ITU dataset
db.fetch("JIS Z 8301:2019") # => routed to the JIS datasetThe router recognises every former flavor (ISO, IEC, IEEE, ITU, IETF, BIPM, NIST, OGC, W3C, IHO, JIS, GB, UN, CEN, ETSI, 3GPP, OASIS, Calconnect, CCSDS, CIE, ECMA, DOI, ISBN, IANA, XSF, Plateau, OIML and the rest) — all registered automatically.
Transform what you fetched — every fetched item serializes:
item.to_xml # => "<bibitem id=\"ISO860112019\" type=\"standard\" …>"
item.to_yaml # => the YAML rendering of the itemRender citations in your citation style (ISO 690 and its variants —
author-date, APA, MLA, Chicago, LNCS, IEEE-SA, JIS en/ja) via
relaton-render, which ships in the monogem’s ecosystem:
require "relaton/render"
r = Relaton::Render::General.new(language: "en", style: "author-date")
r.render(item, embedded: true)
# => "INTERNATIONAL ORGANIZATION FOR STANDARDIZATION (ISO). <em>Date and time …</em>"
Relaton::Render::General.new(language: "en", style: "mla")
.render(item, embedded: true) # => the MLA formShipped styles: author-date (ISO 690), apa, chicago, mla, lncs, ieee-sa,
jis-en, jis-ja. Whole-references rendering: r.render_all(bib, type:
"author-date").
Your existing Relaton::Iso::Bibliography, Relaton::Iec::*,
Relaton::Db, Relaton::Bib::* calls resolve exactly as before — the
flavors moved into the monogem under the same paths. Per-flavor VERSION
constants are gone; use Relaton::VERSION. Any relaton-* ~> 1.x/2.x
pin becomes relaton ~> 3.0 — the monogem is the only line receiving
updates. relaton-bib and relaton-cli remain separate, maintained
gems.
- :
-
= 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
=> nilLogging
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).