relaton / relaton-bipm

MIT License
2 stars 0 forks source link

= RelatonBipm: retrieve BIPM Standards for bibliographic use using the BibliographicItem model

image:https://img.shields.io/gem/v/relaton-bipm.svg["Gem Version", link="https://rubygems.org/gems/relaton-bipm"] image:https://github.com/relaton/relaton-bipm/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-bipm/actions?workflow=macos"] image:https://github.com/relaton/relaton-bipm/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/relaton/relaton-bipm/actions?workflow=windows"] image:https://github.com/relaton/relaton-bipm/workflows/ubuntu/badge.svg["Build Status (Ubuntu)", link="https://github.com/relaton/relaton-bipm/actions?workflow=ubuntu"] image:https://codeclimate.com/github/relaton/relaton-bipm/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/relaton/relaton-bipm"] image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-bipm.svg["Pull Requests", link="https://github.com/relaton/relaton-bipm/pulls"] image:https://img.shields.io/github/commits-since/relaton/relaton-bipm/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-bipm/releases"]

RelatonBipm is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].

You can use it to retrieve metadata of BIPM Standards from https://www.bipm.org, and access such metadata through the BipmBibliographicItem object.

== Installation

Add this line to your application's Gemfile:

[source,ruby]

gem 'relaton-bipm'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install relaton-bipm

== Usage

=== Search for a standard using keywords

==== References for Si-Brochure documents

BIPM {DOCUMENT_NAME}

Allowed document names are:

==== Reference structure for Metrologia documents

BIPM Metrologia {JOURNAL} {VOLUME} {ISSUE}

==== Reference structures for Outcomes documents

===== Basic pattern


Long: {group name} -- {type} {number} ({year}) {group name} {type} {number} ({year}) {group name} {type} {year}-{zero_leading_number}

Short: {group name} -- {type-abbrev} {number} ({year}, {lang}) {group name} {type-abbrev} {number} ({year}, {lang})

===== Special case pattern

The basic pattern works fine for all, except for these 2 cases:

Where the committee name is part of the outcome identifier. + Special cases:


Decision CIPM/111-10 (2022) / Décision CIPM/111-10 (2022) Recommendation JCRB/43-1 (2021) / Recommandation JCRB/43-1 (2021)

===== Single language version (English)

type can be:

e.g.


CCTF -- Recommendation 2 (1970) CCTF -- REC 2 (1970, EN)

Special cases:


Decision CIPM/111-10 (2022) CIPM DECN CIPM/111-10 (2022, EN) Recommendation JCRB/43-1 (2021) JCRB REC JCRB/43-1 (2021, EN)

===== Single language version (French)

type can be:

e.g.


CCTF -- Recommandation 2 (1970) CCTF -- REC 2 (1970, FR)

Special cases:


Décision CIPM/111-10 (2022) CIPM DECN CIPM/111-10 (2022, FR) Recommandation JCRB/43-1 (2021) JCRB REC JCRB/43-1 (2021, FR)

===== Dual language version (language independent version)

type can be in their respective languages or the following abbreviations:


CCTF -- Recommandation 2 (1970) / Recommendation 2 (1970) CCTF REC 2 (1970)

Special cases:


Decision CIPM/110-10 (2022) / Décision CIPM/111-10 (2022) CIPM DECN CIPM/110-10 (2022) Recommendation JCRB/43-1 (2021) / Recommandation JCRB/43-1 (2021) JCRB REC JCRB/43-1 (2021)

==== Examples

[source,ruby]

require "relaton_bipm" => true

get BIPM brochure

item = RelatonBipm::BipmBibliography.get "BIPM SI Brochure" [relaton-bipm] (BIPM SI Brochure) Fetching from Relaton repository ... [relaton-bipm] (BIPM SI Brochure) Found: BIPM SI Brochure => #<RelatonBipm::BipmBibliographicItem:0x007ffb83982fe8 ...

get BIPM Metrologia page

bib = RelatonBipm::BipmBibliography.get "BIPM Metrologia 29 6 001" [relaton-bipm] (BIPM Metrologia 29 6 001) Fetching from Relaton repository ... [relaton-bipm] (BIPM Metrologia 29 6 001) Found: Metrologia 29 6 001 => #<RelatonBipm::BipmBibliographicItem:0x007f8857f94d40 ...

get CGPM meetings

RelatonBipm::BipmBibliography.get "CGPM 1st Meeting (1889)" [relaton-bipm] (CGPM 1st Meeting (1889)) Fetching from Relaton repository ... [relaton-bipm] (CGPM 1st Meeting (1889)) Found: CGPM 1th meeting (1889) => #<RelatonBipm::BipmBibliographicItem:0x00007f7fd02aba28 ...

get CGPM resolutions

RelatonBipm::BipmBibliography.get "CGPM RES (1889, E)" [relaton-bipm] (CGPM RES (1889, E)) Fetching from Relaton repository ... [relaton-bipm] (CGPM RES (1889, E)) Found: CGPM RES (1889) => #<RelatonBipm::BipmBibliographicItem:0x00007f80421f93d8 ...

RelatonBipm::BipmBibliography.get "CGPM Resolution (1889)" [relaton-bipm] (CGPM Resolution (1889)) Fetching from Relaton repository ... [relaton-bipm] (CGPM Resolution (1889)) Found: CGPM RES (1889) => #<RelatonBipm::BipmBibliographicItem:0x00007f8017f60c18 ...

