Class: RelatonBipm::Processor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProcessor

Returns a new instance of Processor.



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

def initialize
  @short = :relaton_bipm
  @prefix = "BIPM"
  @defaultprefix = %r{^(?:BIPM|CCTF|CCDS|CGPM|CIPM|JCRB|JCGM)(?!\w)}
  @idtype = "BIPM"
  @datasets = %w[bipm-data-outcomes bipm-si-brochure rawdata-bipm-metrologia]
end

Instance Attribute Details

#idtypeObject (readonly)

Returns the value of attribute idtype.



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

def idtype
  @idtype
end

Instance Method Details

#fetch_data(source, opts) ⇒ Object

Fetch all the documents from github.com/metanorma/bipm-data-outcomes,

https://github.com/metanorma/bipm-si-brochure, https://github.com/relaton/rawdata-bipm-metrologia

Parameters:

  • source (String)

    source name (bipm-data-outcomes, bipm-si-brochure, rawdata-bipm-metrologia)

  • opts (Hash)

Options Hash (opts):

  • :output (String)

    directory to output documents

  • :format (String)


33
34
35
# File 'lib/relaton_bipm/processor.rb', line 33

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

#from_xml(xml) ⇒ RelatonBipm::BipmBibliographicItem

Parameters:

  • xml (String)

Returns:



39
40
41
# File 'lib/relaton_bipm/processor.rb', line 39

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

#get(code, date, opts) ⇒ RelatonBipm::BipmBibliographicItem

Parameters:

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

    year

  • opts (Hash)

Returns:



19
20
21
# File 'lib/relaton_bipm/processor.rb', line 19

def get(code, date, opts)
  ::RelatonBipm::BipmBibliography.get(code, date, opts)
end

#grammar_hashString

Returns hash of XML grammar

Returns:

  • (String)


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

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

#hash_to_bib(hash) ⇒ RelatonBipm::BipmBibliographicItem

Parameters:

  • hash (Hash)

Returns:



45
46
47
# File 'lib/relaton_bipm/processor.rb', line 45

def hash_to_bib(hash)
  ::RelatonBipm::BipmBibliographicItem.from_hash hash
end

#remove_index_fileObject

Remove index file



58
59
60
# File 'lib/relaton_bipm/processor.rb', line 58

def remove_index_file
  Relaton::Index.find_or_create(:bipm, url: true, file: BipmBibliography::INDEX_FILE).remove_file
end