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

RelatonIso is a Ruby gem that implements the IsoBibliographicItem model.

You can use it to retrieve metadata of ISO Standards from https://www.iso.org, and access such metadata through the IsoBibliographicItem object.

Installation

Add this line to your application’s Gemfile:

gem 'relaton-iso'

And then execute:

$ bundle

Or install it yourself as:

$ gem install relaton-iso

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

require 'relaton_iso'
=> true

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

Search for standards using keywords

hit_collection = RelatonIso::IsoBibliography.search("ISO 19115")
=> <RelatonIso::HitCollection:0x007fa5bc847038 @ref=19115 @fetched=false>

hit_collection.first
=> <RelatonIso::Hit:0x007f87e71ea9f8 @text="ISO 19115" @fetched="false" @fullIdentifier="" @title="">

item = hit_collection[2].fetch
=> #<RelatonIsoBib::IsoBibliographicItem:0x007fa5dca89510
...

item.docidentifier
=> [#<RelatonIso::DocumentIdentifier:0x0000000112a23a88
...

item.docidentifier.detect { |di| di.type == "URN" }.id
=> "urn:iso:std:iso:19115:-1:ed-1:stage-60.60:amd:2020:v2"

Fetch document by reference and year

item = RelatonIso::IsoBibliography.get "ISO 19115:2003"
[relaton-iso] (ISO 19115:2003) Fetching from iso.org ...
[relaton-iso] (ISO 19115:2003) Found: `ISO 19115:2003`
=> #<RelatonIsoBib::IsoBibliographicItem:0x00007f8c83429e30
...

item = RelatonIso::IsoBibliography.get "ISO 19115", "2003"
[relaton-iso] (ISO 19115:2003) Fetching from iso.org ...
[relaton-iso] (ISO 19115:2003) Found: `ISO 19115:2003`
=> #<RelatonIsoBib::IsoBibliographicItem:0x0000000112c9ca80
...

item.docidentifier[0].id
=> "ISO 19115:2003"

Fetch non-part document

item = RelatonIso::IsoBibliography.get "ISO 19115"
[relaton-iso] (ISO 19115) Fetching from iso.org ...
[relaton-iso] (ISO 19115) Found: `ISO 19115:2003`
=> #<RelatonIsoBib::IsoBibliographicItem:0x00007f8c830275a8
...

item.docidentifier[0].id
=> "ISO 19115"

Fetch a part document

item = RelatonIso::IsoBibliography.get "ISO 19115-1"
[relaton-iso] (ISO 19115-1) Fetching from iso.org ...
[relaton-iso] (ISO 19115-1) Found: `ISO 19115-1:2014`
=> #<RelatonIsoBib::IsoBibliographicItem:0x00007f8c83408af0
...

item.docidentifier[0].id
=> "ISO 19115-1"

Fetch all-parts document

item = RelatonIso::IsoBibliography.get "ISO 19115 (all parts)"
[relaton-iso] (ISO 19115) Fetching from iso.org ...
[relaton-iso] (ISO 19115) Found: `ISO 19115`
=> #<RelatonIsoBib::IsoBibliographicItem:0x00007f8ca216e118
...

item = RelatonIso::IsoBibliography.get "ISO 19115", nil, all_parts: true
[relaton-iso] (ISO 19115) Fetching from iso.org ...
[relaton-iso] (ISO 19115) Found: `ISO 19115`
=> #<RelatonIsoBib::IsoBibliographicItem:0x00007f8c830f3d38
...

item.docidentifier[0].id
=> "ISO 19115 (all parts)"

item = RelatonIso::IsoBibliography.get "ISO 19115-1 (all parts)"
[relaton-iso] (ISO 19115) Fetching from iso.org ...
[relaton-iso] (ISO 19115) Found: `ISO 19115`
=> #<RelatonIsoBib::IsoBibliographicItem:0x00007f8c8290e5a0

item = RelatonIso::IsoBibliography.get "ISO 19115-1", nil, all_parts: true
[relaton-iso] (ISO 19115) Fetching from iso.org ...
[relaton-iso] (ISO 19115) Found: `ISO 19115`
=> #<RelatonIsoBib::IsoBibliographicItem:0x00007f8c925355b8
...

item.docidentifier[0].id
=> "ISO 19115 (all parts)"

Search for ISO/IEC Directives

The ISO/IEC Directives are stored in a static cache in a relaton gem. It needs to use the relaton gem to fetch the ISO/IEC Directives. The following references are allowed to fetch:

  • ISO/IEC DIR 1 - Procedures for the technical work

  • ISO/IEC DIR 1 IEC SUP - Procedures for the technical work – Procedures specific to IEC

  • ISO/IEC DIR 1 ISO SUP - Consolidated ISO Supplement — Procedures specific to ISO

  • ISO/IEC DIR 2 IEC - Principles and rules for the structure and drafting of ISO and IEC documents

  • ISO/IEC DIR 2 ISO - Principles and rules for the structure and drafting of ISO and IEC documents

  • ISO/IEC DIR IEC SUP - Procedures specific to IEC

  • ISO/IEC DIR JTC 1 SUP - Procedures specific to JTC 1

XML serialization

Possible options:

  • bibdata - If true then wrapp item with bibdata element and add ext element.

  • note - Array of hashes { text: "Note", type: "note" }. These notes will be added to XML.

item.to_xml
=> "<bibitem id="ISO19115-1-2014" type="standard" schema-version="v1.2.1">
      <fetched>2022-12-04</fetched>
      <title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
      <title type="title-main" format="text/plain" language="en" script="Latn">Metadata</title>
      ...
    </bibitem>"

item.to_xml bibdata: true
=> "<bibdata type="standard" schema-version="v1.2.1">
      <fetched>2022-12-04</fetched>
      <title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
      ...
      <ext schema-version="v1.0.0">
        <doctype>international-standard</doctype>
        ...
      </ext>
    </bibdata>"

item.to_xml note: [{ text: "Note", type: "note" }]
=> "<bibitem id="ISO19115-1-2014" type="standard" schema-version="v1.2.1">
      ...
      <note format="text/plain" type="note">Note</note>
      ...
    </bibitem>"

Get specific language

item.title lang: 'en'
=> #<RelatonBib::TypedTitleStringCollection:0x0000000112783fd0
 @array=
  [#<RelatonBib::TypedTitleString:0x00000001138e2380
    @title=#<RelatonBib::FormattedString:0x0000000112d496b8 @content="Geographic information", @format="text/plain", @language=["en"], @script=["Latn"]>,
    @type="title-intro">,
   #<RelatonBib::TypedTitleString:0x00000001138e1f70
    @title=#<RelatonBib::FormattedString:0x0000000112d495c8 @content="Metadata", @format="text/plain", @language=["en"], @script=["Latn"]>,
    @type="title-main">,
   #<RelatonBib::TypedTitleString:0x00000001138e1d68
    @title=
     #<RelatonBib::FormattedString:0x0000000112d49488 @content="Geographic information – Metadata", @format="text/plain", @language=["en"], @script=["Latn"]>,
    @type="main">]>

item.title lang: 'fr'
=> #<RelatonBib::TypedTitleStringCollection:0x0000000113067458
 @array=
  [#<RelatonBib::TypedTitleString:0x00000001138e1c28
    @title=#<RelatonBib::FormattedString:0x0000000112d49438 @content="Information géographique", @format="text/plain", @language=["fr"], @script=["Latn"]>,
    @type="title-intro">,
   #<RelatonBib::TypedTitleString:0x00000001138e1b10
    @title=#<RelatonBib::FormattedString:0x0000000112d49398 @content="Métadonnées", @format="text/plain", @language=["fr"], @script=["Latn"]>,
    @type="title-main">,
   #<RelatonBib::TypedTitleString:0x00000001138e1908
    @title=
     #<RelatonBib::FormattedString:0x0000000112d491b8
      @content="Information géographique – Métadonnées",
      @format="text/plain",
      @language=["fr"],
      @script=["Latn"]>,
    @type="main">]>

item = RelatonIso::IsoBibliography.get "ISO 19115:2003"
[relaton-iso] (ISO 19115:2003) Fetching from iso.org ...
[relaton-iso] (ISO 19115:2003) Found: `ISO 19115:2003`
=> #<RelatonIsoBib::IsoBibliographicItem:0x00007fa8870b69e0

item.abstract lang: 'en'
=> #<RelatonBib::FormattedString:0x00007fa8870b4f78
 @content=
  "ISO 19115:2003 defines the schema required for describing geographic information ...",
 @format="text/plain",
 @language=["en"],
 @script=["Latn"]>

Each ISO document has src type link and optional obp, rss, and pub link types.

item.link
=> [#<RelatonBib::TypedUri:0x0000000112d66c40
  @content=#<Addressable::URI:0x93d71c URI:https://www.iso.org/standard/26020.html>,
  @language=nil,
  @script=nil,
  @type="src">,
 #<RelatonBib::TypedUri:0x0000000112d66920
  @content=#<Addressable::URI:0x93d730 URI:https://www.iso.org/contents/data/standard/02/60/26020.detail.rss>,
  @language=nil,
  @script=nil,
  @type="rss">]

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

Exceptional Citations

This gem retrieves bibliographic descriptions of ISO documents by doing searches on the ISO website, http://www.iso.org, and screenscraping the document that matches the queried document identifier. The following documents are not returned as search results from the ISO website, and the gem returns manually generated references to them.

  • IEV: used in the metanorma-iso gem to reference Electropedia entries generically. Is resolved to an "all parts" reference to IEC 60050, which in turn is resolved into the specific documents cited by their top-level clause.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/metanorma/relaton-iso

License

The gem is available as open source under the terms of the MIT license.