glossarist 2.8.2 → 2.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +78 -64
  3. data/glossarist.gemspec +1 -1
  4. data/lib/glossarist/bibliography_data.rb +41 -0
  5. data/lib/glossarist/bibliography_entry.rb +13 -0
  6. data/lib/glossarist/citation.rb +8 -2
  7. data/lib/glossarist/cli/export_command.rb +10 -5
  8. data/lib/glossarist/cli/validate_command.rb +21 -5
  9. data/lib/glossarist/collection.rb +2 -2
  10. data/lib/glossarist/collections/bibliography_collection.rb +2 -1
  11. data/lib/glossarist/collections/collection.rb +2 -2
  12. data/lib/glossarist/collections/localization_collection.rb +4 -4
  13. data/lib/glossarist/concept_collector.rb +6 -6
  14. data/lib/glossarist/concept_document.rb +2 -1
  15. data/lib/glossarist/concept_manager.rb +6 -7
  16. data/lib/glossarist/concept_reference.rb +4 -0
  17. data/lib/glossarist/concept_set.rb +4 -4
  18. data/lib/glossarist/concept_store.rb +38 -50
  19. data/lib/glossarist/dataset_register.rb +72 -0
  20. data/lib/glossarist/dataset_validator.rb +2 -1
  21. data/lib/glossarist/gcr_metadata.rb +8 -5
  22. data/lib/glossarist/gcr_package_definition.rb +35 -0
  23. data/lib/glossarist/gcr_statistics.rb +2 -2
  24. data/lib/glossarist/glossary_definition.rb +1 -1
  25. data/lib/glossarist/glossary_store.rb +198 -0
  26. data/lib/glossarist/managed_concept_collection.rb +2 -2
  27. data/lib/glossarist/rdf/gloss_citation.rb +8 -4
  28. data/lib/glossarist/rdf/gloss_concept.rb +6 -3
  29. data/lib/glossarist/rdf/gloss_concept_date.rb +4 -2
  30. data/lib/glossarist/rdf/gloss_concept_reference.rb +6 -3
  31. data/lib/glossarist/rdf/gloss_concept_source.rb +6 -3
  32. data/lib/glossarist/rdf/gloss_designation.rb +56 -25
  33. data/lib/glossarist/rdf/gloss_grammar_info.rb +19 -9
  34. data/lib/glossarist/rdf/gloss_locality.rb +6 -3
  35. data/lib/glossarist/rdf/gloss_localized_concept.rb +14 -7
  36. data/lib/glossarist/rdf/gloss_non_verbal_rep.rb +9 -4
  37. data/lib/glossarist/rdf/gloss_pronunciation.rb +13 -6
  38. data/lib/glossarist/rdf/gloss_reference.rb +8 -4
  39. data/lib/glossarist/rdf/namespaces.rb +3 -2
  40. data/lib/glossarist/rdf/relationship_predicates.rb +14 -7
  41. data/lib/glossarist/rdf.rb +2 -1
  42. data/lib/glossarist/register_data.rb +72 -18
  43. data/lib/glossarist/schema_migration.rb +8 -5
  44. data/lib/glossarist/section.rb +39 -0
  45. data/lib/glossarist/transforms/concept_to_gloss_transform.rb +24 -11
  46. data/lib/glossarist/v2/concept_data.rb +2 -1
  47. data/lib/glossarist/v2/concept_document.rb +1 -1
  48. data/lib/glossarist/v3/concept_data.rb +2 -1
  49. data/lib/glossarist/v3/concept_document.rb +1 -1
  50. data/lib/glossarist/validation/asset_index.rb +2 -2
  51. data/lib/glossarist/validation/bibliography_index.rb +2 -1
  52. data/lib/glossarist/validation/rules/asciidoc_xref_rule.rb +2 -1
  53. data/lib/glossarist/validation/rules/authoritative_source_rule.rb +1 -1
  54. data/lib/glossarist/validation/rules/bibliography_yaml_rule.rb +1 -1
  55. data/lib/glossarist/validation/rules/citation_completeness_rule.rb +1 -1
  56. data/lib/glossarist/validation/rules/concept_count_rule.rb +2 -3
  57. data/lib/glossarist/validation/rules/concept_id_rule.rb +0 -1
  58. data/lib/glossarist/validation/rules/concept_id_uniqueness_rule.rb +0 -1
  59. data/lib/glossarist/validation/rules/concept_mention_rule.rb +1 -2
  60. data/lib/glossarist/validation/rules/concept_status_rule.rb +1 -2
  61. data/lib/glossarist/validation/rules/concept_uri_rule.rb +1 -1
  62. data/lib/glossarist/validation/rules/date_type_rule.rb +5 -3
  63. data/lib/glossarist/validation/rules/date_validity_rule.rb +1 -1
  64. data/lib/glossarist/validation/rules/definition_content_rule.rb +1 -2
  65. data/lib/glossarist/validation/rules/domain_target_rule.rb +1 -1
  66. data/lib/glossarist/validation/rules/duplicate_term_rule.rb +1 -2
  67. data/lib/glossarist/validation/rules/entry_status_rule.rb +1 -2
  68. data/lib/glossarist/validation/rules/filename_id_rule.rb +2 -3
  69. data/lib/glossarist/validation/rules/image_reference_rule.rb +3 -2
  70. data/lib/glossarist/validation/rules/l10n_uuid_integrity_rule.rb +1 -2
  71. data/lib/glossarist/validation/rules/language_coverage_rule.rb +1 -2
  72. data/lib/glossarist/validation/rules/language_list_rule.rb +2 -3
  73. data/lib/glossarist/validation/rules/locality_completeness_rule.rb +3 -1
  74. data/lib/glossarist/validation/rules/localization_consistency_rule.rb +1 -1
  75. data/lib/glossarist/validation/rules/localization_presence_rule.rb +0 -1
  76. data/lib/glossarist/validation/rules/model_validity_rule.rb +1 -1
  77. data/lib/glossarist/validation/rules/orphaned_bibliography_rule.rb +2 -1
  78. data/lib/glossarist/validation/rules/orphaned_images_rule.rb +6 -4
  79. data/lib/glossarist/validation/rules/orphaned_l10n_files_rule.rb +1 -2
  80. data/lib/glossarist/validation/rules/preferred_term_rule.rb +1 -2
  81. data/lib/glossarist/validation/rules/related_concept_cycle_rule.rb +2 -2
  82. data/lib/glossarist/validation/rules/related_concept_rule.rb +1 -2
  83. data/lib/glossarist/validation/rules/related_concept_symmetry_rule.rb +1 -1
  84. data/lib/glossarist/validation/rules/related_concept_target_rule.rb +1 -1
  85. data/lib/glossarist/validation/rules/source_type_rule.rb +2 -2
  86. data/lib/glossarist/validation/rules/source_urn_format_rule.rb +2 -2
  87. data/lib/glossarist/validation/rules/terms_presence_rule.rb +1 -1
  88. data/lib/glossarist/validation/rules/uuid_format_rule.rb +1 -1
  89. data/lib/glossarist/version.rb +1 -1
  90. data/lib/glossarist.rb +7 -0
  91. data/scripts/migrate_dataset.rb +14 -8
  92. data/scripts/migrate_isotc204_to_v3.rb +3 -1
  93. data/scripts/migrate_isotc211_to_v3.rb +5 -3
  94. data/scripts/migrate_osgeo_to_v3.rb +4 -2
  95. data/scripts/upgrade_dataset_to_v3.rb +0 -0
  96. metadata +15 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f602beb2e985225705695343d1309f242117b6b59398f27b9b7d4966e2300c98
