= 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:
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}
{JOURNAL}
- journal number, optional{VOLUME}
- volume number, optional{ISSUE}
- issue number, optional==== 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}
group name
- a name of the group, required. A full list of group names is available https://github.com/metanorma/bipm-editor-guides/blob/main/sources/bipm-references-en.adoc#appendix-a-bipm-groups-and-codes[here].type
- a type of document, required. A list of types is: Resolution (Résolution), Recommendation (Recommandation), Decision (Décision), Meeting (Réunion), Declaration (Déclaration).type-abbrev
- an abbreviation of the type, required. A list of abbreviations: RES (Resolution), REC (Recommendation), DECN (Decision).number
- a number of the document, optional. Can be with part, e.g. 1-2
.zero_leading_number
- a number of the document with a leading zero, required. Can be used when a document has a 1 or 2 digits number. It's 00
for documents without a number.year
- a year of the document, optional.lang
- a language of the document, optional. Can be EN
or FR
.===== 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:
===== Single language version (English)
type
can be:
e.g.
Special cases:
===== Single language version (French)
type
can be:
e.g.
Special cases:
===== Dual language version (language independent version)
type
can be in their respective languages or the following abbreviations:
Special cases:
==== Examples
require "relaton_bipm" => true
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
...
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
...
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
...
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
...
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
...
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
...
CIPM REC 1 (2005)
=> #<RelatonBipm::BipmBibliographicItem:0x00007f80422100d8
...=== XML serialization
item.to_xml
=> "
<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.
item.to_xml bibdata: true
=> "
<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.
bib.link => [#<RelatonBib::TypedUri:0x00007fa6d6a51728 @content=#<Addressable::URI:0xc29c URI:https://iopscience.iop.org/article/10.1088/0026-1394/29/6/001>, @type="src">,
=== Create a bibliographic item from XML
hash = YAML.load_file 'spec/fixtures/bipm_item.yml' => {"id"=>"Draft-Agenda-NMI-Dir-Meeting-2017-v10", ...
=== Fetch data
This gem uses the following datasets as data sources:
bipm-data-outcomes
- looking for a local directory with the repository https://github.com/metanorma/bipm-data-outcomesbipm-si-brochute
- looking for a local directory with the repository https://github.com/metanorma/bipm-si-brochurerawdata-bipm-metrologia
- looking for a local directory with the repository https://github.com/relaton/rawdata-bipm-metrologiaThe 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
- the name of the source datasetoutput
- folder to save documents (default './data').format
- the format in which the documents are saved. Possible formats are: yaml
, xml
, bibxxml
(default yaml
).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
=== 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.