Class: Relaton::Calconnect::Processor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProcessor

rubocop:disable Lint/MissingSuper



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

def initialize # rubocop:disable Lint/MissingSuper
  @short = :relaton_calconnect
  @prefix = "CC"
  @defaultprefix = %r{^CC(?!\w)}
  @idtype = "CC"
  @datasets = %w[calconnect-org]
end

Instance Attribute Details

#idtypeObject (readonly)

Returns the value of attribute idtype.



5
6
7
# File 'lib/relaton/calconnect/processor.rb', line 5

def idtype
  @idtype
end

Instance Method Details

#fetch_data(_source, opts) ⇒ Object

Fetch all the documents from a source

Parameters:

  • _source (String)

    source name

  • opts (Hash)

Options Hash (opts):

  • :output (String)

    directory to output documents

  • :format (String)


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

def fetch_data(_source, opts)
  reqire_relative "data_fetcher"
  DataFetcher.fetch(**opts)
end

#from_xml(xml) ⇒ Relaton::Calconnect::ItemData

Parameters:

  • xml (String)

Returns:



39
40
41
42
# File 'lib/relaton/calconnect/processor.rb', line 39

def from_xml(xml)
  require_relative "../calconnect"
  Item.from_xml xml
end

#get(code, date, opts) ⇒ Relaton::Calconnect::ItemData?

Parameters:

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

    year

  • opts (Hash)

Returns:



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

def get(code, date, opts)
  require_relative "../calconnect"
  Bibliography.get(code, date, opts)
end

#grammar_hashString

Returns hash of XML grammar

Returns:

  • (String)


53
54
55
56
# File 'lib/relaton/calconnect/processor.rb', line 53

def grammar_hash
  require_relative "../calconnect"
  @grammar_hash ||= ::Relaton::Calconnect.grammar_hash
end

#hash_to_bib(hash) ⇒ Relaton::Calconnect::ItemData

Parameters:

  • hash (Hash)

Returns:



46
47
48
49
# File 'lib/relaton/calconnect/processor.rb', line 46

def hash_to_bib(hash)
  require_relative "../calconnect"
  Item.from_yaml hash.to_yaml
end

#remove_index_fileObject

Remove index file



61
62
63
64
# File 'lib/relaton/calconnect/processor.rb', line 61

def remove_index_file
  require_relative "../calconnect"
  Relaton::Index.find_or_create(:CC, url: true, file: "#{INDEXFILE}.yaml").remove_file
end