4
- data.tar.gz: e5891cad0fd4efecac7140d007f36efe0a2f83609013a771ac02621199ba0306
3
+ metadata.gz: bb636339e439da216185715fcfe387842aabd1b38147dd49b5e4fdb5909b6d2d
4
+ data.tar.gz: 2704b81c1f4d179d8909bc1d245b9caee83d2e54fa56a6148699892f021e9d6f
5
5
  SHA512:
6
- metadata.gz: 97a81b187d34665f43c2800b3ac7636de9ae71b83c832bb9fdba0f5d9895089f6c3229ba80d38b3e9b0479ab71f16bf282b924c4ee1f9292059c250ade950cfe
7
- data.tar.gz: 5d5c43b11134a5f072d80d99c5110471dae8145a4c3212aa9cce49ac1c491fd478f748cd4f57adf97a5c3212a41c7ca679c31a07b6018cda6ecf77cdef3fff64
6
+ metadata.gz: 5e39df7a02295426fb6463f93189cf6e3d457e60457b9bb5cde1881eeb549fe1afd4730e3ac280030be8de60734dbc2e0532b14030890e107b9df35dabbd1ede
7
+ data.tar.gz: 5e4ef4cf71118c020f29b105bb81bb19d753dcb9484f367d0a2caab0b51927e7bcf69e325549bb4e7f44f9f1ec571ffb4223710ca8cc7987dd10eb4750148514
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2026-05-13 07:45:58 UTC using RuboCop version 1.86.1.
3
+ # on 2026-06-04 14:04:56 UTC using RuboCop version 1.86.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -11,30 +11,49 @@ Gemspec/RequiredRubyVersion:
11
11
  Exclude:
