Gem Version Build Status Code Climate Pull Requests Commits since latest

RelatonBsi 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

Configuration

Configuration is optional. The available option is logger which is a Logger instance. By default, the logger is Logger.new($stderr) with Logger::WARN level. To change the logger level, use RelatonBsi.configure block.

require 'relaton_bsi'
=> true

RelatonBsi.configure do |config|
  config.logger.level = Logger::DEBUG
end

Search for a standard using keywords

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

item = hit_collection[1].fetch
=> #<RelatonBsi::BsiBibliographicItem:0x007fead494fbf8
 ...

XML serialization

item.to_xml
=> "<bibitem id="BSENISO8848-2021" type="standard" schema-version="v1.2.1">
      <fetched>2022-12-02</fetched>
      <title type="title-main" format="text/plain" language="en" script="Latn">Small craft. Remote mechanical steering systems</title>
      <title type="main" format="text/plain" language="en" script="Latn">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.link
=> [#<RelatonBib::TypedUri:0x00007fc446c4a1a0
  @content=#<Addressable::URI:0x54d8 URI:https://shop.bsigroup.com/products/small-craft-remote-mechanical-steering-systems>,
  @language=nil,
  @script=nil,
  @type="src">]

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.2.1">
      <fetched>2022-12-02</fetched>
      <title type="title-main" format="text/plain" language="en" script="Latn">Small craft. Remote mechanical steering systems</title>
      ...
      <ext schema-version="v1.0.0">
        <doctype>standard</doctype>
        ...
      </ext>
    </bibdata>"

Get standard by code and year

RelatonBsi::BsiBibliography.get "BS EN ISO 8848:2021"
[relaton-bsi] (BS EN ISO 8848:2021) Fetching from shop.bsigroup.com ...
[relaton-bsi] (BS EN ISO 8848:2021) Found: `BS EN ISO 8848:2021`
=> #<RelatonBsi::BsiBibliographicItem:0x007feb14814ca8
...

RelatonBsi::BsiBibliography.get "BS EN ISO 8848", "2021"
[relaton-bsi] (BS EN ISO 8848) Fetching from shop.bsigroup.com ...
[relaton-bsi] (BS EN ISO 8848) Found: `BS EN ISO 8848:2021`
=> #<RelatonBsi::BsiBibliographicItem:0x007feaf59188a8
...

Create bibliographic item form YAML

hash = YAML.load_file 'spec/fixtures/bibdata.yaml'
=> {"id"=>"BSENISO8848-2021",
...

RelatonBsi::BsiBibliographicItem.from_hash hash
=> #<RelatonBsi::BsiBibliographicItem:0x007feaf5109630
...

Create bibliographic item from XML

RelatonBsi::XMLParser.from_xml File.read("spec/fixtures/bibdata.xml", encoding: "UTF-8")
=> #<RelatonBsi::BsiBibliographicItem:0x007feb14d50b68
...

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).