Relaton::Iana is a Ruby gem that implements the IsoBibliographicItem model.
You can use it to retrieve metadata of IANA Standards and access such metadata through the Realaton::Iana::ItemData object.
Installation
Add this line to your application’s Gemfile:
gem 'relaton-iana'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install relaton-iana
Usage
Search for a standard using keywords
require 'relaton/iana'
=> true
item = Relaton::Iana::Bibliography.get "IANA service-names-port-numbers"
[relaton-iana] INFO: (IANA service-names-port-numbers) Fetching from Relaton repository ...
[relaton-iana] INFO: (IANA service-names-port-numbers) Found: `IANA service-names-port-numbers`
=> #<Relaton::Iana::ItemData:0x0000000110a8ed80
...
XML serialization
item.to_xml
=> "<bibitem id="IANAservicenamesportnumbers" type="standard" schema-version="v1.5.6">
<fetched>2026-01-27</fetched>
<title language="en" script="Latn">Service Name and Transport Protocol Port Number Registry</title>
<uri type="self">https://www.iana.org/assignments/service-names-port-numbers</uri>
<docidentifier type="IANA" primary="true">IANA service-names-port-numbers</docidentifier>
...
</bibitem>"
Typed links
Each IANA document has src type source link.
item.source.first.type
=> "src"
item.source.first.content
=> "https://www.iana.org/assignments/service-names-port-numbers"
Create bibliographic item from XML
Relaton::Iana::Item.from_xml File.read('spec/fixtures/auto-response-parameters.xml')
=> #<Relaton::Iana::ItemData:0x0000000124776198
...
Create bibliographic item from YAML
Relaton::Iana::Item.from_yaml File.read('spec/fixtures/item.yaml')
=> #<Relaton::Iana::ItemData:0x0000000124e1c588
...
Fetch data
There is an IANA dataset https://github.com/ietf-ribose/iana-registries which can be converted into RelatonXML/BibXML/BibYAML formats.
The method Relaton::Iana::DataFetcher.fetch(output: "data", format: "yaml") converts 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,bibxml(defaultyaml).
Relaton::Iana::DataFetcher.fetch
Started at: 2021-11-19 13:32:05 +0100
Stopped at: 2021-11-19 13:34:40 +0100
Done in: 155 sec.
=> nil
This method uses GitHub search API to fetch the documents. The search API has a rate limitaion of 30 requests per minute for authenticated users and 10 requests per minute for unauthenticated users. Usually, the rate limit is not reached because the search API is used only for the file list fetching. But if you run the method multiple times in a short period, the rate limit may be reached. In this case, the method will wait until the rate limit is reset.
You can use a personal access token (PTA) to increase the rate limit. To do this, add your PTA to the GITHUB_TOKEN environment variable.
Logging
Relaton::Iana 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 update the index test fixture (used by tests), run rake spec:update_index. This downloads the latest index-v1.zip from the relaton-data-iana repository.
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/relaton/relaton_w3c.
License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).