= RelatonBib image:https://img.shields.io/gem/v/relaton-bib.svg["Gem Version", link="https://rubygems.org/gems/relaton-bib"] image:https://img.shields.io/travis/metanorma/relaton-bib["Build Status", link="https://travis-ci.com/metanorma/relaton-bib"] image:https://codeclimate.com/github/metanorma/relaton-bib["Code Climate", link="https://codeclimate.com/github/metanorma/relaton-bib"] RlatonBib is a Ruby gem that implements the https://github.com/metanorma/relaton-models#bibliography-uml-models[BibliographicItem model]. == Installation Add this line to your application's Gemfile: [source,ruby] ---- gem 'relaton-bib' ---- And then execute: $ bundle Or install it yourself as: $ gem install relaton-bib == Usage === Create bibliographic item [source,ruby] ---- item = RelatonBib::BibliographicItem.new( id: "ISO/TC211", fetched: Date.today.to_s, type: "standard", title: [ { type: "main", content: "Geographic information", language: "en", script: "Latn" }, { content: "Information géographique", language: "fr", script: "Latn" }, ], link: [ { type: "src", content: "https://www.iso.org/standard/53798.html" }, { type: "obp", content: "https://www.iso.org/obp/ui/#!iso:std:53798:en" }, { type: "rss", content: "https://www.iso.org/contents/data/standard"\ "/05/37/53798.detail.rss" } ], docid: [ RelatonBib::DocumentIdentifier.new(id: "TC211", type: "ISO") ], docnumber: "123456", date: [ { type: "issued", on: "2014" }, { type: "published", on: "2014-04" }, { type: "accessed", on: "2015-05-20" } ], contributor: [ { entity: { name: "International Organization for Standardization", url: "www.iso.org", abbreviation: "ISO", subdivision: "division" }, role: [["publisher", ["Publisher role"]]], } ], edition: "1", version: RelatonBib::BibliographicItem::Version.new("2019-04-01", ["draft"]), language: ["en", "fr"], script: ["Latn"], abstract: [ { content: "ISO 19115-1:2014 defines the schema required for ...", language: "en", script: "Latn", format: "text/plain" }, { content: "L'ISO 19115-1:2014 définit le schéma requis pour ...", language: "fr", script: "Latn", format: "text/plain" }, ], docstatus: RelatonBib::DocumentStatus.new( RelatonBib::LocalizedString.new("standard", "en", "Latn") ), copyright: { owner: { name: "International Organization for Standardization", abbreviation: "ISO", url: "www.iso.org" }, from: "2014", to: "2020" }, relation: [ { type: "updates", bibitem: RelatonBib::BibliographicItem.new( formattedref: RelatonBib::FormattedRef.new(content: "ISO 19115:2003"), ), bib_locality: [RelatonBib::BibItemLocality.new("updates", "Reference form")], } ], series: [ RelatonBib::Series.new( type: "main", title: RelatonBib::TypedTitleString.new( type: "original", content: "ISO/IEC FDIS 10118-3", language: "en", script: "Latn", format: "text/plain", ), place: "Serie's place", organization: "Serie's organization", abbreviation: RelatonBib::LocalizedString.new("ABVR", "en", "Latn"), from: "2009-02-01", to: "2010-12-20", number: "serie1234", partnumber: "part5678", ), RelatonBib::Series.new( type: "alt", formattedref: RelatonBib::FormattedRef.new( content: "serieref", language: "en", script: "Latn" ), ) ], medium: RelatonBib::Medium.new( form: "medium form", size: "medium size", scale: "medium scale" ), place: ["bib place"], extent: [ RelatonBib::BibItemLocality.new( "section", "Reference from", "Reference to" ), ], accesslocation: ["accesslocation1", "accesslocation2"], classification: RelatonBib::Classification.new(type: "type", value: "value"), validity: RelatonBib::Validity.new( begins: Time.new(2010, 10, 10, 12, 21), ends: Time.new(2011, 2, 3, 18,30), revision: Time.new(2011, 3, 4, 9, 0) ) ) ---- === BibliographicItem Typed Title Strings [source,ruby] ---- item.title => [#, @type="main">, #, @type=nil>] ---- === BibliographicItem Formatted Strings [source,ruby] ---- item.abstract => [#, #] item.abstract(lang: "en").to_s => "ISO 19115-1:2014 defines the schema required for ..." " ---- === BibliographicItem references [source,ruby] ---- item.shortref item => "ISO/TC211:2014" ---- === XML serialization [source,ruby] ---- item.to_xml => " 2019-04-30 Geographic information Information géographique https://www.iso.org/standard/53798.html https://www.iso.org/obp/ui/#!iso:std:53798:en https://www.iso.org/contents/data/standard/05/37/53798.detail.rss TC211 123456 2014 2014 2015 Publisher role International Organization for Standardization division ISO www.iso.org 1 2019-04-01 draft en fr ISO 19115-1:2014 defines the schema required for ... L'ISO 19115-1:2014 définit le schéma requis pour ... standard 2014 2020 International Organization for Standardization ISO www.iso.org ISO 19115:2003 Reference form ISO/IEC FDIS 10118-3 Serie's place Serie's organization ABVR 2009-02-01 2010-12-20 serie1234 part5678 serieref
medium form
medium size medium scale
bib place Reference from Reference to accesslocation1 accesslocation2 value 2010-10-10 12:21 2011-02-03 18:30 2011-03-04 09:00
" ---- Default root element is `bibitem`. With argument `bibdata: true` the XML wrapped with `bibdata` element. [source,ruby] ---- item.to_xml => " 2019-04-30 Geographic information ... " ---- ==== Date format By default date elements are formatted as year (yyyy). Option `:date_format` allows to output date elements in `:short` (yyyy-mm) and `:full` (yyyy-mm-dd) additiona formats. [surce,ruby] ---- item.to_xml date_format: :short => " 2019-04-30 Geographic information Information géographique https://www.iso.org/standard/53798.html https://www.iso.org/obp/ui/#!iso:std:53798:en https://www.iso.org/contents/data/standard/05/37/53798.detail.rss TC211 123456 2014-01 2014-04 2015-05 ... item.to_xml date_format: :full => " ... 2014-01-01 2014-04-01 2015-05-20 ... ---- === Create bibliographic item form YAML [source,ruby] ---- hash = YAML.load_file 'spec/examples/bib_item.yml' => {"id"=>"ISO/TC211", ... bib_hash = RelatonBib::HashConverter.hash_to_bib hash => {:id=>"ISO/TC211", ... RelatonBib::BibliographicItem.new bib_hash => #