RelatonBipm::BipmBibliography.get "CGPM Résolution (1889)" [relaton-bipm] (CGPM Résolution (1889)) Fetching from Relaton repository ... [relaton-bipm] (CGPM Résolution (1889)) Found: CGPM RES (1889) => #<RelatonBipm::BipmBibliographicItem:0x00007f8017f492e8 ...

get CIPM decision by year and decision number

RelatonBipm::BipmBibliography.get "BIPM Decision CIPM/101-1 (2012)" [relaton-bipm] (BIPM Decision CIPM/101-1 (2012)) Fetching from Relaton repository ... [relaton-bipm] (BIPM Decision CIPM/101-1 (2012)) Found: CIPM DECN 101-1 (2012) => #<RelatonBipm::BipmBibliographicItem:0x00007f8017f2bd88 ...

RelatonBipm::BipmBibliography.get "BIPM DECN CIPM/101-1 (2012, E)" [relaton-bipm] (BIPM DECN CIPM/101-1 (2012, E)) Fetching from Relaton repository ... [relaton-bipm] (BIPM DECN CIPM/101-1 (2012, E)) Found: CIPM DECN 101-1 (2012) => #<RelatonBipm::BipmBibliographicItem:0x00007f8017f39438 ...

get CIPM recommendation

RelatonBipm::BipmBibliography.get "CIPM Recommendation 1 (2005)" [relaton-bipm] (CIPM Recommendation 1 (2005)) Fetching from Relaton repository ... [relaton-bipm] (CIPM Recommendation 1 (2005)) Found: CIPM REC 1 (2005) => #<RelatonBipm::BipmBibliographicItem:0x00007f8017f31da0 ...

RelatonBipm::BipmBibliography.get "CIPM REC 1 (2005, FR)" [relaton-bipm] (CIPM REC 1 (2005, FR)) Fetching from Relaton repository ... [relaton-bipm] (CIPM REC 1 (2005, FR)) Found: CIPM REC 1 (2005) => #<RelatonBipm::BipmBibliographicItem:0x00007f80422100d8 ...

=== XML serialization

[source,ruby]

item.to_xml => "

2022-12-02
  <title type="main" format="text/plain" language="en">The International System of Units</title>
  <title type="cover" format="text/plain" language="en">The International System of Units (SI)</title>
  <title type="main" format="text/plain" language="fr">Le Système international d’unités</title>
  <title type="cover" format="text/plain" language="fr">Le Système international d’unités (SI)</title>
  <docidentifier type="BIPM" primary="true">BIPM SI Brochure</docidentifier>
  ...
</bibitem>"

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

[source,ruby]

item.to_xml bibdata: true => "

2022-12-02
  <title type="main" format="text/plain" language="en">The International System of Units</title>
  <title type="cover" format="text/plain" language="en">The International System of Units (SI)</title>
  <title type="main" format="text/plain" language="fr">Le Système international d’unités</title>
  <title type="cover" format="text/plain" language="fr">Le Système international d’unités (SI)</title>
  <docidentifier type="BIPM" primary="true">BIPM SI Brochure</docidentifier>
  ...
  <ext schema-version="v1.0.0">
    <doctype>brochure</doctype>
    ...
  </ext>
</bibdata>"

=== Typed links

Each BIPM document has src type link and an optional doi type link.

[source,ruby]

bib.link => [#<RelatonBib::TypedUri:0x00007fa6d6a51728 @content=#<Addressable::URI:0xc29c URI:https://iopscience.iop.org/article/10.1088/0026-1394/29/6/001>, @type="src">,

<RelatonBib::TypedUri:0x00007fa6d6a29250 @content=#<Addressable::URI:0xc2b0 URI:https://doi.org/10.1088/0026-1394/29/6/001>, @type="doi">]


=== Create a bibliographic item from XML

[source,ruby]

RelatonBipm::XMLParser.from_xml File.read('spec/fixtures/bipm_item.xml') => #<RelatonBipm::BipmBibliographicItem:0x007ffb83827a90 ...

=== Create a bibliographic item from YAML [source,ruby]

hash = YAML.load_file 'spec/fixtures/bipm_item.yml' => {"id"=>"Draft-Agenda-NMI-Dir-Meeting-2017-v10", ...

RelatonBipm::BipmBibliographicItem.from_hash hash => #<RelatonBipm::BipmBibliographicItem:0x007ffb668755a0 ...

=== Fetch data

This gem uses the following datasets as data sources:

The method RelatonBipm::DataFetcher.fetch(source, output: "data", format: "yaml") fetches all the documents from the dataset and saves them to the ./data folder in YAML format. Arguments:

[source,ruby]

RelatonBipm::DataFetcher.fetch "bipm-data-outcomes" Started at: 2022-06-23 09:36:55 +0200 Stopped at: 2022-06-23 09:36:58 +0200 Done in: 2 sec. => nil

RelatonBipm::DataFetcher.fetch "bipm-si-brochure" Started at: 2022-06-23 09:37:12 +0200 Stopped at: 2022-06-23 09:37:12 +0200 Done in: 0 sec. => nil

RelatonBipm::DataFetcher.fetch "rawdata-bipm-metrologia" Started at: 2022-06-23 09:39:12 +0200 Stopped at: 2022-06-23 09:40:34 +0200 Done in: 82 sec. => nil

=== Logging

RelatonBipm uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[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.

== Contributing

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

== License

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