Class: Relaton::Doi::Processor

Inherits:
Core::Processor
  • Object
show all
Defined in:
lib/relaton/doi/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProcessor

rubocop:disable Lint/MissingSuper



8
9
10
11
12
13
# File 'lib/relaton/doi/processor.rb', line 8

def initialize # rubocop:disable Lint/MissingSuper
  @short = :relaton_doi
  @prefix = "DOI"
  @defaultprefix = %r{^doi:}
  @idtype = "DOI"
end

Instance Attribute Details

#idtypeObject (readonly)

Returns the value of attribute idtype.



6
7
8
# File 'lib/relaton/doi/processor.rb', line 6

def idtype
  @idtype
end

Instance Method Details

#fetch_data(_source, _opts) ⇒ Object

Parameters:

  • source (String)

    source name

  • opts (Hash)


30
31
32
# File 'lib/relaton/doi/processor.rb', line 30

def fetch_data(_source, _opts)
  Util.info "This processor does not support fetching data by source name. Use `get` method with DOI instead."
end

#from_xml(xml) ⇒ Bib::ItemData

Parameters:

  • xml (String)

Returns:

  • (Bib::ItemData)


36
37
38
39
# File 'lib/relaton/doi/processor.rb', line 36

def from_xml(xml)
  require_relative "../doi"
  Bib::Item.from_xml xml
end

#from_yaml(yaml) ⇒ Bib::ItemData

Parameters:

  • yaml (String)

Returns:

  • (Bib::ItemData)


43
44
45
46
# File 'lib/relaton/doi/processor.rb', line 43

def from_yaml(yaml)
  require_relative "../doi"
  Bib::Item.from_yaml yaml
end

#get(code, _date, _opts) ⇒ RelatonBib::BibliographicItem

Parameters:

  • code (String)

    DOI

  • date (String, nil)

    year

  • opts (Hash)

Returns:

  • (RelatonBib::BibliographicItem)


19
20
21
22
# File 'lib/relaton/doi/processor.rb', line 19

def get(code, _date, _opts)
  require_relative "../doi"
  Crossref.get(code)
end

#grammar_hashString

Returns hash of XML grammar

Returns:

  • (String)


50
51
52
53
# File 'lib/relaton/doi/processor.rb', line 50

def grammar_hash
  require_relative "../doi"
  @grammar_hash ||= ::Relaton::Doi.grammar_hash
end

#remove_index_fileObject



55
56
57
# File 'lib/relaton/doi/processor.rb', line 55

def remove_index_file
  Util.info "This processor does not support index file. No action taken."
end

#threadsInteger

Returns number of threads

Returns:

  • (Integer)


61
# File 'lib/relaton/doi/processor.rb', line 61

def threads = 2