Sha256: e3fad5fbe3bbe61b4d7c522352f3c1279eefae8364d5db535e4eb70b3db25c85

Contents?: true

Size: 858 Bytes

Versions: 3

Compression:

Stored size: 858 Bytes

Contents

module RelatonDoi
  module Crossref
    extend self

    #
    # Get a document by DOI from the CrossRef API.
    #
    # @param [String] doi The DOI.
    #
    # @return [RelatonBib::BibliographicItem, RelatonIetf::IetfBibliographicItem,
    #   RelatonBipm::BipmBibliographicItem, RelatonIeee::IeeeBibliographicItem,
    #   RelatonNist::NistBibliographicItem] The bibitem.
    #
    def get(doi)
      warn "[relaton-doi] [\"#{doi}\"] fetching..."
      id = doi.sub(%r{^doi:}, "")
      message = get_by_id id
      warn "[relaton-doi] [\"#{doi}\"] found #{message['DOI']}"
      Parser.parse message
    end

    #
    # Get a document by DOI from the CrossRef API.
    #
    # @param [String] id The DOI.
    #
    # @return [Hash] The document.
    #
    def get_by_id(id)
      resp = Serrano.works ids: id
      resp[0]["message"]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
relaton-doi-1.16.0 lib/relaton_doi/crossref.rb
relaton-doi-1.14.4 lib/relaton_doi/crossref.rb
relaton-doi-1.14.3 lib/relaton_doi/crossref.rb