Skip to content

relaton/relaton-itu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RelatonItu: retrieve ITU Standards for bibliographic use using the BibliographicItem model

Gem Version Build Status (macOS) Build Status (Windows) Build Status (Ubuntu) Code Climate Pull Requests Commits since latest

RelatonItu is a Ruby gem that implements the IsoBibliographicItem model.

Installation

Add this line to your application’s Gemfile:

gem 'relaton-bib'

And then execute:

$ bundle

Or install it yourself as:

$ gem install relaton-bib

Usage

Configuration

Configuration is optional. The available option is logger which is a Logger instance. By default, the logger is Logger.new($stderr) with Logger::WARN level. To change the logger level, use RelatonItu.configure block.

require 'relaton_itu'
=> true

RelatonItu.configure do |config|
  config.logger.level = Logger::DEBUG
end

Search for a standard using keywords

hit_collection = RelatonItu::ItuBibliography.search("ITU-T L.163")
=> <RelatonItu::HitCollection:0x007fbf5fb4ab60 @ref=ITU-T L.163 @fetched=false>

item = hit_collection[1].fetch
=> #<RelatonItu::ItuBibliographicItem:0x007fbf1fc89548
 ...

XML serialization

item.to_xml
=> "<bibitem id="ITU-TLSuppl.39" type="standard" schema-version="v1.2.1">
      <fetched>2022-12-05</fetched>
      <title type="title-intro" format="text/plain" language="en" script="Latn">ITU-T L.1470</title>
      ...
    </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.2.1">
      <fetched>2022-12-05</fetched>
      <title type="title-intro" format="text/plain" language="en" script="Latn">ITU-T L.1470</title>
      ...
      <ext schema-version="v1.0.0">
        <doctype>recommendation</doctype>
        ...
      </ext>
    </bibdata>"

Get document by code and year

RelatonItu::ItuBibliography.get("ITU-T L.163", "2018", {})
[relaton-itu] (ITU-T L.163) Fetching from www.itu.int ...
[relaton-itu] (ITU-T L.163) Found: `ITU-T L.163`
=> #<RelatonItu::ItuBibliographicItem:0x007fbf5f94b9b8
...

Get amendment

RelatonItu::ItuBibliography.get "ITU-T G.989.2/Amd 1"
[relaton-itu] (ITU-T G.989.2/Amd 1) Fetching from www.itu.int ...
[relaton-itu] (ITU-T G.989.2/Amd 1) Found: `ITU-T G.989.2/Amd 1`
=> #<RelatonItu::ItuBibliographicItem:0x007fe5409e5840
...

Get ITU-R documents

RelatonItu::ItuBibliography.get "ITU-R BO.600-1"
[relaton-itu] (ITU-R BO.600-1) Fetching from www.itu.int ...
[relaton-itu] (ITU-R BO.600-1) Found: `ITU-R BO.600-1`
=> #<RelatonItu::ItuBibliographicItem:0x00007fb0cf8a1308
...

Get ITU-R Radio Regulations (RR)

RelatonItu::ItuBibliography.get 'ITU-R RR (2020)'
[relaton-itu] (ITU-R RR) Fetching from www.itu.int ...
[relaton-itu] WARNING: Invalid doctype: `publication`
[relaton-itu] (ITU-R RR) Found: ITU-R RR
=> #<RelatonItu::ItuBibliographicItem:0x007fb4b55eb660
...

Each ITU document has src type link and optional obp and word link types.

item.link
=> [#<RelatonBib::TypedUri:0x00007f82d665f530 @content=#<Addressable::URI:0xc170 URI:https://www.itu.int/ITU-T/recommendations/rec.aspx?rec=13786&lang=en>, @type="src">,
 #<RelatonBib::TypedUri:0x00007f82d665f0f8 @content=#<Addressable::URI:0xc184 URI:https://www.itu.inthttp//handle.itu.int/11.1002/1000/13786-en?locatt=format:pdf&auth>, @type="obp">]

Create a bibliographic item from YAML

hash = YAML.load_file 'spec/examples/itu_bib_item.yml'
=> {"id"=>"ITU-T L.163 (11/2018)",
...

RelatonItu::ItuBibliographicItem.from_hash hash
=> #<RelatonItu::ItuBibliographicItem:0x007fd88ac02aa0
...

Fetch data

This gem uses the (https://extranet.itu.int/brdocsearch) dataset as a data source.

The method RelatonItu::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, bibxxml (default yaml).

RelatonItu::DataFetcher.fetch 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

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/metanorma/relaton-bib.

License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

About

Relaton-ITU: retrieve ITU Standards for bibliographic use using the Relaton BibliographicItem model

Resources

License

Stars

Watchers

Forks

Packages

No packages published