12
12
  - 'glossarist.gemspec'
13
13
 
14
- # Offense count: 3
14
+ # Offense count: 6
15
15
  # This cop supports safe autocorrection (--autocorrect).
16
16
  # Configuration parameters: EnforcedStyle, IndentationWidth.
17
17
  # SupportedStyles: with_first_argument, with_fixed_indentation
18
18
  Layout/ArgumentAlignment:
19
19
  Exclude:
20
- - 'lib/glossarist/designation/expression.rb'
21
- - 'spec/unit/designations_spec.rb'
20
+ - 'spec/unit/section_spec.rb'
22
21
 
23
- # Offense count: 1
22
+ # Offense count: 3
24
23
  # This cop supports safe autocorrection (--autocorrect).
25
24
  # Configuration parameters: EnforcedStyleAlignWith.
26
25
  # SupportedStylesAlignWith: either, start_of_block, start_of_line
27
26
  Layout/BlockAlignment:
28
27
  Exclude:
29
- - 'spec/unit/designations_spec.rb'
28
+ - 'spec/unit/section_spec.rb'
30
29
 
31
- # Offense count: 1
30
+ # Offense count: 3
32
31
  # This cop supports safe autocorrection (--autocorrect).
33
32
  Layout/BlockEndNewline:
34
33
  Exclude:
35
- - 'spec/unit/designations_spec.rb'
34
+ - 'spec/unit/section_spec.rb'
36
35
 
37
- # Offense count: 7
36
+ # Offense count: 1
37
+ # This cop supports safe autocorrection (--autocorrect).
38
+ Layout/EmptyLineAfterGuardClause:
39
+ Exclude:
40
+ - 'lib/glossarist/section.rb'
41
+
42
+ # Offense count: 1
43
+ # This cop supports safe autocorrection (--autocorrect).
44
+ Layout/EmptyLines:
45
+ Exclude:
46
+ - 'Gemfile'
47
+
48
+ # Offense count: 2
49
+ # This cop supports safe autocorrection (--autocorrect).
50
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
51
+ # SupportedStyles: special_inside_parentheses, consistent, align_braces
52
+ Layout/FirstHashElementIndentation:
53
+ Exclude:
54
+ - 'spec/unit/section_spec.rb'
55
+
56
+ # Offense count: 8
38
57
  # This cop supports safe autocorrection (--autocorrect).
39
58
  # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
40
59
  # SupportedHashRocketStyles: key, separator, table
@@ -42,32 +61,39 @@ Layout/BlockEndNewline:
42
61
  # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
43
62
  Layout/HashAlignment:
44
63
  Exclude:
45
- - 'spec/unit/concept_data_spec.rb'
46
- - 'spec/unit/designations_spec.rb'
64
+ - 'spec/unit/dataset_register_spec.rb'
65
+ - 'spec/unit/section_spec.rb'
47
66
 
