RelatonCalconnect is a Ruby gem that implements the IsoBibliographicItem model.

You can use it to retrieve metadata of Calconnect Standards from https://standards.calconnect.org, and access such metadata through the CcBibliographicItem object.

Installation

Add this line to your application’s Gemfile:

gem 'relaton-un'

And then execute:

$ bundle

Or install it yourself as:

$ gem install relaton-un

Usage

Search for a standard using keywords

require 'relaton_un'
=> true

hits = RelatonUn::UnBibliography.search("TRADE/CEFACT/2004/32")
=> <RelatonUn::HitCollection:0x007fc4e6ec2018 @ref=TRADE/CEFACT/2004/32 @fetched=false>

item = hits[0].fetch
=> #<RelatonUn::UnBibliographicItem:0x007fc4e6ac3138
...

XML serialization

item.to_xml
=> "<bibitem id="TRADE-CEFACT-2004-32" type="standard" schema-version="v1.2.1">
      <fetched>2022-12-05</fetched>
      ...
    </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-05</fetched>
      ...
      <ext schema-version="v1.0.0">
        <editorialgroup>
          <committee>Committee on Trade</committee>
          <committee>Centre for Trade Facilitation and Electronic Business</committee>
        </editorialgroup>
        ...
      </ext>
    </bibdata>"

Get code, and year

RelatonUn::UnBibliography.get "UN TRADE/CEFACT/2004/32"
[relaton-un] (UN TRADE/CEFACT/2004/32) Fetching from documents.un.org ...
[relaton-un] (UN TRADE/CEFACT/2004/32) Found: `TRADE/CEFACT/2004/32`
=> #<RelatonUn::UnBibliographicItem:0x007fdc5f1c3a20
...

UN documens may have pdf and word link types.

item.link
=> [#<RelatonBib::TypedUri:0x00007f81af368250
  @content=#<Addressable::URI:0x9ec URI:https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/pdf/G0430683.pdf?OpenElement>, @type="pdf">,
 #<RelatonBib::TypedUri:0x00007f81af3630e8 @content=#<Addressable::URI:0xa00 URI:https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/doc/G0430683.DOC?OpenElement>, @type="word">]

Create bibliographic item from XML

RelatonUn::XMLParser.from_xml File.read('spec/fixtures/un_bib.xml')
=> #<RelatonUn::UnBibliographicItem:0x007fdc5e7ab678
...

Create bibliographic item from YAML

hash = YAML.load_file 'spec/fixtures/un_bib.yaml'
=> {"id"=>"TRADE/CEFACT/2004/32",
...

bib_hash = RelatonUn::HashConverter.hash_to_bib hash
=> {:id=>"TRADE/CEFACT/2004/32",
...

RelatonUn::UnBibliographicItem.new **bib_hash
=> #<RelatonUn::UnBibliographicItem:0x007fdc5e061908
...

Logging

RelatonUn 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/calconnect/relaton_un.

License

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