RlatonBib is a Ruby gem that implements the BibliographicItem model.
Installation
Add this line to your application’s Gemfile:
gem 'relaton-bib'
And then execute:
$ bundle
Or install it yourself as:
$ gem install relaton-bib
Usage
Create bibliographic item
item = RelatonBib::BibliographicItem.new(
id: "ISO/TC211",
fetched: Date.today.to_s,
type: "standard",
titles: [
{ 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",
dates: [
{ type: "issued", on: "2014" },
{ type: "published", on: "2014-04" },
{ type: "accessed", on: "2015-05-20" }
],
contributors: [
{ entity: {
name: "International Organization for Standardization",
url: "www.iso.org", abbreviation: "ISO", subdivision: "division" },
roles: [["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" },
relations: [
{ 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
item.title
=> [#<RelatonBib::TypedTitleString:0x007fa49a360290
@title=#<RelatonBib::FormattedString:0x007fa49a360088 @content="Geographic information", @format=nil, @language=["en"], @script=["Latn"]>,
@type="main">,
#<RelatonBib::TypedTitleString:0x007fa49a35bf38
@title=#<RelatonBib::FormattedString:0x007fa49a35bdd0 @content="Information géographique", @format=nil, @language=["fr"], @script=["Latn"]>,
@type=nil>]
BibliographicItem Formatted Strings
item.abstract
=> [#<RelatonBib::FormattedString:0x007fa49a35aed0 @content="ISO 19115-1:2014 defines the schema required for ...", @format="text/plain", @language=["en"], @script=["Latn"]>,
#<RelatonBib::FormattedString:0x007fa49a35ae08 @content="L'ISO 19115-1:2014 définit le schéma requis pour ...", @format="text/plain", @language=["fr"], @script=["Latn"]>]
item.abstract(lang: "en").to_s
=> "ISO 19115-1:2014 defines the schema required for ..."
"
BibliographicItem references
item.shortref item
=> "ISO/TC211:2014"
XML serialization
item.to_xml
=> "<bibitem id=\"ISO/TC211\" type=\"standard\">
<fetched>2019-04-30</fetched>
<title type=\"main\" language=\"en\" script=\"Latn\">Geographic information</title>
<title language=\"fr\" script=\"Latn\">Information géographique</title>
<uri type=\"src\">https://www.iso.org/standard/53798.html</uri>
<uri type=\"obp\">https://www.iso.org/obp/ui/#!iso:std:53798:en</uri>
<uri type=\"rss\">https://www.iso.org/contents/data/standard/05/37/53798.detail.rss</uri>
<docidentifier type=\"ISO\">TC211</docidentifier>
<docnumber>123456</docnumber>
<date type="issued">
<on>2014</on>
</date>
<date type="published">
<on>2014</on>
</date>
<date type="accessed">
<on>2015</on>
</date>
<contributor>
<role type=\"publisher\">
<description>Publisher role</description>
</role>
<organization>
<name>International Organization for Standardization</name>
<subdivision>division</subdivision>
<abbreviation>ISO</abbreviation>
<uri>www.iso.org</uri>
</organization>
</contributor>
<edition>1</edition>
<version>
<revision_date>2019-04-01</revision_date>
<draft>draft</draft>
</version>
<language>en</language>
<language>fr</language>
<script>Latn</script>
<abstract format=\"text/plain\" language=\"en\" script=\"Latn\">ISO 19115-1:2014 defines the schema required for ...</abstract>
<abstract format=\"text/plain\" language=\"fr\" script=\"Latn\">L'ISO 19115-1:2014 définit le schéma requis pour ...</abstract>
<status language=\"en\" script=\"Latn\">standard</status>
<copyright>
<from>2014</from>
<to>2020</to>
<owner>
<organization>
<name>International Organization for Standardization</name>
<abbreviation>ISO</abbreviation>
<uri>www.iso.org</uri>
</organization>
</owner>
</copyright>
<relation type=\"updates\">
<bibitem>
<formattedref>ISO 19115:2003</formattedref>
</bibitem>
<locality type=\"updates\">
<referenceFrom>Reference form</referenceFrom>
</locality>
</relation>
<series type=\"main\">
<title type=\"original\" format=\"text/plain\" language=\"en\" script=\"Latn\">ISO/IEC FDIS 10118-3</title>
<place>Serie's place</place>
<organization>Serie's organization</organization>
<abbreviation language=\"en\" script=\"Latn\">ABVR</abbreviation>
<from>2009-02-01</from>
<to>2010-12-20</to>
<number>serie1234</number>
<partnumber>part5678</partnumber>
</series>
<series type=\"alt\">
<formattedref language=\"en\" script=\"Latn\">serieref</formattedref>
</series>
<medium>
<form>medium form</form>
<size>medium size</size>
<scale>medium scale</scale>
</medium>
<place>bib place</place>
<locality type=\"section\">
<referenceFrom>Reference from</referenceFrom>
<referenceTo>Reference to</referenceTo>
</locality>
<accesslocation>accesslocation1</accesslocation>
<accesslocation>accesslocation2</accesslocation>
<classification type=\"type\">value</classification>
<validity>
<validityBegins>2010-10-10 12:21</validityBegins>
<validityEnds>2011-02-03 18:30</validityEnds>
<validityRevision>2011-03-04 09:00</validityRevision>
</validity>
</bibitem>"
Default root element is bibitem
. With argument bibdata: true
the XML wrapped with bibdata
element.
item.to_xml
=> "<bibitem id=\"ISO/TC211\" type=\"standard\">
<fetched>2019-04-30</fetched>
<title type=\"main\" language=\"en\" script=\"Latn\">Geographic information</title>
...
</bibdata>"
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.
item.to_xml date_format: :short
=> "<bibitem id=\"ISO/TC211\" type=\"standard\">
<fetched>2019-04-30</fetched>
<title type=\"main\" language=\"en\" script=\"Latn\">Geographic information</title>
<title language=\"fr\" script=\"Latn\">Information géographique</title>
<uri type=\"src\">https://www.iso.org/standard/53798.html</uri>
<uri type=\"obp\">https://www.iso.org/obp/ui/#!iso:std:53798:en</uri>
<uri type=\"rss\">https://www.iso.org/contents/data/standard/05/37/53798.detail.rss</uri>
<docidentifier type=\"ISO\">TC211</docidentifier>
<docnumber>123456</docnumber>
<date type="issued">
<on>2014-01</on>
</date>
<date type="published">
<on>2014-04</on>
</date>
<date type="accessed">
<on>2015-05</on>
</date>
...
item.to_xml date_format: :full
=> "<bibitem id=\"ISO/TC211\" type=\"standard\">
...
<date type="issued">
<on>2014-01-01</on>
</date>
<date type="published">
<on>2014-04-01</on>
</date>
<date type="accessed">
<on>2015-05-20</on>
</date>
...
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).
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/metanorma/relaton-bib.
License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).