Class: FAIRChampionHarvester::OpenAlex
- Inherits:
-
Object
- Object
- FAIRChampionHarvester::OpenAlex
- Defined in:
- lib/openalex.rb
Class Method Summary collapse
Class Method Details
.convertToOpenAlex(guid) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/openalex.rb', line 20 def self.convertToOpenAlex(guid) guid = guid.sub(%r{^https?://[\w.]+/}, "") guid = guid.sub(/^doi:/, "") FAIRChampionHarvester::Utils::GUID_TYPES.each do |pair| k, regex = pair if k == "doi" and regex.match(guid) url = "https://api.openalex.org/works/doi:#{guid}" return ["doi", url] end end [nil, nil] end |
.openalex_doi(guid, meta) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/openalex.rb', line 3 def self.openalex_doi(guid, ) guid.downcase! type, url = convertToOpenAlex(guid) # returns doi, http://lopenalex... .guidtype = type if .guidtype.nil? unless type .comments << "WARN: Was not given a DOI. I am going to fail\n" return end .comments << "INFO: Found a DOI.\n" FAIRChampionHarvester::URL.resolve_url(guid: url, meta: , nolinkheaders: true) # the true is to prevent recursive pursuit of link headers .comments << "INFO: parsing of OpenAlex #{url} complete.\n" end |