48
- # Offense count: 2
67
+ # Offense count: 6
49
68
  # This cop supports safe autocorrection (--autocorrect).
50
69
  # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
51
70
  # SupportedStylesAlignWith: start_of_line, relative_to_receiver
52
71
  Layout/IndentationWidth:
53
72
  Exclude:
54
- - 'spec/unit/designations_spec.rb'
73
+ - 'spec/unit/section_spec.rb'
55
74
 
56
- # Offense count: 267
75
+ # Offense count: 424
57
76
  # This cop supports safe autocorrection (--autocorrect).
58
77
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
59
78
  # URISchemes: http, https
60
79
  Layout/LineLength:
61
80
  Enabled: false
62
81
 
82
+ # Offense count: 1
83
+ # This cop supports safe autocorrection (--autocorrect).
84
+ # Configuration parameters: EnforcedStyle.
85
+ # SupportedStyles: symmetrical, new_line, same_line
86
+ Layout/MultilineHashBraceLayout:
87
+ Exclude:
88
+ - 'spec/unit/section_spec.rb'
89
+
63
90
  # Offense count: 7
64
91
  # This cop supports safe autocorrection (--autocorrect).
65
92
  # Configuration parameters: AllowInHeredoc.
66
93
  Layout/TrailingWhitespace:
67
94
  Exclude:
68
- - 'lib/glossarist/designation/expression.rb'
69
- - 'spec/unit/concept_data_spec.rb'
70
- - 'spec/unit/designations_spec.rb'
95
+ - 'spec/unit/dataset_register_spec.rb'
96
+ - 'spec/unit/section_spec.rb'
71
97
 
72
98
  # Offense count: 1
73
99
  # Configuration parameters: AllowedMethods.
@@ -76,6 +102,12 @@ Lint/ConstantDefinitionInBlock:
76
102
  Exclude:
77
103
  - 'spec/unit/utilities/common_functions_spec.rb'
78
104
 
105
+ # Offense count: 1
106
+ # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
107
+ Lint/DuplicateBranch:
108
+ Exclude:
109
+ - 'scripts/migrate_dataset.rb'
110
+
79
111
  # Offense count: 1
80
112
  # This cop supports safe autocorrection (--autocorrect).
81
113
  # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
@@ -84,55 +116,36 @@ Lint/UnusedMethodArgument:
84
116
  Exclude:
85
117
  - 'lib/glossarist/dataset_validator.rb'
86
118
 
87
- # Offense count: 37
119
+ # Offense count: 85
88
120
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
89
121
  Metrics/AbcSize:
90
122
  Enabled: false
91
123
 
92
- # Offense count: 24
124
+ # Offense count: 7
125
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
126
+ # AllowedMethods: refine
127
+ Metrics/BlockLength:
128
+ Max: 41
129
+
130
+ # Offense count: 52
93
131
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
94
132
  Metrics/CyclomaticComplexity:
95
- Exclude:
96
- - 'lib/glossarist/cli/export_command.rb'
97
- - 'lib/glossarist/concept_validator.rb'
98
- - 'lib/glossarist/designation/expression.rb'
99
- - 'lib/glossarist/gcr_metadata.rb'
100
- - 'lib/glossarist/gcr_statistics.rb'
101
- - 'lib/glossarist/gcr_validator.rb'
102
- - 'lib/glossarist/managed_concept.rb'
103
- - 'lib/glossarist/reference_extractor.rb'
104
- - 'lib/glossarist/reference_resolver.rb'
105
- - 'lib/glossarist/resolution_adapter/local.rb'
106
- - 'lib/glossarist/schema_migration.rb'
107
- - 'lib/glossarist/transforms/concept_to_skos_transform.rb'
108
- - 'lib/glossarist/transforms/concept_to_tbx_transform.rb'
109
- - 'lib/glossarist/validation/bibliography_index.rb'
133
+ Enabled: false
110
134
 
111
- # Offense count: 48
135
+ # Offense count: 107
112
136
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
113
137
  Metrics/MethodLength:
