Class: Relaton::Bipm::Processor

Inherits:
Core::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.



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

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.



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

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)


35
36
37
38
# File 'lib/relaton/bipm/processor.rb', line 35

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

#from_xml(xml) ⇒ RelatonBipm::BipmBibliographicItem

Parameters:

  • xml (String)

Returns:

  • (RelatonBipm::BipmBibliographicItem)


42
43
44
45
# File 'lib/relaton/bipm/processor.rb', line 42

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

#from_yaml(yaml) ⇒ Object



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

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

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

Parameters:

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

    year

  • opts (Hash)

Returns:

  • (RelatonBipm::BipmBibliographicItem)


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

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

#grammar_hashString

Returns hash of XML grammar

Returns:

  • (String)


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

def grammar_hash
  require_relative "../bipm"
  @grammar_hash ||= Relaton::Bipm.grammar_hash
end

#remove_index_fileObject

Remove index file



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

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