Class: CrossrefDoi
- Inherits:
 - 
      Sequel::Model
      
        
- Object
 - Sequel::Model
 - CrossrefDoi
 
 
- Extended by:
 - DOIHelpers
 
- Includes:
 - DOIHelpers
 
- Defined in:
 - model/crossref.rb
 
Overview
Class that query Crossref for a DOI and stores the result
Class Method Summary collapse
- 
  
    
      .procesar_doi(doi)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Given a DOI, query Crossref, store the result and return a raw JSON.
 - 
  
    
      .reference_integrator_json(doi)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns Reference_Integrator::JSON::Reader for a DOI.
 
Methods included from DOIHelpers
a_doi, doi_without_http, find_doi, url_doi
Class Method Details
.procesar_doi(doi) ⇒ String
Given a DOI, query Crossref, store the result and return a raw JSON
      40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61  | 
    
      # File 'model/crossref.rb', line 40 def self.procesar_doi(doi) require 'serrano' raise ArgumentError, 'DOI is nil' if doi.nil? co=CrossrefDoi[doi_without_http(doi)] if !co or co[:json].nil? begin resultado=Serrano.works(ids: CGI.escape(doi)) rescue Serrano::NotFound=>e return false rescue URI::InvalidURIError #$log.info("Malformed URI: #{doi}") return false end if co co.update(:json=>resultado.to_json) else CrossrefDoi.insert(:doi=>doi_without_http(doi),:json=>resultado.to_json) co=CrossrefDoi[doi_without_http(doi)] end end co[:json] end  | 
  
.reference_integrator_json(doi) ⇒ Object
Returns Reference_Integrator::JSON::Reader for a DOI.
      67 68 69 70 71 72 73 74  | 
    
      # File 'model/crossref.rb', line 67 def self.reference_integrator_json(doi) co=self.procesar_doi(doi) if(co) BibliographicalImporter::JSON::Reader.parse(co)[0] else false end end  |