Class: Relaton::Etsi::Processor

Inherits:
Core::Processor
  • Object
show all
Defined in:
lib/relaton/etsi/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/etsi/processor.rb', line 8

def initialize # rubocop:disable Lint/MissingSuper
  @short = :relaton_etsi
  @prefix = "ETSI"
  @defaultprefix = %r{^ETSI\s}
  @idtype = "ETSI"
  @datasets = %w[etsi-csv]
end

Instance Attribute Details

#idtypeObject (readonly)

Returns the value of attribute idtype.



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

def idtype
  @idtype
end

Instance Method Details

#fetch_data(_source, opts) ⇒ Object

Fetch all the documents from www.etsi.org

Parameters:

  • _source (String)

    source name

  • opts (Hash)

Options Hash (opts):

  • :output (String)

    directory to output documents

  • :format (String)

    output format (xml, yaml, bibxml)



33
34
35
36
# File 'lib/relaton/etsi/processor.rb', line 33

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

#from_xml(xml) ⇒ Relaton::Etsi::Item

Parameters:

  • xml (String)

Returns:



40
41
42
43
# File 'lib/relaton/etsi/processor.rb', line 40

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

#from_yaml(yaml) ⇒ Relaton::Etsi::Item

Parameters:

  • yaml (String)

Returns:



47
48
49
50
# File 'lib/relaton/etsi/processor.rb', line 47

def from_yaml(yaml)
  require_relative "../etsi"
  Item.from_yaml yaml
end

#get(code, date, opts) ⇒ Relaton::Etsi::Item

Parameters:

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

    year

  • opts (Hash)

Returns:



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

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

#grammar_hashString

Returns hash of XML grammar

Returns:

  • (String)


54
55
56
57
58
# File 'lib/relaton/etsi/processor.rb', line 54

def grammar_hash
  require "relaton/bib/version"
  require_relative "version"
  Digest::MD5.hexdigest Relaton::Etsi::VERSION + Relaton::Bib::VERSION
end

#remove_index_fileObject

Remove index file



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

def remove_index_file
  require_relative "../etsi"
  Relaton::Index.find_or_create(:etsi, url: true, file: INDEX_FILE).remove_file
end