jekyll-geolexica 1.8.15 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95c0a7c0547605c1021f70db23fb61dfd5bcc394508c380d5ba7c83d62e15050
4
- data.tar.gz: dc7ebc49fd3aec4a6e3fc49432d12e6725c4acc27a68b8e8689f922a69b354a1
3
+ metadata.gz: 7bf9198ece6031ea2db54e9a6f4f8d236dbcf253aba824e92db8a103a4f650f8
4
+ data.tar.gz: 7d03d364470f0a219cb98ca1832d7fb046dbe170808588861dc090d4af927c71
5
5
  SHA512:
6
- metadata.gz: bd1b971b4fb9ab92f9f8661dc7e3476091c0470bf3c4d49111551e0284e9340ea292cd2b679e6ac6f5acc36ab2bc24f1adcb2652285784c72eff0a367a3348a2
7
- data.tar.gz: f3aef44aa0bbaa85dc494463b74f8d2cce23958065666e2216354f58f46c6c8085706de66acf4b34bc56cbd5bbda2d703bc941a520a60f867e4ac44dacb627c7
6
+ metadata.gz: a3c019c8c9be5691fa0e836352d4973efdbb3ad0f8570fac50ff748562382042b645fd54f1ea6a0f77617d445464f2aed32a1f2cf4e4f111883a31b751144866
7
+ data.tar.gz: e0c1764ad91b3d49ed30fa235e1714af75571e1578f1d32872320d864bb92bb64e12a413752a96822eae21c428283f3a31605bac32520d36da7a7efc4f5461ba
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
36
  spec.require_paths = ["lib"]
37
37
 
38
+ spec.add_runtime_dependency "glossarist", "~> 2.0"
38
39
  # Jekyll 4.1.0 adds some breaking changes which are reverted in 4.1.1.
39
40
  # I doubt we should be worried, but there is no good reason to allow them
40
41
  # either.
@@ -16,6 +16,11 @@ module Jekyll
16
16
  File.expand_path(path, site.source)
17
17
  end
18
18
 
19
+ def glossary_path
20
+ glob_string = glossary_config["glossary_path"]
21
+ File.expand_path(glob_string, site.source)
22
+ end
23
+
19
24
  def glossary_format
20
25
  glossary_config["format"]
21
26
  end
@@ -13,11 +13,27 @@ module Jekyll
13
13
 
14
14
  def initialize(site)
15
15
  @site = site
16
+ @collection = Glossarist::ManagedConceptCollection.new
16
17
  end
17
18
 
18
19
  def load_glossary
19
20
  Jekyll.logger.info('Geolexica:', 'Loading concepts')
20
- Dir.glob(concepts_glob).each { |path| load_concept(path) }
21
+ @collection.load_from_files(glossary_path)
22
+
23
+ @collection.each do |managed_concept|
24
+ concept_hash = {
25
+ "id" => managed_concept.uuid,
26
+ "term" => managed_concept.default_designation,
27
+ "termid" => managed_concept.id,
28
+ }.merge(managed_concept.to_h)
29
+
30
+ managed_concept.localizations.each do |lang, localization|
31
+ concept_hash[lang] = localization.to_h["data"]
32
+ end
33
+
34
+ preprocess_concept_hash(concept_hash)
35
+ store(Concept.new(concept_hash))
36
+ end
21
37
  end
22
38
 
23
39
  def store(concept)
@@ -37,70 +53,6 @@ module Jekyll
37
53
 
38
54
  protected
39
55
 
40
- def load_concept(concept_file_path)
41
- Jekyll.logger.debug('Geolexica:',
42
- "reading concept from file #{concept_file_path}")
43
-
44
- concept_hash = if glossary_format == 'paneron'
45
- read_paneron_concept_file(concept_file_path)
46
- else
47
- read_concept_file(concept_file_path)
48
- end
49
-
50
- preprocess_concept_hash(concept_hash)
51
- store Concept.new(concept_hash)
52
- rescue StandardError
53
- Jekyll.logger.error('Geolexica:',
54
- "failed to read concept from file #{concept_file_path}")
55
- raise
56
- end
57
-
58
- # Reads and parses concept file located at given path.
59
- def read_concept_file(path)
60
- YAML.safe_load(File.read(path), permitted_classes: [Time])
61
- end
62
-
63
- def read_paneron_concept_file(path)
64
- safe_load_options = { permitted_classes: [Date, Time] }
65
- concept = YAML.safe_load(File.read(path), **safe_load_options)
66
- concept['termid'] = concept['data']['identifier']
67
-
68
- (concept['data']['localizedConcepts'] || []).each do |lang, local_concept_id|
69
- localized_concept_path = File.join(localized_concepts_path, "#{local_concept_id}.yaml")
70
- concept[lang] = YAML.safe_load(File.read(localized_concept_path), **safe_load_options)['data']
71
-
72
- next unless concept[lang]
73
-
74
- normalize_sources(concept[lang])
75
- concept['term'] = concept[lang]['terms'].first['designation'] if lang == 'eng'
76
- end
77
-
78
- concept
79
- end
80
-
81
- def normalize_sources(concept)
82
- authoritative_sources = concept.delete('authoritativeSource') || []
83
- concept['sources'] ||= []
84
-
85
- authoritative_sources.each do |authoritative_source|
86
- if authoritative_source['relationship']
87
- status = authoritative_source['relationship']['type']
88
- modification = authoritative_source['relationship']['modification']
89
- end
90
-
91
- concept['sources'] << {
92
- "status" => status,
93
- "modification" => modification,
94
- "origin" => {
95
- 'ref' => authoritative_source['ref'],
96
- 'clause' => authoritative_source['clause'],
97
- 'link' => authoritative_source['link'],
98
- }.compact,
99
- 'type' => 'authoritative'
100
- }.compact
101
- end
102
- end
103
-
104
56
  # Does nothing, but some sites may replace this method.
105
57
  def preprocess_concept_hash(concept_hash); end
106
58
 
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Jekyll
5
5
  module Geolexica
6
- VERSION = "1.8.15".freeze
6
+ VERSION = "1.9.0".freeze
7
7
  end
8
8
  end
@@ -2,6 +2,7 @@
2
2
  #
3
3
 
4
4
  require "jekyll"
5
+ require "glossarist"
5
6
 
6
7
  module Jekyll
7
8
  module Geolexica
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-geolexica
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.15
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-24 00:00:00.000000000 Z
11
+ date: 2024-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: glossarist
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: jekyll
15
29
  requirement: !ruby/object:Gem::Requirement