Class: GeolexicaServer::Generator::Bibliography

Inherits:
Base
  • Object
show all
Defined in:
lib/geolexica_server/generator/bibliography.rb

Overview

Class for generating bibliography of the glossary

Instance Method Summary collapse

Methods inherited from Base

generate

Constructor Details

#initialize(options) ⇒ Bibliography

Returns a new instance of Bibliography.



9
10
11
12
13
14
15
16
17
# File 'lib/geolexica_server/generator/bibliography.rb', line 9

def initialize(options)
  super

  @input_file = "#{@glossary_path}/bibliography.yaml"
  @output_dir = "bibliography"

  @bibliography_map = YAML.load_file(@input_file)
  @db = Relaton::Db.new(nil, nil)
end

Instance Method Details

#generateObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/geolexica_server/generator/bibliography.rb', line 19

def generate
  Dir.mkdir(@output_dir) unless File.directory?(@output_dir)

  @bibliography_map.each do |name, identifier|
    bib =
      @db.fetch(identifier["reference"]) ||
      user_defined_bib(identifier)

    file_path = "#{@output_dir}/#{name}.yaml"
    File.write(file_path, bib.to_yaml)
  end
end