Skip to content

RelatonIso: ISO Standards metadata using the BibliographicItem model

License

Notifications You must be signed in to change notification settings

relaton/relaton-iso

RelatonIso: retrieve ISO Standards for bibliographic use using the BibliographicItem model

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

Search for standards using keywords

require 'relaton_iso'
=> true

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

Non-standard ISO/IEC documents

General

ISO/IEC Directives and related documents are fetched from the relaton-data-iso repository managed by the Relaton team.

The following PubID patterns are used to fetch particular documents.

ISO/IEC Directives in Parts

ISO/IEC DIR 1 ISO SUP

ISO/IEC Directives, Consolidated ISO Supplement — Procedures specific to ISO. This is the undated reference.

ISO/IEC DIR 1 ISO SUP:{yyyy}

Available edition years from 2003 (ed1) to 2023 (ed14).

ISO/IEC DIR 1

ISO/IEC Directives, Part 1. This is the undated reference.

ISO/IEC DIR 1 ISO

ISO-published version of "ISO/IEC Directives, Part 1".

ISO/IEC DIR 1 ISO:{yyyy}

Edition years from 1986 (ed1) to 2023 (ed19).

ISO/IEC DIR 1 IEC

IEC-published version of "ISO/IEC Directives, Part 1"

ISO/IEC DIR 1 IEC:{yyyy}

Edition years from 1986 (ed1) to 2023 (ed19).

ISO/IEC DIR 2

ISO/IEC Directives, Part 2. This is the undated reference.

ISO/IEC DIR 2 ISO

ISO-published version of "ISO/IEC Directives, Part 2"

ISO/IEC DIR 2 ISO:{yyyy}

Edition years from 1986 (ed1) to 2021 (ed9).

ISO/IEC DIR 2 IEC

IEC-published version of "ISO/IEC Directives, Part 2"

ISO/IEC DIR 2 IEC:{yyyy}

Edition years from 1986 (ed1) to 2021 (ed9).

ISO/IEC DIR 3

ISO/IEC Directives, Part 3. This is the undated reference. This is of historical interest, as originally ISO/IEC published the Directives in 3 parts: Part 1 "Procedures for the technical work", Part 2 "Methodology for the development of International Standards", Part 3 "Drafting and presentation of International Standards". In the 2004 versions, Parts 1 and 2 merged into the new Part 1, and Part 3 was renamed as Part 2.

ISO/IEC DIR 3:{yyyy}

Edition years: 1986 (ed1), 1989 (ed2), 1997 (ed3).

ISO/IEC DIR 1 ISO SUP

ISO/IEC Directives, Consolidated ISO Supplement — Procedures specific to ISO. This is the undated reference.

ISO/IEC DIR 1 ISO SUP:{yyyy}

Available edition years from 2003 (ed1) to 2023 (ed14).

ISO/IEC DIR IEC SUP

ISO/IEC Directives, IEC Supplement — Procedures specific to IEC. This is the undated reference.

ISO/IEC DIR IEC SUP:{yyyy}

Available edition years from 2009 (ed4) to 2023 (ed17).

ISO/IEC DIR 1 + IEC SUP

The consolidated version of "ISO/IEC Directives, Part 1 + IEC Supplement — Procedures specific to IEC". This is the undated reference.

ISO/IEC DIR 1 + IEC SUP:{yyyy}

Available edition years from 2016 (ed12) to 2023 (ed19).

ISO/IEC JTC 1 governance documents

ISO/IEC JTC 1 DIR

ISO/IEC JTC 1 Directives. This is the undated reference. Notice that these are "internal directives" of ISO/IEC JTC 1. This series existed until 2007, after which it became "ISO/IEC Directives — JTC 1 Supplement".

ISO/IEC JTC 1 DIR:{yyyy}

Available edition years are: 2004 (5th Edition), 2005 (5th Edition, Version 1.0), 2006 (5th Edition, Version 2.0), 2007 (5th Edition, Version 3.0).

ISO/IEC DIR JTC 1

ISO/IEC Directives, JTC 1 Supplement — Procedures specific to JTC 1. This is the undated reference.

ISO/IEC DIR JTC 1:{yyyy}

Available edition years from 2010 (ed1) to 2023 (ed12).

ISO/TC 184/SC 4 important N-documents

ISO/TC 184/SC 4 N2412

ISO/TC 184/SC 4 Supplementary directives - Rules for the structure and drafting of SC 4 standards for industrial data. 2008-12-16.

ISO/TC 184/SC 4 N2412

ISO/TC 184/SC 4 Supplementary directives - Rules for the structure and drafting of SC 4 standards for industrial data. 2020-07-31.

ISO/TC 184/SC 4 N3500

ISO/TC 184/SC 4 Handbook — SC 4 Supplement to ISO directives. 2020-08-09.

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.3">
        <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">]

Logging

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

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.