114
- Max: 42
138
+ Max: 47
115
139
 
116
- # Offense count: 4
140
+ # Offense count: 5
117
141
  # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
118
142
  Metrics/ParameterLists:
119
143
  Max: 6
120
144
 
121
- # Offense count: 18
145
+ # Offense count: 38
122
146
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
123
147
  Metrics/PerceivedComplexity:
124
- Exclude:
125
- - 'lib/glossarist/concept_validator.rb'
126
- - 'lib/glossarist/designation/expression.rb'
127
- - 'lib/glossarist/gcr_metadata.rb'
128
- - 'lib/glossarist/gcr_validator.rb'
129
- - 'lib/glossarist/reference_extractor.rb'
130
- - 'lib/glossarist/reference_resolver.rb'
131
- - 'lib/glossarist/resolution_adapter/local.rb'
132
- - 'lib/glossarist/schema_migration.rb'
133
- - 'lib/glossarist/transforms/concept_to_skos_transform.rb'
134
- - 'lib/glossarist/transforms/concept_to_tbx_transform.rb'
135
- - 'lib/glossarist/validation/bibliography_index.rb'
148
+ Enabled: false
136
149
 
137
150
  # Offense count: 6
138
151
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
@@ -141,13 +154,16 @@ Naming/MethodParameterName:
141
154
  Exclude:
142
155
  - 'lib/glossarist/schema_migration.rb'
143
156
 
144
- # Offense count: 3
145
- # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
146
- # SupportedStyles: snake_case, normalcase, non_integer
147
- # AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
148
- Naming/VariableNumber:
157
+ # Offense count: 5
158
+ # This cop supports safe autocorrection (--autocorrect).
159
+ # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
160
+ # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
161
+ # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
162
+ # FunctionalMethods: let, let!, subject, watch
163
+ # AllowedMethods: lambda, proc, it
164
+ Style/BlockDelimiters:
149
165
  Exclude:
150
- - 'spec/unit/rdf/skos_vocabulary_spec.rb'
166
+ - 'spec/unit/section_spec.rb'
151
167
 
152
168
  # Offense count: 6
153
169
  # This cop supports safe autocorrection (--autocorrect).
@@ -156,18 +172,16 @@ Naming/VariableNumber:
156
172
  Style/FormatStringToken:
157
173
  EnforcedStyle: unannotated
158
174
 
159
- # Offense count: 1
160
- # Configuration parameters: AllowedClasses.
161
- Style/OneClassPerFile:
175
+ # Offense count: 2
176
+ # This cop supports unsafe autocorrection (--autocorrect-all).
177
+ Style/IdenticalConditionalBranches:
162
178
  Exclude:
163
- - 'spec/**/*'
164
- - 'test/**/*'
165
- - 'lib/glossarist.rb'
179
+ - 'scripts/migrate_dataset.rb'
166
180
 
167
- # Offense count: 4
181
+ # Offense count: 3
168
182
  # Configuration parameters: Max.
169
183
  Style/SafeNavigationChainLength:
170
184
  Exclude:
171
185
  - 'lib/glossarist/managed_concept.rb'
172
- - 'lib/glossarist/transforms/concept_to_skos_transform.rb'
173
186
  - 'lib/glossarist/transforms/concept_to_tbx_transform.rb'
187
+ - 'lib/glossarist/validation/rules/source_urn_format_rule.rb'
data/glossarist.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.require_paths = ["lib"]
33
33
 
34
34
  spec.add_dependency "lutaml-model", "~> 0.8.15"
35
- spec.add_dependency "lutaml-store", "~> 0.1.1"
35
+ spec.add_dependency "lutaml-store", "~> 0.2.0"
36
36
  spec.add_dependency "paint", "~> 2.3"
37
37
  spec.add_dependency "relaton", ">= 2.0.0", "< 3"
