Class: Jekyll::Geolexica::Glossary

Inherits:
Hash
  • Object
show all
Includes:
Configuration
Defined in:
lib/jekyll/geolexica/glossary.rb

Defined Under Namespace

Classes: Concept

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configuration

#bibliography_path, #concepts_glob, #glossary_format, #glossary_path, #images_metadata_path, #images_path, #localized_concepts_path, #output_html?, #output_json?, #output_jsonld?, #output_tbx?, #output_turtle?, #output_yaml?, #report_issue_url, #suggest_translation_url, #term_languages

Constructor Details

#initialize(site) ⇒ Glossary

Returns a new instance of Glossary.



14
15
16
17
# File 'lib/jekyll/geolexica/glossary.rb', line 14

def initialize(site)
  @site = site
  @collection = Glossarist::ManagedConceptCollection.new
end

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



9
10
11
# File 'lib/jekyll/geolexica/glossary.rb', line 9

def site
  @site
end

Instance Method Details

#language_statisticsObject



45
46
47
# File 'lib/jekyll/geolexica/glossary.rb', line 45

def language_statistics
  @language_statistics ||= calculate_language_statistics
end

#load_glossaryObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jekyll/geolexica/glossary.rb', line 19

def load_glossary
  Jekyll.logger.info("Geolexica:", "Loading concepts")
  @collection.load_from_files(glossary_path)

  @collection.each do |managed_concept|
    concept_hash = {
      "id" => managed_concept.uuid,
      "term" => managed_concept.default_designation,
      "termid" => managed_concept.data.id,
      "status" => managed_concept.status,
    }.merge(managed_concept.to_yaml_hash)

    managed_concept.localizations.each do |lang, localization|
      concept_hash[lang] =
        localization.to_yaml_hash["data"].merge({ "status" => localization.entry_status })
    end

    preprocess_concept_hash(concept_hash)
    store(Concept.new(concept_hash))
  end
end

#store(concept) ⇒ Object



41
42
43
# File 'lib/jekyll/geolexica/glossary.rb', line 41

def store(concept)
  super(concept.data["termid"], concept)
end

#to_liquidObject

Defines how Glossary is exposed in Liquid templates.



50
51
52
53
54
# File 'lib/jekyll/geolexica/glossary.rb', line 50

def to_liquid
  {
    "language_statistics" => language_statistics,
  }
end