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-calconnect'

And then execute:

$ bundle

Or install it yourself as:

$ gem install relaton-calconnect

Usage

Search for a standard using keywords

require 'relaton_calconnect'
=> true

hits = RelatonCalconnect::CcBibliography.search("CC/DIR 10005:2019")
=> <RelatonCalconnect::HitCollection:0x007f98e34a8bb0 @ref=CC/DIR 10005:2019 @fetched=false>

item = hits[0].fetch
=> #<RelatonCalconnect::CcBibliographicItem:0x007f9a766b15d0
...

XML serialization

item.to_xml
=> "<bibitem id="CC-DIR10005-2019" type="standard" schema-version="v1.2.1">
      <title format="text/plain" language="en">Guidelines for the implementation of the CalConnect patent policy</title>
      <uri type="xml">https://standards.calconnect.org/csd/cc-10005.xml</uri>
      <uri type="pdf">https://standards.calconnect.org/csd/cc-10005.pdf</uri>
      ...
    </bibitem>"

With argument bibdata: true it outputs XML wrapped by bibdata element and adds flavour ext element.

item.to_xml bibdata: true
=> "<bibdata type="standard" schema-version="v1.2.1">
      <title format="text/plain" language="en">Guidelines for the implementation of the CalConnect patent policy</title>
      <uri type="xml">https://standards.calconnect.org/csd/cc-10005.xml</uri>
      ...
      <ext schema-version="v1.0.0">
        <doctype>directive</doctype>
        <editorialgroup>
          <committee>PUBLISH</committee>
        </editorialgroup>
      </ext>
    </bibdata>"

Each Calconnect document has link types:

  • xml - XML format

  • pdf - PDF format

  • doc - Microsoft Word document format

  • html - HTML format

  • rxl - RelatonXML format

item.link
=> [#<RelatonBib::TypedUri:0x00007ff2d4b009e0 @content=#<Addressable::URI:0x668 URI:https://standards.calconnect.org/csd/cc-10005.xml>, @type="xml">,
 #<RelatonBib::TypedUri:0x00007ff2d4b00378 @content=#<Addressable::URI:0x67c URI:https://standards.calconnect.org/csd/cc-10005.pdf>, @type="pdf">,
 #<RelatonBib::TypedUri:0x00007ff2d4b00058 @content=#<Addressable::URI:0x690 URI:https://standards.calconnect.org/csd/cc-10005.doc>, @type="doc">,
 #<RelatonBib::TypedUri:0x00007ff2d4b23d28 @content=#<Addressable::URI:0x6a4 URI:https://standards.calconnect.org/csd/cc-10005.html>, @type="html">,
 #<RelatonBib::TypedUri:0x00007ff2d4b23a08 @content=#<Addressable::URI:0x6b8 URI:https://standards.calconnect.org/csd/cc-10005.rxl>, @type="rxl">]

Get document by code and year

RelatonCalconnect::CcBibliography.get "CC/DIR 10005", "2019", {}
[relaton-calconnect] (CC/DIR 10005) Fetching from Relaton repository ...
[relaton-calconnect] (CC/DIR 10005) Found: `CC/DIR 10005:2019`
=> #<RelatonCalconnect::CcBibliographicItem:0x007f9a73dfa290
...

Create bibliographic item from XML

RelatonCalconnect::XMLParser.from_xml File.read('spec/fixtures/cc_dir_10005_2019.xml')
=> #<RelatonCalconnect::CcBibliographicItem:0x007f9a7423dde8
...

Create bibliographic item from YAML

hash = YAML.load_file 'spec/fixtures/cc_dir_10005_2019.yml'
=> {"id"=>"CC/DIR10005-2019",
...

RelatonCalconnect::CcBibliographicItem.from_hash hash
=> #<RelatonCalconnect::CcBibliographicItem:0x007fc5a0109f88
...

Fetch data

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

RelatonCalconnect::DataFetcher.fetch
Started at: 2021-09-09 16:03:51 +0200
Stopped at: 2021-09-09 16:04:12 +0200
Done in: 20 sec.
=> nil

Logging

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

License

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