Gem Version Build Status (macOS) Build Status (Windows) Build Status (Ubuntu) Code Climate Pull Requests Commits since latest

RelatonCie is a Ruby gem that searches and fetches standards from the International Commision on Illuminantion.

Installation

Add this line to your application’s Gemfile:

gem 'relaton-cie'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install relaton-cie

Usage

Search document

require 'relaton_cie'
=> true

item = RelatonCie::CieBibliography.get 'CIE 001-1980'
[relaton-cie] (CIE 001-1980) Fetching from Realton repository ...
[relaton-cie] (CIE 001-1980) Found: `CIE 001-1980`
=> #<RelatonBib::BibliographicItem:0x007fb3f6098920
...

# Return nil if a document doesn't exist.
RelatonCie::CieBibliography.get '1111'
[relaton-cie] (1111) Fetching from Realton repository ...
[relaton-cie] (1111) Not found.
=> nil

Serialization

item.to_xml
=> "<bibitem id="CIE001-1980" type="standard" schema-version="v1.2.1">
      <fetched>2022-12-03</fetched>
      <title type="title-main" format="text/plain">Guidelines for minimizing urban sky glow near astronomical observatories (Joint Publication IAU/CIE)</title>
      <title type="main" format="text/plain">Guidelines for minimizing urban sky glow near astronomical observatories (Joint Publication IAU/CIE)</title>
      <uri type="src">https://www.techstreet.com/cie/standards/cie-001-1980?product_id=1210107</uri>
      ...
    </bibitem>"

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

item.to_xml bibdata: true
=> "<bibdata type="standard" schema-version="v1.2.1">
      <fetched>2022-12-03</fetched>
      <title type="title-main" format="text/plain">Guidelines for minimizing urban sky glow near astronomical observatories (Joint Publication IAU/CIE)</title>
      <title type="main" format="text/plain">Guidelines for minimizing urban sky glow near astronomical observatories (Joint Publication IAU/CIE)</title>
      <uri type="src">https://www.techstreet.com/cie/standards/cie-001-1980?product_id=1210107</uri>
      ...
      <ext schema-version="v1.0.0">
        <doctype>document</doctype>
      </ext>
    </bibdata>"
=== Typed links

Each CIE document has src type link.

item.link
=> [#<RelatonBib::TypedUri:0x00007fe58e8d4048 @content=#<Addressable::URI:0xbe50 URI:https://www.techstreet.com/cie/standards/cie-001-1980?product_id=1210107>, @type="src">]

Parse a file locally

item = RelatonCie::XMLParser.from_xml File.read("spec/fixtures/bibdata.xml")
#<RelatonCie::BibliographicItem:0x00007feecda370f0
...

Fetch data

This gem uses the https://www.techstreet.com/cie/searches/31156444 dataset as one of the data sources.

The method RelatonCie::DataFetcher.fetch(output: "data", format: "yaml") fetches all the documents from the dataset and saves them to the ./data folder in YAML format. Arguments:

  • output - folder to save documents (default './data').

  • format - the format in which the documents are saved. Possible formats are: yaml, xml, bibxml (default yaml).

RelatonCie::DataFetcher.fetch
Started at: 2021-09-08 16:37:53 +0200
Stopped at: 2021-09-08 16:49:17 +0200
Done in: 684 sec.
=> nil

Logging

RelatonCie 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 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/relaton/relaton-cie.

License

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