Class: RelatonIetf::Processor

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

Instance Method Summary collapse

Constructor Details

#initializeProcessor

rubocop:disable Lint/MissingSuper



6
7
8
9
10
11
12
# File 'lib/relaton_ietf/processor.rb', line 6

def initialize # rubocop:disable Lint/MissingSuper
  @short = :relaton_ietf
  @prefix = "IETF"
  @defaultprefix = /^((IETF|RFC|BCP|FYI|STD)\s|I-D[.\s])/
  @idtype = "IETF"
  @datasets = %w[ietf-rfcsubseries ietf-internet-drafts ietf-rfc-entries]
end

Instance Method Details

#fetch_data(source, opts) ⇒ Object

Fetch all the documents from www.rfc-editor.org/rfc-index.xml

Parameters:

  • source (String)

    source name

  • opts (Hash)

Options Hash (opts):

  • :output (String)

    directory to output documents

  • :format (String)


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

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

#from_xml(xml) ⇒ RelatonIetf::IetfBibliographicItem

Parameters:

  • xml (String)

Returns:



36
37
38
# File 'lib/relaton_ietf/processor.rb', line 36

def from_xml(xml)
  ::RelatonIetf::XMLParser.from_xml xml
end

#get(code, date, opts) ⇒ RelatonIetf::IetfBibliographicItem

Parameters:

  • code (String)
  • date (String, NilClass)

    year

  • opts (Hash)

Returns:



18
19
20
# File 'lib/relaton_ietf/processor.rb', line 18

def get(code, date, opts)
  ::RelatonIetf::IetfBibliography.get(code, date, opts)
end

#grammar_hashString

Returns hash of XML grammar

Returns:

  • (String)


48
49
50
# File 'lib/relaton_ietf/processor.rb', line 48

def grammar_hash
  @grammar_hash ||= ::RelatonIetf.grammar_hash
end

#hash_to_bib(hash) ⇒ RelatonIetf::IetfBibliographicItem

Parameters:

  • hash (Hash)

Returns:



42
43
44
# File 'lib/relaton_ietf/processor.rb', line 42

def hash_to_bib(hash)
  ::RelatonIetf::IetfBibliographicItem.from_hash hash
end

#remove_index_fileObject

Remove index file



55
56
57
58
59
# File 'lib/relaton_ietf/processor.rb', line 55

def remove_index_file
  Relaton::Index.find_or_create(:RFC, url: true, file: Scrapper::INDEX_FILE).remove_file
  Relaton::Index.find_or_create(:RSS, url: true, file: Scrapper::INDEX_FILE).remove_file
  Relaton::Index.find_or_create(:IDS, url: true, file: Scrapper::INDEX_FILE).remove_file
end