Project

relaton-un

0.01
The project is in a healthy, maintained state
RelatonIso: retrieve CC Standards for bibliographic use using the IsoBibliographicItem model
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2.7.0
~> 1.0.5
>= 0.0.7.7
~> 1.18.0
~> 2.8.0
 Project Readme

Relaton for UN documents

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

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 RelatonUn.configure block.

require 'relaton_un'
=> true

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

Search for a standard using keywords

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
...

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).