glossarist 2.8.7 → 2.8.10
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop_todo.yml +128 -11
- data/CLAUDE.md +34 -3
- data/Gemfile +1 -0
- data/lib/glossarist/cli/compare_command.rb +2 -2
- data/lib/glossarist/cli/export_command.rb +1 -3
- data/lib/glossarist/collection.rb +1 -1
- data/lib/glossarist/collections/bibliography_collection.rb +1 -1
- data/lib/glossarist/concept_data.rb +1 -0
- data/lib/glossarist/concept_reference.rb +7 -1
- data/lib/glossarist/concept_source.rb +2 -2
- data/lib/glossarist/concept_validator.rb +3 -1
- data/lib/glossarist/dataset_validator.rb +1 -1
- data/lib/glossarist/{error.rb → errors/base.rb} +3 -1
- data/lib/glossarist/errors/cache_version_mismatch_error.rb +12 -0
- data/lib/glossarist/errors/invalid_language_code_error.rb +19 -0
- data/lib/glossarist/errors/invalid_type_error.rb +8 -0
- data/lib/glossarist/errors/load_error.rb +22 -0
- data/lib/glossarist/errors/parse_error.rb +24 -0
- data/lib/glossarist/errors.rb +14 -0
- data/lib/glossarist/gcr_package.rb +4 -2
- data/lib/glossarist/glossary_store.rb +175 -1
- data/lib/glossarist/managed_concept.rb +16 -2
- data/lib/glossarist/managed_concept_collection.rb +52 -8
- data/lib/glossarist/reference_extractor.rb +22 -2
- data/lib/glossarist/reference_resolver.rb +38 -3
- data/lib/glossarist/resolution_adapter/bibliography.rb +22 -0
- data/lib/glossarist/resolution_adapter.rb +1 -0
- data/lib/glossarist/schema_migration/v0_to_v1.rb +200 -0
- data/lib/glossarist/schema_migration/v2_to_v3.rb +50 -0
- data/lib/glossarist/schema_migration.rb +10 -224
- data/lib/glossarist/sts/importer.rb +11 -12
- data/lib/glossarist/sts/term_extractor.rb +104 -6
- data/lib/glossarist/validation/asset_index.rb +1 -1
- data/lib/glossarist/validation/rules/cite_ref_integrity_rule.rb +75 -0
- data/lib/glossarist/version.rb +1 -1
- data/lib/glossarist.rb +5 -13
- data/scripts/upgrade_dataset_to_v3.rb +1 -1
- metadata +13 -9
- data/lib/glossarist/concept_collector.rb +0 -231
- data/lib/glossarist/concept_manager.rb +0 -183
- data/lib/glossarist/error/cache_version_mismatch_error.rb +0 -8
- data/lib/glossarist/error/invalid_language_code_error.rb +0 -15
- data/lib/glossarist/error/invalid_type_error.rb +0 -4
- data/lib/glossarist/error/parse_error.rb +0 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3d52bb386f776f12beb9671c25c5f1ce8330ff8349df68d734c80fa3937cec6f
|
|
4
|
+
data.tar.gz: 43cab5da334046a266967ba590d9791ee56f1fe283110075c880ddb8f5ec8344
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6364fe8da9e37fdf669b2064fa244ad7f97f745cc4059243e4d1a337e710aff0ad1f1a6034573504b6106708cc9ed153e8fd9a6f1396d504c5d8b45e917c6e15
|
|
7
|
+
data.tar.gz: 71ac705f2149e4995b1476a2802a3f5361e8d8733435d3fda15b7f2033d4ac62c72183b11770032bda22c6e6de8fadc8798f80c6f9af636b2e06828571d16d30
|
data/.gitignore
CHANGED
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-06-
|
|
3
|
+
# on 2026-06-13 04:17:12 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,13 +11,101 @@ Gemspec/RequiredRubyVersion:
|
|
|
11
11
|
Exclude:
|
|
12
12
|
- 'glossarist.gemspec'
|
|
13
13
|
|
|
14
|
-
# Offense count:
|
|
14
|
+
# Offense count: 7
|
|
15
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
16
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
17
|
+
# SupportedStyles: with_first_argument, with_fixed_indentation
|
|
18
|
+
Layout/ArgumentAlignment:
|
|
19
|
+
Exclude:
|
|
20
|
+
- 'lib/glossarist/errors.rb'
|
|
21
|
+
- 'lib/glossarist/reference_resolver.rb'
|
|
22
|
+
- 'lib/glossarist/schema_migration/v0_to_v1.rb'
|
|
23
|
+
- 'lib/glossarist/schema_migration/v2_to_v3.rb'
|
|
24
|
+
- 'spec/unit/reference_resolver_spec.rb'
|
|
25
|
+
|
|
26
|
+
# Offense count: 1
|
|
27
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
28
|
+
# Configuration parameters: IndentationWidth.
|
|
29
|
+
Layout/AssignmentIndentation:
|
|
30
|
+
Exclude:
|
|
31
|
+
- 'lib/glossarist/schema_migration/v0_to_v1.rb'
|
|
32
|
+
|
|
33
|
+
# Offense count: 1
|
|
34
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
35
|
+
# Configuration parameters: EnforcedStyleAlignWith.
|
|
36
|
+
# SupportedStylesAlignWith: either, start_of_block, start_of_line
|
|
37
|
+
Layout/BlockAlignment:
|
|
38
|
+
Exclude:
|
|
39
|
+
- 'lib/glossarist/sts/importer.rb'
|
|
40
|
+
|
|
41
|
+
# Offense count: 1
|
|
42
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
43
|
+
Layout/BlockEndNewline:
|
|
44
|
+
Exclude:
|
|
45
|
+
- 'lib/glossarist/sts/importer.rb'
|
|
46
|
+
|
|
47
|
+
# Offense count: 1
|
|
48
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
49
|
+
Layout/ClosingParenthesisIndentation:
|
|
50
|
+
Exclude:
|
|
51
|
+
- 'spec/unit/concept_source_spec.rb'
|
|
52
|
+
|
|
53
|
+
# Offense count: 1
|
|
54
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
55
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
56
|
+
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
|
|
57
|
+
Layout/FirstArgumentIndentation:
|
|
58
|
+
Exclude:
|
|
59
|
+
- 'spec/unit/concept_source_spec.rb'
|
|
60
|
+
|
|
61
|
+
# Offense count: 3
|
|
62
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
63
|
+
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
|
64
|
+
# SupportedHashRocketStyles: key, separator, table
|
|
65
|
+
# SupportedColonStyles: key, separator, table
|
|
66
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
|
67
|
+
Layout/HashAlignment:
|
|
68
|
+
Exclude:
|
|
69
|
+
- 'lib/glossarist/managed_concept.rb'
|
|
70
|
+
- 'lib/glossarist/schema_migration/v0_to_v1.rb'
|
|
71
|
+
- 'spec/unit/validation/rules/cite_ref_integrity_rule_spec.rb'
|
|
72
|
+
|
|
73
|
+
# Offense count: 2
|
|
74
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
75
|
+
# Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
|
|
76
|
+
# SupportedStylesAlignWith: start_of_line, relative_to_receiver
|
|
77
|
+
Layout/IndentationWidth:
|
|
78
|
+
Exclude:
|
|
79
|
+
- 'lib/glossarist/sts/importer.rb'
|
|
80
|
+
|
|
81
|
+
# Offense count: 449
|
|
15
82
|
# This cop supports safe autocorrection (--autocorrect).
|
|
16
83
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
17
84
|
# URISchemes: http, https
|
|
18
85
|
Layout/LineLength:
|
|
19
86
|
Enabled: false
|
|
20
87
|
|
|
88
|
+
# Offense count: 1
|
|
89
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
90
|
+
# Configuration parameters: EnforcedStyle.
|
|
91
|
+
# SupportedStyles: symmetrical, new_line, same_line
|
|
92
|
+
Layout/MultilineMethodCallBraceLayout:
|
|
93
|
+
Exclude:
|
|
94
|
+
- 'spec/unit/concept_source_spec.rb'
|
|
95
|
+
|
|
96
|
+
# Offense count: 11
|
|
97
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
98
|
+
# Configuration parameters: AllowInHeredoc.
|
|
99
|
+
Layout/TrailingWhitespace:
|
|
100
|
+
Exclude:
|
|
101
|
+
- 'lib/glossarist/errors.rb'
|
|
102
|
+
- 'lib/glossarist/managed_concept.rb'
|
|
103
|
+
- 'lib/glossarist/reference_resolver.rb'
|
|
104
|
+
- 'lib/glossarist/schema_migration/v0_to_v1.rb'
|
|
105
|
+
- 'lib/glossarist/schema_migration/v2_to_v3.rb'
|
|
106
|
+
- 'spec/unit/reference_resolver_spec.rb'
|
|
107
|
+
- 'spec/unit/validation/rules/cite_ref_integrity_rule_spec.rb'
|
|
108
|
+
|
|
21
109
|
# Offense count: 1
|
|
22
110
|
# Configuration parameters: AllowedMethods.
|
|
23
111
|
# AllowedMethods: enums
|
|
@@ -39,7 +127,12 @@ Lint/UnusedMethodArgument:
|
|
|
39
127
|
Exclude:
|
|
40
128
|
- 'lib/glossarist/dataset_validator.rb'
|
|
41
129
|
|
|
42
|
-
# Offense count:
|
|
130
|
+
# Offense count: 1
|
|
131
|
+
Lint/UselessConstantScoping:
|
|
132
|
+
Exclude:
|
|
133
|
+
- 'lib/glossarist/sts/term_extractor.rb'
|
|
134
|
+
|
|
135
|
+
# Offense count: 89
|
|
43
136
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
44
137
|
Metrics/AbcSize:
|
|
45
138
|
Enabled: false
|
|
@@ -50,12 +143,12 @@ Metrics/AbcSize:
|
|
|
50
143
|
Metrics/BlockLength:
|
|
51
144
|
Max: 41
|
|
52
145
|
|
|
53
|
-
# Offense count:
|
|
146
|
+
# Offense count: 58
|
|
54
147
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
55
148
|
Metrics/CyclomaticComplexity:
|
|
56
149
|
Enabled: false
|
|
57
150
|
|
|
58
|
-
# Offense count:
|
|
151
|
+
# Offense count: 109
|
|
59
152
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
60
153
|
Metrics/MethodLength:
|
|
61
154
|
Max: 47
|
|
@@ -65,17 +158,21 @@ Metrics/MethodLength:
|
|
|
65
158
|
Metrics/ParameterLists:
|
|
66
159
|
Max: 6
|
|
67
160
|
|
|
68
|
-
# Offense count:
|
|
161
|
+
# Offense count: 43
|
|
69
162
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
70
163
|
Metrics/PerceivedComplexity:
|
|
71
164
|
Enabled: false
|
|
72
165
|
|
|
73
|
-
# Offense count:
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
|
|
166
|
+
# Offense count: 1
|
|
167
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
168
|
+
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
|
|
169
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
|
|
170
|
+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
|
171
|
+
# FunctionalMethods: let, let!, subject, watch
|
|
172
|
+
# AllowedMethods: lambda, proc, it
|
|
173
|
+
Style/BlockDelimiters:
|
|
77
174
|
Exclude:
|
|
78
|
-
- 'lib/glossarist/
|
|
175
|
+
- 'lib/glossarist/sts/importer.rb'
|
|
79
176
|
|
|
80
177
|
# Offense count: 6
|
|
81
178
|
# This cop supports safe autocorrection (--autocorrect).
|
|
@@ -90,6 +187,18 @@ Style/IdenticalConditionalBranches:
|
|
|
90
187
|
Exclude:
|
|
91
188
|
- 'scripts/migrate_dataset.rb'
|
|
92
189
|
|
|
190
|
+
# Offense count: 1
|
|
191
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
192
|
+
Style/MultilineIfModifier:
|
|
193
|
+
Exclude:
|
|
194
|
+
- 'lib/glossarist/schema_migration/v0_to_v1.rb'
|
|
195
|
+
|
|
196
|
+
# Offense count: 2
|
|
197
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
198
|
+
Style/RedundantRegexpCharacterClass:
|
|
199
|
+
Exclude:
|
|
200
|
+
- 'lib/glossarist/sts/term_extractor.rb'
|
|
201
|
+
|
|
93
202
|
# Offense count: 3
|
|
94
203
|
# Configuration parameters: Max.
|
|
95
204
|
Style/SafeNavigationChainLength:
|
|
@@ -97,3 +206,11 @@ Style/SafeNavigationChainLength:
|
|
|
97
206
|
- 'lib/glossarist/managed_concept.rb'
|
|
98
207
|
- 'lib/glossarist/transforms/concept_to_tbx_transform.rb'
|
|
99
208
|
- 'lib/glossarist/validation/rules/source_urn_format_rule.rb'
|
|
209
|
+
|
|
210
|
+
# Offense count: 1
|
|
211
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
212
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
|
213
|
+
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
|
|
214
|
+
Style/TrailingCommaInArguments:
|
|
215
|
+
Exclude:
|
|
216
|
+
- 'spec/unit/concept_source_spec.rb'
|
data/CLAUDE.md
CHANGED
|
@@ -59,11 +59,15 @@ Designation inheritance hierarchy (MECE):
|
|
|
59
59
|
|
|
60
60
|
`ConceptData#domain` stores URI references (relative like `section-103-01`, URN like `urn:iec:std:iec:60050-103-01`, or URL like `https://...`) to subject area concepts.
|
|
61
61
|
|
|
62
|
+
### Dataset Loading
|
|
63
|
+
|
|
64
|
+
- **`GlossaryStore`** (`glossary_store.rb`) — the dataset abstraction. Backed by `Lutaml::Store::PackageStore`, handles loading/saving from directories and ZIPs, concept CRUD, metadata, bibliography, images, and stats. Format detection is model-driven via `ConceptDocument.for_version`. **All callers that need to load concepts from a dataset should use GlossaryStore.**
|
|
65
|
+
- **`ConceptCollector`** (`concept_collector.rb`) — legacy scanner with hand-rolled format detection (file-system heuristics, not model-driven). Being replaced by GlossaryStore. Do not add new callers.
|
|
66
|
+
- **`ConceptManager`** (`concept_manager.rb`) — legacy file I/O used by `ManagedConceptCollection`. Being replaced by GlossaryStore. Do not add new callers.
|
|
67
|
+
- **`ManagedConceptCollection`** (`managed_concept_collection.rb`) — legacy collection that loads via ConceptManager. Being replaced by GlossaryStore.
|
|
68
|
+
|
|
62
69
|
### YAML Serialization
|
|
63
70
|
|
|
64
|
-
- **`ConceptManager`** (`concept_manager.rb`) — handles file I/O. Supports two storage formats:
|
|
65
|
-
1. Separate `concept/` and `localized_concept/` directories (or `localized-concept/` with dashes)
|
|
66
|
-
2. Grouped: concept + localized concepts in a single YAML stream file
|
|
67
71
|
- Supports both camelCase and snake_case keys in YAML (e.g., `localizedConcepts` / `localized_concepts`) using `%i[key1 key2]` mapping syntax.
|
|
68
72
|
- Also supports V1 format (`concept-*.yaml` files at root level).
|
|
69
73
|
|
|
@@ -121,3 +125,30 @@ The Gemfile overrides relaton gems from git branches for lutaml-model 0.8 compat
|
|
|
121
125
|
- Released 2.0.0 gems have untyped lutaml-model attributes that fail with 0.8+
|
|
122
126
|
- relaton-bib 2.1.0 is released but sub-gems pin `~> 2.0.0`, blocking 2.1.0 adoption until upstream updates constraints
|
|
123
127
|
- Remove git overrides once relaton gems release versions with lutaml-model 0.8 support
|
|
128
|
+
|
|
129
|
+
## Schema Version Subclasses Are NOT Duplication
|
|
130
|
+
|
|
131
|
+
V2 and V3 namespace classes (e.g. `V2::ManagedConceptData`, `V3::ManagedConceptData`) exist because each schema version has its own `key_value` mapping and its own type references (`V2::LocalizedConcept` vs `V3::LocalizedConcept`). These are version-specific serialization adapters at a **real seam** — two adapters justifies the seam.
|
|
132
|
+
|
|
133
|
+
Do not attempt to "parameterize" or "collapse" these into the base class:
|
|
134
|
+
|
|
135
|
+
- **OCP**: Adding a new schema version = adding a new subclass, not modifying the base. This is the pattern working as intended.
|
|
136
|
+
- **lutaml-model DSL is class-level**: `attribute` and `key_value` mappings are declarative DSL invoked at class definition time. They cannot be meaningfully "parameterized" at the instance level without metaprogramming (`Class.new`), which is worse than the current clear, declarative pattern.
|
|
137
|
+
- **Structural similarity ≠ accidental duplication**: The fact that V2 and V3 `ManagedConceptData` look similar is because V3 evolved from V2. Their `localizations_from_yaml` callbacks differ in which class they instantiate, their `key_value` mappings differ in which fields are mapped, and V2 has custom `related` handling that V3 doesn't. These differences will diverge further as the schemas evolve.
|
|
138
|
+
- **Three similar lines is better than a wrong abstraction**: The global instruction applies directly here.
|
|
139
|
+
|
|
140
|
+
## Architectural Review Findings (2026-06-10)
|
|
141
|
+
|
|
142
|
+
### Valid deepening opportunities
|
|
143
|
+
|
|
144
|
+
See `TODO.improve/` for detailed plans.
|
|
145
|
+
|
|
146
|
+
1. **Migrate callers to GlossaryStore** — ConceptCollector (8 call sites) and ConceptManager (1 call site) duplicate format detection with file-system heuristics. GlossaryStore is model-driven, framework-aligned, and handles both directory and ZIP. All callers should go through GlossaryStore.
|
|
147
|
+
|
|
148
|
+
2. **Split SchemaMigration into focused modules** — Currently handles V0→V1 hash migration, V2→V3 model migration, and a CLI pipeline at three different abstraction levels. Each should be its own module.
|
|
149
|
+
|
|
150
|
+
### Rejected candidates (do not re-suggest)
|
|
151
|
+
|
|
152
|
+
- **Collapse V2/V3 ManagedConceptData** — Version subclasses are a real seam, not duplication. See "Schema Version Subclasses Are NOT Duplication" above.
|
|
153
|
+
- **Extract validation reporter from CLI::ValidateCommand** — 159 lines of terminal formatting in a CLI command is normal. Creating 4 reporter classes to replace a 3-way case statement (where 2 branches are 1 line each) is premature abstraction. CLI commands are leaf nodes, not extension points.
|
|
154
|
+
- **Refactor ConceptToGlossTransform** — The transform is already deep (3 public methods, 343 lines of implementation). Moving mapping to domain models would violate model-driven by leaking RDF knowledge into the domain layer. Using lutaml-model views can't handle the type dispatching and URI construction the transform does. The module has locality (all mapping in one place) and leverage (one interface, N callers).
|
data/Gemfile
CHANGED
|
@@ -12,8 +12,8 @@ module Glossarist
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def run
|
|
15
|
-
new_concepts =
|
|
16
|
-
old_concepts =
|
|
15
|
+
new_concepts = GlossaryStore.new.tap { |s| s.load(@new_path) }.concepts
|
|
16
|
+
old_concepts = GlossaryStore.new.tap { |s| s.load(@old_path) }.concepts
|
|
17
17
|
|
|
18
18
|
result = ConceptComparator.new(
|
|
19
19
|
new_concepts: new_concepts,
|
|
@@ -41,9 +41,7 @@ module Glossarist
|
|
|
41
41
|
resolve_metadata_from_package(package)
|
|
42
42
|
package.concepts
|
|
43
43
|
else
|
|
44
|
-
|
|
45
|
-
collection.load_from_files(@path)
|
|
46
|
-
collection.to_a
|
|
44
|
+
GlossaryStore.new.tap { |s| s.load(@path) }.concepts
|
|
47
45
|
end
|
|
48
46
|
end
|
|
49
47
|
|
|
@@ -68,7 +68,7 @@ module Glossarist
|
|
|
68
68
|
def load_concept_from_file(filename)
|
|
69
69
|
Concept.from_yaml(File.read(filename))
|
|
70
70
|
rescue Psych::SyntaxError => e
|
|
71
|
-
raise Glossarist::ParseError.new(filename: filename, line: e.line)
|
|
71
|
+
raise Glossarist::Errors::ParseError.new(filename: filename, line: e.line)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def save_concept_to_file(concept)
|
|
@@ -30,7 +30,7 @@ module Glossarist
|
|
|
30
30
|
expected = Relaton::Registry.instance.by_type(dir.split("/").last)&.grammar_hash
|
|
31
31
|
next if expected.nil? || actual == expected
|
|
32
32
|
|
|
33
|
-
return CacheVersionMismatchError.new(dir, expected, actual)
|
|
33
|
+
return Errors::CacheVersionMismatchError.new(dir, expected, actual)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
nil
|
|
@@ -13,6 +13,7 @@ module Glossarist
|
|
|
13
13
|
attribute :source, :string
|
|
14
14
|
attribute :ref_type, :string
|
|
15
15
|
attribute :urn, :string
|
|
16
|
+
attribute :version, :string
|
|
16
17
|
|
|
17
18
|
key_value do
|
|
18
19
|
map :term, to: :term
|
|
@@ -20,6 +21,7 @@ module Glossarist
|
|
|
20
21
|
map :source, to: :source
|
|
21
22
|
map :ref_type, to: :ref_type
|
|
22
23
|
map :urn, to: :urn
|
|
24
|
+
map :version, to: :version
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def self.domain(concept_id)
|
|
@@ -31,7 +33,7 @@ module Glossarist
|
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
def local?
|
|
34
|
-
%w[local designation].include?(ref_type) ||
|
|
36
|
+
%w[local designation cite].include?(ref_type) ||
|
|
35
37
|
(ref_type.nil? && (source.nil? || source.empty?))
|
|
36
38
|
end
|
|
37
39
|
|
|
@@ -39,6 +41,10 @@ module Glossarist
|
|
|
39
41
|
!local?
|
|
40
42
|
end
|
|
41
43
|
|
|
44
|
+
def cite?
|
|
45
|
+
ref_type == "cite"
|
|
46
|
+
end
|
|
47
|
+
|
|
42
48
|
def dedup_key
|
|
43
49
|
concept_id ? [source, concept_id] : [source, concept_id, term]
|
|
44
50
|
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module Glossarist
|
|
2
2
|
class ConceptSource < Lutaml::Model::Serializable
|
|
3
|
+
attribute :id, :string
|
|
3
4
|
attribute :status, :string,
|
|
4
5
|
values: Glossarist::GlossaryDefinition::CONCEPT_SOURCE_STATUSES
|
|
5
6
|
attribute :type, :string,
|
|
@@ -8,8 +9,7 @@ module Glossarist
|
|
|
8
9
|
attribute :modification, :string
|
|
9
10
|
|
|
10
11
|
key_value do
|
|
11
|
-
|
|
12
|
-
# when multiple key mapping is supported in lutaml-model
|
|
12
|
+
map :id, to: :id
|
|
13
13
|
map :origin, to: :origin
|
|
14
14
|
map :status, to: :status
|
|
15
15
|
map :type, to: :type
|
|
@@ -16,7 +16,9 @@ module Glossarist
|
|
|
16
16
|
context = Validation::Rules::DatasetContext.new(@path)
|
|
17
17
|
concept_rules = Validation::Rules::Registry.for_scope(:concept)
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
store = GlossaryStore.new
|
|
20
|
+
store.load(@path)
|
|
21
|
+
all_concepts = store.concepts
|
|
20
22
|
total = all_concepts.length
|
|
21
23
|
|
|
22
24
|
if total.zero?
|
|
@@ -52,7 +52,7 @@ module Glossarist
|
|
|
52
52
|
def validate_directory_cross_references(path, reference_path)
|
|
53
53
|
extractor = ReferenceExtractor.new
|
|
54
54
|
resolver = build_resolver(reference_path)
|
|
55
|
-
concepts =
|
|
55
|
+
concepts = GlossaryStore.new.tap { |s| s.load(path) }.concepts
|
|
56
56
|
resolver.register_self(concepts)
|
|
57
57
|
resolver.validate_all(concepts, extractor: extractor)
|
|
58
58
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module Errors
|
|
5
|
+
class CacheVersionMismatchError < Base
|
|
6
|
+
def initialize(cache_dir, expected, actual)
|
|
7
|
+
super("Relaton cache version mismatch in '#{cache_dir}': " \
|
|
8
|
+
"expected '#{expected}', got '#{actual}'")
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module Errors
|
|
5
|
+
class InvalidLanguageCodeError < Base
|
|
6
|
+
attr_reader :code
|
|
7
|
+
|
|
8
|
+
def initialize(code:)
|
|
9
|
+
@code = code
|
|
10
|
+
|
|
11
|
+
super()
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_s
|
|
15
|
+
"Invalid value for language_code: `#{code}`. It must be 3 characters long string."
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module Errors
|
|
5
|
+
class LoadError < Base
|
|
6
|
+
attr_accessor :path, :reason
|
|
7
|
+
|
|
8
|
+
def initialize(path:, reason: nil)
|
|
9
|
+
@path = path
|
|
10
|
+
@reason = reason
|
|
11
|
+
|
|
12
|
+
super(to_s)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_s
|
|
16
|
+
parts = ["Unable to load: #{path}"]
|
|
17
|
+
parts << reason if reason
|
|
18
|
+
parts.join(" — ")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module Errors
|
|
5
|
+
class ParseError < Base
|
|
6
|
+
attr_accessor :line, :filename, :message
|
|
7
|
+
|
|
8
|
+
def initialize(filename:, line: nil, message: nil)
|
|
9
|
+
@filename = filename
|
|
10
|
+
@line = line
|
|
11
|
+
@message = message
|
|
12
|
+
|
|
13
|
+
super(to_s)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to_s
|
|
17
|
+
parts = ["Unable to parse file: #{filename}"]
|
|
18
|
+
parts << "error on line: #{line}" if line
|
|
19
|
+
parts << message if message
|
|
20
|
+
parts.join(", ")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module Errors
|
|
5
|
+
autoload :Base, "glossarist/errors/base"
|
|
6
|
+
autoload :ParseError, "glossarist/errors/parse_error"
|
|
7
|
+
autoload :LoadError, "glossarist/errors/load_error"
|
|
8
|
+
autoload :InvalidTypeError, "glossarist/errors/invalid_type_error"
|
|
9
|
+
autoload :InvalidLanguageCodeError,
|
|
10
|
+
"glossarist/errors/invalid_language_code_error"
|
|
11
|
+
autoload :CacheVersionMismatchError,
|
|
12
|
+
"glossarist/errors/cache_version_mismatch_error"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -259,7 +259,9 @@ module Glossarist
|
|
|
259
259
|
|
|
260
260
|
def create_batch(dir, output:, shortname:, version:,
|
|
261
261
|
compiled_formats: [], **opts)
|
|
262
|
-
|
|
262
|
+
store = GlossaryStore.new
|
|
263
|
+
store.load(dir)
|
|
264
|
+
concepts = store.concepts
|
|
263
265
|
if concepts.empty?
|
|
264
266
|
raise ArgumentError,
|
|
265
267
|
"No concept files found in #{dir}"
|
|
@@ -304,7 +306,7 @@ compiled_formats: [], **opts)
|
|
|
304
306
|
zos.write(register_data.to_yaml)
|
|
305
307
|
end
|
|
306
308
|
|
|
307
|
-
|
|
309
|
+
GlossaryStore.new.tap { |s| s.load(dir) }.each_concept do |mc|
|
|
308
310
|
enricher.inject_references([mc])
|
|
309
311
|
if opts[:concept_uri_template]
|
|
310
312
|
enricher.apply_uri_template([mc],
|