Skip to content

relaton/relaton-bsi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RelatonBsi retrieve BSI Standards for bibliographic use using the BibliographicItem model

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

Search for a standard using keywords

require 'relaton_bsi'
=> true

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

Logging

RelatonBsi 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

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors