RelatonItu is a Ruby gem that implements the IsoBibliographicItem model.
Installation
Add this line to your application’s Gemfile:
gem 'relaton-itu'
And then execute:
$ bundle
Or install it yourself as:
$ gem install relaton-itu
Usage
Search for a standard using keywords
require 'relaton/itu'
=> true
hit_collection = Relaton::Itu::Bibliography.search("ITU-T L.163")
=> <Relaton::Itu::HitCollection:0x00000000001700 @ref=ITU-T L.163 @fetched=false>
item = hit_collection[1].item
=> #<Relaton::Itu::ItemData:0x000000012541b8f8
...
XML serialization
item.to_xml
=> "<bibitem id="ITUTLSuppl39092020" type="standard" schema-version="v1.4.1">
<fetched>2026-02-24</fetched>
<title language="en" script="Latn" type="title-intro">ITU-T L.1470</title>
<title language="en" script="Latn" type="title-main">Optical fibre cable Recommendations and standardization guideline</title>
<title language="en" script="Latn" type="main">ITU-T L.1470 - Optical fibre cable Recommendations and standardization guideline</title>
<uri type="src">https://handle.itu.int/11.1002/1000/14547</uri>
<uri type="pdf">https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-L.Sup39-202009-I!!PDF-E&type=items</uri>
<docidentifier type="ITU" primary="true">ITU-T L Suppl. 39 (09/2020)</docidentifier>
...
</bibitem>"
With bibdata: true option XML output is wrapped with bibdata element and ext element added.
item.to_xml bibdata: true
=> "<bibdata type="standard" schema-version="v1.4.1">
<fetched>2026-02-24</fetched>
<title language="en" script="Latn" type="title-intro">ITU-T L.1470</title>
<title language="en" script="Latn" type="title-main">Optical fibre cable Recommendations and standardization guideline</title>
<title language="en" script="Latn" type="main">ITU-T L.1470 - Optical fibre cable Recommendations and standardization guideline</title>
<uri type="src">https://handle.itu.int/11.1002/1000/14547</uri>
<uri type="pdf">https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-L.Sup39-202009-I!!PDF-E&type=items</uri>
<docidentifier type="ITU" primary="true">ITU-T L Suppl. 39 (09/2020)</docidentifier>
...
<ext schema-version="v1.0.2">
<doctype>recommendation</doctype>
<flavor>itu</flavor>
</ext>
</bibdata>"
Get document by code and year
Relaton::Itu::Bibliography.get("ITU-T L.163", "2018", {})
[relaton-itu] INFO: (ITU-T L.163 (2018)) Fetching from www.itu.int ...
[relaton-itu] INFO: (ITU-T L.163 (2018)) Found: `ITU-T L.163 (11/2018)`
=> #<Relaton::Itu::ItemData:0x000000010f92a288
...
Get amendment
Relaton::Itu::Bibliography.get "ITU-T G.989.2 (2019)/Amd 1"
[relaton-itu] INFO: (ITU-T G.989.2 (2019)) Fetching from www.itu.int ...
[relaton-itu] INFO: (ITU-T G.989.2 (2019)) Found: `ITU-T G.989.2 (02/2019)`
=> #<Relaton::Itu::ItemData:0x000000010fa4f3c0
...
Get ITU-R documents
Relaton::Itu::Bibliography.get "ITU-R BO.600-1"
[relaton-itu] INFO: (ITU-R BO.600-1) Fetching from Relaton repository ...
[relaton-itu] INFO: (ITU-R BO.600-1) Found: `ITU-R BO.600-1`
=> #<Relaton::Itu::ItemData:0x000000010fa4a3c0
...
Get ITU-R Radio Regulations (RR)
Relaton::Itu::Bibliography.get 'ITU-R RR (2020)'
[relaton-itu] INFO: (ITU-R RR (2020)) Fetching from www.itu.int ...
[relaton-itu] INFO: (ITU-R RR (2020)) Found: `ITU-R RR (2020)`
=> #<Relaton::Itu::ItemData:0x000000010fa41e00
...
Typed source links
Each ITU document has src type link and optional obp and word link types.
item.source[0].type
=> "src"
item.source[0].content
=> "https://handle.itu.int/11.1002/1000/14547"
Create a bibliographic item from XML
item = Relaton::Itu::Item.from_xml File.read("spec/fixtures/bibdata.xml")
=> #<Relaton::Itu::ItemData:0x000000010fa28ea0
...
Create a bibliographic item from YAML
item = Relaton::Itu::Item.from_yaml File.read("spec/fixtures/item.yaml")
=> #<Relaton::Itu::ItemData:0x000000010f9848a0
...
Fetch data
This gem uses the https://extranet.itu.int/brdocsearch dataset as a data source.
The method Relaton::Itu::DataFetcher.fetch("itu-r", output: "data", format: "yaml") fetches all the documents from the dataset and saves them to the ./data folder in YAML format.
Arguments:
-
source- source name (itu-r). -
output- folder to save documents (defaultdata). -
format- the format in which the documents are saved. Possible formats are:yaml,xml,bibxxml(defaultyaml).
Relaton::Itu::DataFetcher.fetch "itu-r", output: "dir", format: "xml"
Started at: 2023-05-27 09:21:16 -0400
Stopped at: 2023-05-27 09:27:45 -0400
Done in: 390 sec.
=> nil
Logging
RelatonItu 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/relaton/relaton-itu.
License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).