38
38
  spec.add_dependency "rubyzip", ">= 2.3", "< 3"
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Glossarist
4
+ class BibliographyData < Lutaml::Model::Serializable
5
+ attribute :shortname, :string, default: -> { "bibliography" }
6
+ attribute :entries, BibliographyEntry, collection: true,
7
+ initialize_empty: true
8
+
9
+ key_value do
10
+ map nil, to: :entries,
11
+ with: { from: :entries_from_hash, to: :entries_to_hash }
12
+ end
13
+
14
+ def find(citation_key)
15
+ entries.find { |e| e.citation_key == citation_key }
16
+ end
17
+
18
+ def keys
19
+ entries.map(&:citation_key)
20
+ end
21
+
22
+ def [](citation_key)
23
+ entry = find(citation_key)
24
+ entry&.data
25
+ end
26
+
27
+ def entries_from_hash(model, value)
28
+ return unless value.is_a?(Hash)
29
+
30
+ model.entries = value.map do |key, data|
31
+ BibliographyEntry.new(citation_key: key, data: data || {})
32
+ end
33
+ end
34
+
35
+ def entries_to_hash(model, doc)
36
+ model.entries.each do |entry|
37
+ doc[entry.citation_key] = entry.data
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Glossarist
4
+ class BibliographyEntry < Lutaml::Model::Serializable
5
+ attribute :citation_key, :string
6
+ attribute :data, :hash, default: -> { {} }
7
+
8
+ key_value do
9
+ map "citation_key", to: :citation_key
10
+ map "data", to: :data
11
+ end
12
+ end
13
+ end
@@ -56,8 +56,14 @@ module Glossarist
56
56
 
57
57
  doc["locality"] = {}
58
58
  doc["locality"]["type"] = model.locality.type
59
- doc["locality"]["reference_from"] = model.locality.reference_from if model.locality.reference_from
60
- doc["locality"]["reference_to"] = model.locality.reference_to if model.locality.reference_to
59
+ if model.locality.reference_from
60
+ doc["locality"]["reference_from"] =
61
+ model.locality.reference_from
62
+ end
63
+ if model.locality.reference_to
64
+ doc["locality"]["reference_to"] =
65
+ model.locality.reference_to
66
+ end
61
67
  end
62
68
  end
63
69
  end
@@ -74,14 +74,18 @@ module Glossarist
74
74
 
75
75
  def export_jsonld(concepts, name, output_dir)
76
76
  require "glossarist/transforms/concept_to_gloss_transform"
77
- transform = Transforms::ConceptToGlossTransform.new(nil, transform_options)
78
- File.write(File.join(output_dir, "#{name}.jsonld"), transform.to_jsonld(concepts))
77
+ transform = Transforms::ConceptToGlossTransform.new(nil,
78
+ transform_options)
79
+ File.write(File.join(output_dir, "#{name}.jsonld"),
80
+ transform.to_jsonld(concepts))
79
81
  end
80
82
 
81
83
  def export_turtle(concepts, name, output_dir)
82
84
  require "glossarist/transforms/concept_to_gloss_transform"
83
- transform = Transforms::ConceptToGlossTransform.new(nil, transform_options)
84
- File.write(File.join(output_dir, "#{name}.ttl"), transform.to_turtle(concepts))
85
+ transform = Transforms::ConceptToGlossTransform.new(nil,
86
+ transform_options)
87
+ File.write(File.join(output_dir, "#{name}.ttl"),
88
+ transform.to_turtle(concepts))
85
89
  end
86
90
 
87
91
  def export_tbx(concepts, name, output_dir)
@@ -95,7 +99,8 @@ module Glossarist
95
99
  require "glossarist/transforms/concept_to_gloss_transform"
96
100
  File.open(File.join(output_dir, "#{name}.jsonl"), "w") do |f|
97
101
  concepts.each do |concept|
98
- transform = Transforms::ConceptToGlossTransform.new(concept, transform_options)
102
+ transform = Transforms::ConceptToGlossTransform.new(concept,
103
+ transform_options)
99
104
  f.write(transform.to_jsonl_line)
100
105
  f.write("\n")
101
106
  end
@@ -37,7 +37,8 @@ module Glossarist
37
37
  filled = (current.to_f / total * bar_width).round
