= RelatonIsoBib image:https://img.shields.io/gem/v/relaton-iso-bib.svg["Gem Version", link="https://rubygems.org/gems/relaton-iso-bib"] image:https://github.com/relaton/relaton-iso-bib/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-iso-bib/actions?workflow=macos"] image:https://github.com/relaton/relaton-iso-bib/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/relaton/relaton-iso-bib/actions?workflow=windows"] image:https://github.com/relaton/relaton-iso-bib/workflows/ubuntu/badge.svg["Build Status (Ubuntu)", link="https://github.com/relaton/relaton-iso-bib/actions?workflow=ubuntu"] image:https://codeclimate.com/github/relaton/relaton-iso-bib/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/relaton/relaton-iso-bib"] image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-iso-bib.svg["Pull Requests", link="https://github.com/relaton/relaton-iso-bib/pulls"] image:https://img.shields.io/github/commits-since/relaton/relaton-iso-bib/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-iso-bib/releases"] IsoBib is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model]. == Installation Add this line to your application's Gemfile: [source,ruby] ---- gem 'relaton-iso-bib' ---- And then execute: $ bundle Or install it yourself as: $ gem install relaton-iso-bib == Usage === Create ISO bibliographic item [source,ruby] ---- require 'relaton_iso_bib' => true hash = YAML.load_file "spec/examples/iso_bib_item.yml" => { "schema-version"=>"v1.0.0", "id"=>"ISO/TC211", "title"=>[ {"type"=>"title-intro", "content"=>"Geographic information", "language"=>"en", "script"=>"Latn", "format"=>"text/plain"}, ... bib_hash = RelatonIsoBib::HashConverter.hash_to_bib hash => {:"schema-version"=>"v1.0.0", :id=>"ISO/TC211", :fetched=>"2011-06-22", :title=> # # #, @type="title-intro">, #, @type="title-main">, #, @type="title-part">, #, @type="main">, #, @type="title-intro">, #, @type="title-main">, #, @type="title-part">, #, @type="main">]> item.title(lang: "en") => #, @type="title-intro">, #, @type="title-main">, #, @type="title-part">, #, @type="main">]> item.abstract(lang: "en").to_s => "ISO 19115-1:2014 defines the schema required for ..." ---- === IsoBibliographicItem references [source,ruby] ---- item.shortref(item.structuredidentifier) => "ISO1-2-2014:2014" ---- === IsoBibliographicItem URLs [source,ruby] ---- item.url => "https://www.iso.org/standard/53798.html" item.url(:obp) => "https://www.iso.org/obp/ui/#!iso:std:53798:en" item.url(:rss) => "https://www.iso.org/contents/data/standard/05/37/53798.detail.rss" ---- === IsoBibliographicItem ICS [source,ruby] ---- item.ics [], @subgroupcode="70">] ---- === IsoBibliographicItem BibliographicDates [source,ruby] ---- item.date => [#, #, #] item.date.filter(type: "published").first.on => "2014-04" item.date.filter(type: "published").first.on :year => 2014 item.date.filter(type: "published").first.on :month => 4 item.date.filter(type: "published").first.on :day => nil item.date.filter(type: "published").first.on :date => # ---- === IsoBibliographicItem DocumentStatus [source,ruby] ---- item.status => #, @substage=#> ---- [source,ruby] ---- wg = item.editorialgroup => #], @technical_committee= [#], @workgroup=[#]> ---- === Document relations of a standard [source,ruby] ---- item.relation => # # #, @type="title-intro">, #, @type="title-main">, #, @type="main">]> all_parts_item.shortref(item.structuredidentifier) => "ISO1-2-2014:2014: All Parts" all_parts_item.relation.last.bibitem.title => #, @type="title-intro">, #, @type="title-main">, #, @type="title-part">, #, @type="main">, #, @type="title-intro">, #, @type="title-main">, #, @type="title-part">, #, @type="main">]> ---- === Reference modification: convert to most recent reference In ISO, an undated reference is interpreted as a _de dicto_ reference to the most recent instance of the reference; if the document is read after a new version of the reference has been issued, the reference is taken to refer to that new instance, even if that instance had not been published at the time the bibliography was authored. All references on the ISO website (as retrieved by the isobib gem) are dated. A dated reference is converted to a Most Recent reference by making the dated reference an instance relation to a new reference, which strips the date of publication of the original, and its abstract. The operation is destructive. [source,ruby] ---- all_parts_item.date => [#, #, #] most_recent_ref_item = all_parts_item.to_most_recent_reference => # [] most_recent_ref_item.shortref(most_recent_ref_item.structuredidentifier) => "ISO1(allparts): All Parts" ---- === XML serialization [source,ruby] ---- item.to_xml(bibdata: true) => " 2011-06-22 Geographic information Metadata Part 1: Fundamentals Geographic information – Metadata – Part 1: Fundamentals Information géographique Métadonnées Information géographique Information géographique – Métadonnées – Information géographique ... international-standard ... " item.to_xml(bibdata: true, note: [{ type: "note type", text: "test note" }]) => " 2011-06-22 Geographic information ... test note ... " ---- === Export bibliographic item to BibTeX [source,ruby] ---- item.to_bibtex => "@misc{ISO/TC211, title = {Geographic information – Metadata – Part 1: Fundamentals}, edition = {1}, author = {Bierman, A. and Bierman, A}, publisher = {IETF}, address = {bib place}, year = {2014}, month = apr, urldate = {2015-05-20}, type = {value}, timestamp = {2011-06-22}, url = {https://www.iso.org/standard/53798.html}, month_numeric = {4} }" ---- === Exporting bibliographic item to AsciiBib [source,ruby] ---- item.to_asciibib => "[%bibitem] == {blank} id:: ISO/TC211 fetched:: 2011-06-22 title:: title.type:: title-intro title.content:: Geographic information title.language:: en title.script:: Latn title.format:: text/plain title:: title.type:: title-main title.content:: Metadata title.language:: en title.script:: Latn title.format:: text/plain ... " ---- === Create bibliographic item from YAML [source,ruby] ---- hash = YAML.load_file 'spec/examples/iso_bib_item.yml' => {"schema-version"=>"v1.0.0", "id"=>"ISO/TC211", ... bib_hash = RelatonIsoBib::HashConverter.hash_to_bib hash => {:"schema-version"=>"v1.0.0", :id=>"ISO/TC211", ... RelatonIsoBib::IsoBibliographicItem.new **bib_hash => #