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
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">
<title type="main" format="text/plain" language="en" script="Latn">SECRETARIAT REVIEW OF UN/LOCODE, 19 DECEMBER 2003 / SUBMITTED BY THE SECRETARIAT</title>
<uri type="pdf">https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/pdf/G0430683.pdf?OpenElement</uri>
<uri type="word">https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/doc/G0430683.DOC?OpenElement</uri>
<docidentifier type="UN">TRADE/CEFACT/2004/32</docidentifier>
<docnumber>TRADE/CEFACT/2004/32</docnumber>
...
</bibitem>"
With argument bibdata: true
it ouputs XML wrapped by bibdata
element and adds flavour ext
element.
item.to_xml bibdata: true
=> "<bibdata type="standard">
<fetched>2020-03-13</fetched>
<title type="main" format="text/plain" language="en" script="Latn">SECRETARIAT REVIEW OF UN/LOCODE, 19 DECEMBER 2003 / SUBMITTED BY THE SECRETARIAT</title>
<uri type="pdf">https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/pdf/G0430683.pdf?OpenElement</uri>
<uri type="word">https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/doc/G0430683.DOC?OpenElement</uri>
<docidentifier type="UN">TRADE/CEFACT/2004/32</docidentifier>
<docnumber>TRADE/CEFACT/2004/32</docnumber>
...
<ext>
<editorialgroup>
<committee>Committee on Trade</committee>
<committee>Centre for Trade Facilitation and Electronic Business</committee>
</editorialgroup>
<distribution>general</distribution>
<session>
<number>10</number>
<agenda-id>12</agenda-id>
</session>
<job_number>G0430683</job_number>
</ext>
</bibdata>"
Get code, and year
RelatonUn::UnBibliography.get "UN TRADE/CEFACT/2004/32"
[relaton-un] ("UN TRADE/CEFACT/2004/32") fetching...
[relaton-un] ("UN TRADE/CEFACT/2004/32") found TRADE/CEFACT/2004/32
=> #<RelatonUn::UnBibliographicItem:0x007fdc5f1c3a20
...
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).