38
38
  bar = "#{'█' * filled}#{'░' * (bar_width - filled)}"
39
39
 
40
- $stderr.print "\r #{Paint['Validating', :bold]} #{bar} #{current}/#{total} (#{pct}%)"
40
+ $stderr.print "\r #{Paint['Validating',
41
+ :bold]} #{bar} #{current}/#{total} (#{pct}%)"
41
42
  $stderr.flush
42
43
  end
43
44
 
@@ -96,18 +97,33 @@ module Glossarist
96
97
  msg_col = 21
97
98
 
98
99
  puts " #{label} #{code} #{issue.message}"
99
- puts "#{' ' * msg_col}#{Paint[issue.suggestion, :green]}" if issue.suggestion
100
+ if issue.suggestion
101
+ puts "#{' ' * msg_col}#{Paint[issue.suggestion,
102
+ :green]}"
103
+ end
100
104
  end
101
105
 
102
106
  def print_summary_line(result)
103
107
  error_count = result.issues.count(&:error?)
104
108
  warning_count = result.issues.count(&:warning?)
105
109
 
106
- status = error_count.positive? ? Paint["INVALID", :red, :bold] : Paint["VALID", :green, :bold]
110
+ status = if error_count.positive?
111
+ Paint["INVALID", :red,
112
+ :bold]
113
+ else
114
+ Paint["VALID", :green,
115
+ :bold]
116
+ end
107
117
 
108
118
  details = []
109
- details << Paint["#{error_count} error(s)", :red] if error_count.positive?
110
- details << Paint["#{warning_count} warning(s)", :yellow] if warning_count.positive?
119
+ if error_count.positive?
120
+ details << Paint["#{error_count} error(s)",
121
+ :red]
122
+ end
123
+ if warning_count.positive?
124
+ details << Paint["#{warning_count} warning(s)",
125
+ :yellow]
126
+ end
111
127
 
112
128
  puts " #{status} #{details.join(', ')}"
113
129
  end
@@ -15,8 +15,8 @@ module Glossarist
15
15
  @index = {}
16
16
  end
17
17
 
18
- def each(&block)
19
- @index.each_value(&block)
18
+ def each(&)
19
+ @index.each_value(&)
20
20
  end
21
21
 
22
22
  # Returns concept with given ID, if it is present in collection, or +nil+
@@ -7,7 +7,7 @@ module Glossarist
7
7
  class BibliographyCollection < Relaton::Db
8
8
  def initialize(_concepts, global_cache, local_cache)
9
9
  @version_mismatch = check_cache_version(local_cache) ||
10
- check_cache_version(global_cache)
10
+ check_cache_version(global_cache)
11
11
  super(global_cache, local_cache)
12
12
  end
13
13
 
@@ -40,6 +40,7 @@ module Glossarist
40
40
  concepts.each do |concept|
41
41
  concept.default_lang.sources.each do |source|
42
42
  next if source.origin.ref.nil?
43
+
43
44
  ref_text = source.origin.ref.source
44
45
  next if ref_text.nil?
45
46
 
@@ -18,8 +18,8 @@ module Glossarist
18
18
  @collection << @klass.new(object)
19
19
  end
20
20
 
21
- def each(&block)
22
- @collection.each(&block)
21
+ def each(&)
22
+ @collection.each(&)
23
23
  end
24
24
 
25
25
  def empty?
@@ -27,12 +27,12 @@ module Glossarist
27
27
  to_a
28
28
  end
29
29
 
30
- def each_key(&block)
31
- keys.each(&block)
30
+ def each_key(&)
31
+ keys.each(&)
32
32
  end
33
33
 
34
- def each_value(&block)
35
- values.each(&block)
34
+ def each_value(&)
35
+ values.each(&)
36
36
  end
37
37
  end
38
38
  end
@@ -136,25 +136,25 @@ module Glossarist
136
136
  end
137
137
  end
138
138
 
139
- def each_v2_concept(dir, &block)
139
+ def each_v2_concept(dir, &)
140
140
  if v2_flat_concepts?(dir)
