README.adoc
= RelatonOmg
image:https://img.shields.io/gem/v/relaton-omg.svg["Gem Version", link="https://rubygems.org/gems/relaton-omg"]
image:https://github.com/relaton/relaton-omg/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-omg/actions?workflow=macos"]
image:https://github.com/relaton/relaton-omg/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/relaton/relaton-omg/actions?workflow=windows"]
image:https://github.com/relaton/relaton-omg/workflows/ubuntu/badge.svg["Build Status (Ubuntu)", link="https://github.com/relaton/relaton-omg/actions?workflow=ubuntu"]
image:https://codeclimate.com/github/relaton/relaton-omg/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/relaton/relaton-omg"]
image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-omg.svg["Pull Requests", link="https://github.com/relaton/relaton-omg/pulls"]
image:https://img.shields.io/github/commits-since/relaton/relaton-omg/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-omg/releases"]
RelatonOmg is a Ruby gem that searches and fetches standards from https://www.omg.org[The Object Management Group (OMG)].
The standards scrape form https://www.omg.org/spec
== Installation
Add this line to your application's Gemfile:
[source,ruby]
----
gem 'relaton-omg'
----
And then execute:
$ bundle install
Or install it yourself as:
$ gem install relaton-omg
== Usage
=== Search document
Reference format is `OMG + {ACRONYM} + {VERSION}`
- `ACRONYM` is an acronym from the list of specs https://www.omg.org/spec/#all
- `VERSION` (optional) if omitted then the lastes version is fetched
[source,ruby]
----
require 'relaton_omg'
=> true
item = RelatonOmg::OmgBibliography.get 'OMG AMI4CCM 1.0'
[relaton-omg] (OMG AMI4CCM 1.0) Fetching from www.omg.org ...
[relaton-omg] (OMG AMI4CCM 1.0) Found: `AMI4CCM 1.0`
=> #<RelatonOmg::OmgBibliographicItem:0x000000010435a520
...
# Return nil if the document doesn't exist.
RelatonOmg::OmgBibliography.get 'OMG 1111'
[relaton-omg] (OMG 1111) Fetching from www.omg.org ...
[relaton-omg] (OMG 1111) Not found.
=> nil
----
=== Serialization
[source,ruby]
----
item.to_xml
=> "<bibitem id="AMI4CCM1.0" schema-version="v1.2.9">
<fetched>2022-12-05</fetched>
<title type="main" format="text/plain" language="en" script="Latn">Asynchronous Method Invocation for CCM</title>
<uri type="src">https://www.omg.org/spec/AMI4CCM/1.0/About-AMI4CCM</uri>
<uri type="pdf">https://www.omg.org/spec/AMI4CCM/1.0/PDF</uri>
<docidentifier type="OMG" primary="true">AMI4CCM 1.0</docidentifier>
...
</bibitem>"
----
=== Typed links
OMG documents may have `src` and `pdf` link types.
[source,ruby]
----
item.link
=> [#<RelatonBib::TypedUri:0x00007fa897a72208 @content=#<Addressable::URI:0x80c URI:https://www.omg.org/spec/AMI4CCM/1.0/About-AMI4CCM/>, @type="src">,
#<RelatonBib::TypedUri:0x00007fa897a71600 @content=#<Addressable::URI:0x820 URI:https://www.omg.org/spec/AMI4CCM/1.0/PDF>, @type="pdf">]
----
=== Create bibliographic item from XML
[source,ruby]
----
item = RelatonOmg::OmgBibliographicItem.from_xml 'spec/fixtures/omg_ami4ccm_1_0.xml'
=> #<RelatonOmg::OmgBibliographicItem:0x007fb351582e90
...
----
=== Create bibliographic item from Hash
[source,ruby]
----
hash = YAML.load_file 'spec/fixtures/omg_ami4ccm_1_0.yaml'
=> {"schema-version"=>"v1.2.9",
"id"=>"AMI4CCM1.0",
...
item = RelatonOmg::OmgBibliographicItem.from_hash hash
=> #<RelatonOmg::OmgBibliographicItem:0x007f85b0247ec0
...
----
=== Create bibliographic item from YAML
[source,ruby]
----
item = RelatonOmg::OmgBibliographicItem.from_yaml 'spec/fixtures/omg_ami4ccm_1_0.yaml'
=> #<RelatonOmg::OmgBibliographicItem:0x007f85a00f45d8
...
----
=== Logging
RelatonOmg uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
== Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/relaton/relaton-ietf.
== License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).