Class: Relaton::Plateau::Processor

Inherits:
Relaton::Processor
  • Object
show all
Defined in:
lib/relaton/plateau/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProcessor

rubocop:disable Lint/MissingSuper



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

def initialize # rubocop:disable Lint/MissingSuper
  @short = :"relaton/plateau"
  @prefix = "PLATEAU"
  @defaultprefix = /^PLATEAU\s/
  @idtype = "PLATEAU"
  @datasets = %w[plateau-handbooks plateau-technical-reports]
end

Instance Attribute Details

#idtypeObject (readonly)

Returns the value of attribute idtype.



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

def idtype
  @idtype
end

Instance Method Details

#fetch_data(source, opts) ⇒ Object

Fetch all the documents from www.mlit.go.jp/plateau

Parameters:

  • source (String)

    source name (plateau-handbooks, paleteau-technical-reports)

  • opts (Hash)

Options Hash (opts):

  • :output (String)

    directory to output documents

  • :format (String)

    output format (xml, yaml, bibxml)



32
33
34
# File 'lib/relaton/plateau/processor.rb', line 32

def fetch_data(source, opts)
  Fetcher.fetch(source, **opts)
end

#from_xml(xml) ⇒ Relaton::Plateau::BibItem

Parameters:

  • xml (String)

Returns:



38
39
40
# File 'lib/relaton/plateau/processor.rb', line 38

def from_xml(xml)
  ::Relaton::Plateau::XMLParser.from_xml xml
end

#get(code, date, opts) ⇒ Relaton::Plateau::BibliographicItem

Returns Relaton::Plateau::BibliographicItem.

Parameters:

  • code (String)
  • date (String, nil)

    year

  • opts (Hash)

Returns:

  • (Relaton::Plateau::BibliographicItem)

    Relaton::Plateau::BibliographicItem



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

def get(code, date, opts)
  ::Relaton::Plateau::Bibliography.get(code, date, opts)
end

#grammar_hashString

Returns hash of XML grammar

Returns:

  • (String)


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

def grammar_hash
  @grammar_hash ||= ::Relaton::Plateau.grammar_hash
end

#hash_to_bib(hash) ⇒ Relaton:Plateau::BibItem

Parameters:

  • hash (Hash)

Returns:

  • (Relaton:Plateau::BibItem)


44
45
46
47
# File 'lib/relaton/plateau/processor.rb', line 44

def hash_to_bib(hash)
  item_hash = HashConverter.hash_to_bib(hash)
  ::Relaton::Plateau::BibItem.new(**item_hash)
end

#remove_index_fileObject

Remove index file



64
65
66
# File 'lib/relaton/plateau/processor.rb', line 64

def remove_index_file
  Relaton::Index.find_or_create(:plateau, url: true, file: "#{Bibliography::INDEXFILE}.yaml").remove_file
end

#threadsInteger

Returns number of workers

Returns:

  • (Integer)


57
58
59
# File 'lib/relaton/plateau/processor.rb', line 57

def threads
  3
end