141
- each_grouped_v2_concepts(File.join(dir, "concepts"), &block)
141
+ each_grouped_v2_concepts(File.join(dir, "concepts"), &)
142
142
  else
143
143
  v2_dir = File.join(dir, "geolexica-v2")
144
144
  if File.directory?(File.join(v2_dir, "concepts"))
145
- each_managed_concept(v2_dir, &block)
145
+ each_managed_concept(v2_dir, &)
146
146
  else
147
- each_grouped_v2_concepts(v2_dir, &block)
147
+ each_grouped_v2_concepts(v2_dir, &)
148
148
  end
149
149
  end
150
150
  end
151
151
 
152
- def each_grouped_v2_concepts(v2_dir, &block)
152
+ def each_grouped_v2_concepts(v2_dir, &)
153
153
  collection = ManagedConceptCollection.new
154
154
  manager = ConceptManager.new(path: v2_dir)
155
155
  manager.version = detect_schema_version(v2_dir)
156
156
  manager.load_from_files(collection: collection)
157
- collection.each(&block)
157
+ collection.each(&)
158
158
  end
159
159
 
160
160
  def collect_grouped_v2_concepts(v2_dir)
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Glossarist
4
4
  class ConceptDocument < Lutaml::Model::Serializable
5
+ attribute :id, :string
5
6
  attribute :concept, ManagedConcept
6
7
  attribute :localizations, LocalizedConcept, collection: true
7
8
 
@@ -9,7 +10,7 @@ module Glossarist
9
10
  sequence do
10
11
  map_document 0, to: :concept, type: ManagedConcept
11
12
  map_document 1.., to: :localizations, type: LocalizedConcept,
12
- collection: true
13
+ collection: true
13
14
  end
14
15
  end
15
16
 
@@ -132,13 +132,12 @@ module Glossarist
132
132
  if v1_collection?
133
133
  File.join(path, "concept-*.{yaml,yml}")
134
134
  else
135
- # normal v2 collection
136
- concepts_glob = File.join(path, "concept", "*.{yaml,yml}")
137
- if Dir.glob(concepts_glob).empty?
138
- # multiple content YAML files
139
- concepts_glob = File.join(path, "*.{yaml,yml}")
140
- end
141
- concepts_glob
135
+ candidates = [
136
+ File.join(path, "concept", "*.{yaml,yml}"),
137
+ File.join(path, "concepts", "*.{yaml,yml}"),
138
+ File.join(path, "*.{yaml,yml}"),
139
+ ]
140
+ candidates.find { |g| !Dir.glob(g).empty? }
142
141
  end
143
142
  end
144
143
 
@@ -26,6 +26,10 @@ module Glossarist
26
26
  new(concept_id: concept_id, ref_type: "domain")
27
27
  end
28
28
 
29
+ def self.section(concept_id)
30
+ new(concept_id: concept_id, ref_type: "section")
31
+ end
32
+
29
33
  def local?
30
34
  %w[local designation].include?(ref_type) ||
31
35
  (ref_type.nil? && (source.nil? || source.empty?))
@@ -36,7 +36,7 @@ module Glossarist
36
36
  end
37
37
 
38
38
  def to_latex_from_file(entries_file)
39
- File.readlines(entries_file).map do |concept_name|
39
+ File.readlines(entries_file).filter_map do |concept_name|
40
40
  concept = concept_map[concept_name.strip.downcase]
41
41
 
42
42
  if concept.nil?
@@ -44,7 +44,7 @@ module Glossarist
44
44
  else
45
45
  latex_template(concept)
46
46
  end
47
- end.compact.join("\n")
47
+ end.join("\n")
48
48
  end
49
49
 
50
50
  def read_concepts(concepts)
@@ -72,9 +72,9 @@ module Glossarist
72
72
  end
73
73
 
74
74
  def concept_map
75
- @concept_map ||= concepts.managed_concepts.map do |concept|
75
+ @concept_map ||= concepts.managed_concepts.to_h do |concept|
76
76
  [concept.default_designation.downcase, concept]
77
- end.to_h
77
+ end
78
78
  end
79
79
  end
80
80
  end