Gem Version Build Status Code Climate Pull Requests Commits since latest

Relaton::Bsi is a Ruby gem that implements the IsoBibliographicItem model.

Installation

Add this line to your application’s Gemfile:

gem 'relaton-bsi'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install relaton-bsi

Usage

Search for a standard using keywords

require 'relaton/bsi'
=> true

hit_collection = Relaton::Bsi::Bibliography.search("BS EN ISO 8848")
=> <Relaton::Bsi::HitCollection:0x007fead49fe1f8 @ref=BS EN ISO 8848 @fetched=false>

item = hit_collection[1].item
=> #<Relaton::Bsi::ItemData:0x000000012ac6c9a8
 ...

XML serialization

item.to_xml
=> "<bibitem id="BSENISO88482021" type="standard" schema-version="v1.5.6">
      <fetched>2025-10-18</fetched>
      <title language="en" script="Latn" type="title-main">Small craft. Remote mechanical steering systems</title>
      <title language="en" script="Latn" type="main">Small craft. Remote mechanical steering systems</title>
      <uri type="src">https://shop.bsigroup.com/products/small-craft-remote-mechanical-steering-systems</uri>
      <docidentifier type="BSI" primary="true">BS EN ISO 8848:2021</docidentifier>
      ...
    </bibitem>"

Each BSI document has src type link.

item.source[0].type
 => "src"

item.source[0].content
 => "https://shop.bsigroup.com/products/small-craft-remote-mechanical-steering-systems"

With bibdata: true option XML output wrapped with bibdata element and ext element added.

item.to_xml bibdata: true
=> "<bibdata type="standard" schema-version="v1.5.6">
      <fetched>2025-10-18</fetched>
      <title language="en" script="Latn" type="title-main">Small craft. Remote mechanical steering systems</title>
      ...
      <ext schema-version="v1.1.3">
        <doctype>standard</doctype>
        ...
      </ext>
    </bibdata>"

Get standard by code and year

Relaton::Bsi::Bibliography.get "BS EN ISO 8848:2021"
[relaton-bsi] INFO: (BS EN ISO 8848:2021) Fetching from shop.bsigroup.com ...
[relaton-bsi] INFO: (BS EN ISO 8848:2021) Found: `BS EN ISO 8848:2021`
 => #<Relaton::Bsi::ItemData:0x000000011f19b688
...

Relaton::Bsi::Bibliography.get "BS EN ISO 8848", "2021"
[relaton-bsi] INFO: (BS EN ISO 8848) Fetching from shop.bsigroup.com ...
[relaton-bsi] INFO: (BS EN ISO 8848) Found: `BS EN ISO 8848:2021`
 => #<Relaton::Bsi::ItemData:0x000000011f1bdc10
...

Create bibliographic item form YAML

Relaton::Bsi::Item.from_yaml File.read("spec/fixtures/item.yaml", encoding: "UTF-8")
 => #<Relaton::Bsi::ItemData:0x0000000104dd0dd8
...

Create bibliographic item from XML

Relaton::Bsi::Item.from_xml File.read("spec/fixtures/bibdata.xml", encoding: "UTF-8")
 => #<Relaton::Bsi::ItemData:0x0000000104178c20
...

Logging

Relaton::Bsi uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the 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 the created tag, 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/relaton/relaton-bsi.

License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).