metanorma-plugin-glossarist 0.3.0 → 0.3.1
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/.github/workflows/rake.yml +3 -0
- data/.github/workflows/release.yml +7 -1
- data/.gitignore +1 -0
- data/.rubocop.yml +11 -2
- data/.rubocop_todo.yml +326 -0
- data/Gemfile +13 -15
- data/README.adoc +15 -1
- data/lib/metanorma/plugin/glossarist/bibliography_renderer.rb +66 -0
- data/lib/metanorma/plugin/glossarist/concept_filter.rb +128 -0
- data/lib/metanorma/plugin/glossarist/concept_renderer.rb +91 -0
- data/lib/metanorma/plugin/glossarist/concept_serializer.rb +103 -0
- data/lib/metanorma/plugin/glossarist/dataset_preprocessor.rb +116 -298
- data/lib/metanorma/plugin/glossarist/document.rb +8 -23
- data/lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb +58 -136
- data/lib/metanorma/plugin/glossarist/liquid/custom_filters/filters.rb +5 -34
- data/lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb +6 -3
- data/lib/metanorma/plugin/glossarist/sanitize.rb +26 -0
- data/lib/metanorma/plugin/glossarist/version.rb +3 -1
- data/lib/metanorma-plugin-glossarist.rb +8 -10
- data/metanorma-plugin-glossarist.gemspec +6 -6
- metadata +16 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 035bbab9dbca5a50d31568ac38270873b5d0adba5bc7be42f69f5cfc90930e2b
|
|
4
|
+
data.tar.gz: 226a954bac71bd41894a46692f7610b9b7d04f3d44444494acb4d73e6fbfb053
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0353502cfb820476dca14b27c428475feb7ac33a6badaf0d84517540c7b5466f410eb2b1025f26eca5f9dc0e1cf5d90c170e7222cd90a72fad0db258267c8d95
|
|
7
|
+
data.tar.gz: 1fefdf7694567c819f7789f96494e8dd4fbc54ddfeea801686924c524ed064ddf263dadd497b84c60deb763341b347d0c4bc87c64fb845a6cb2ab02eafcc70d2
|
data/.github/workflows/rake.yml
CHANGED
|
@@ -7,12 +7,18 @@ on:
|
|
|
7
7
|
inputs:
|
|
8
8
|
next_version:
|
|
9
9
|
description: |
|
|
10
|
-
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
|
10
|
+
Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
|
|
11
|
+
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
|
|
11
12
|
required: true
|
|
12
13
|
default: 'skip'
|
|
13
14
|
repository_dispatch:
|
|
14
15
|
types: [ do-release ]
|
|
15
16
|
|
|
17
|
+
permissions:
|
|
18
|
+
contents: write
|
|
19
|
+
packages: write
|
|
20
|
+
id-token: write
|
|
21
|
+
|
|
16
22
|
jobs:
|
|
17
23
|
release:
|
|
18
24
|
uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
# Auto-generated by Cimas: Do not edit it manually!
|
|
2
2
|
# See https://github.com/metanorma/cimas
|
|
3
3
|
inherit_from:
|
|
4
|
-
- https://raw.githubusercontent.com/riboseinc/oss-guides/
|
|
4
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
|
|
5
|
+
- .rubocop_todo.yml
|
|
6
|
+
|
|
7
|
+
inherit_mode:
|
|
8
|
+
merge:
|
|
9
|
+
- Exclude
|
|
5
10
|
|
|
6
11
|
# local repo-specific modifications
|
|
7
12
|
# ...
|
|
13
|
+
plugins:
|
|
14
|
+
- rubocop-rspec
|
|
15
|
+
- rubocop-performance
|
|
16
|
+
- rubocop-rake
|
|
8
17
|
|
|
9
18
|
AllCops:
|
|
10
|
-
TargetRubyVersion:
|
|
19
|
+
TargetRubyVersion: 3.0
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2026-05-11 09:00:54 UTC using RuboCop version 1.86.1.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 7
|
|
10
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
11
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
|
|
12
|
+
Bundler/OrderedGems:
|
|
13
|
+
Exclude:
|
|
14
|
+
- 'Gemfile'
|
|
15
|
+
|
|
16
|
+
# Offense count: 1
|
|
17
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
18
|
+
Gemspec/RequireMFA:
|
|
19
|
+
Exclude:
|
|
20
|
+
- 'metanorma-plugin-glossarist.gemspec'
|
|
21
|
+
|
|
22
|
+
# Offense count: 1
|
|
23
|
+
Gemspec/RequiredRubyVersion:
|
|
24
|
+
Exclude:
|
|
25
|
+
- 'metanorma-plugin-glossarist.gemspec'
|
|
26
|
+
|
|
27
|
+
# Offense count: 3
|
|
28
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
29
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
30
|
+
# SupportedStyles: with_first_argument, with_fixed_indentation
|
|
31
|
+
Layout/ArgumentAlignment:
|
|
32
|
+
Exclude:
|
|
33
|
+
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
34
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
35
|
+
- 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
|
|
36
|
+
|
|
37
|
+
# Offense count: 1
|
|
38
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
39
|
+
# Configuration parameters: IndentationWidth.
|
|
40
|
+
Layout/AssignmentIndentation:
|
|
41
|
+
Exclude:
|
|
42
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
43
|
+
|
|
44
|
+
# Offense count: 20
|
|
45
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
46
|
+
# Configuration parameters: EnforcedStyleAlignWith.
|
|
47
|
+
# SupportedStylesAlignWith: either, start_of_block, start_of_line
|
|
48
|
+
Layout/BlockAlignment:
|
|
49
|
+
Exclude:
|
|
50
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
51
|
+
- 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
|
|
52
|
+
- 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
|
|
53
|
+
- 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
|
|
54
|
+
|
|
55
|
+
# Offense count: 14
|
|
56
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
57
|
+
Layout/BlockEndNewline:
|
|
58
|
+
Exclude:
|
|
59
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
60
|
+
- 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
|
|
61
|
+
- 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
|
|
62
|
+
- 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
|
|
63
|
+
|
|
64
|
+
# Offense count: 1
|
|
65
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
66
|
+
Layout/ClosingParenthesisIndentation:
|
|
67
|
+
Exclude:
|
|
68
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
69
|
+
|
|
70
|
+
# Offense count: 1
|
|
71
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
72
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
73
|
+
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
|
|
74
|
+
Layout/FirstArgumentIndentation:
|
|
75
|
+
Exclude:
|
|
76
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
77
|
+
|
|
78
|
+
# Offense count: 4
|
|
79
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
80
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
81
|
+
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
|
82
|
+
Layout/FirstHashElementIndentation:
|
|
83
|
+
Exclude:
|
|
84
|
+
- 'spec/metanorma/plugin/glossarist/concept_filter_spec.rb'
|
|
85
|
+
|
|
86
|
+
# Offense count: 4
|
|
87
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
88
|
+
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
|
89
|
+
# SupportedHashRocketStyles: key, separator, table
|
|
90
|
+
# SupportedColonStyles: key, separator, table
|
|
91
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
|
92
|
+
Layout/HashAlignment:
|
|
93
|
+
Exclude:
|
|
94
|
+
- 'Gemfile'
|
|
95
|
+
- 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
|
|
96
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
97
|
+
- 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
|
|
98
|
+
|
|
99
|
+
# Offense count: 1
|
|
100
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
101
|
+
# Configuration parameters: EnforcedStyle.
|
|
102
|
+
# SupportedStyles: normal, indented_internal_methods
|
|
103
|
+
Layout/IndentationConsistency:
|
|
104
|
+
Exclude:
|
|
105
|
+
- 'metanorma-plugin-glossarist.gemspec'
|
|
106
|
+
|
|
107
|
+
# Offense count: 22
|
|
108
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
109
|
+
# Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
|
|
110
|
+
# SupportedStylesAlignWith: start_of_line, relative_to_receiver
|
|
111
|
+
Layout/IndentationWidth:
|
|
112
|
+
Exclude:
|
|
113
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
114
|
+
- 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
|
|
115
|
+
- 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
|
|
116
|
+
- 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
|
|
117
|
+
|
|
118
|
+
# Offense count: 1
|
|
119
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
120
|
+
# Configuration parameters: EnforcedStyle.
|
|
121
|
+
# SupportedStyles: leading, trailing
|
|
122
|
+
Layout/LineContinuationLeadingSpace:
|
|
123
|
+
Exclude:
|
|
124
|
+
- 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
|
|
125
|
+
|
|
126
|
+
# Offense count: 32
|
|
127
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
128
|
+
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
129
|
+
# URISchemes: http, https
|
|
130
|
+
Layout/LineLength:
|
|
131
|
+
Exclude:
|
|
132
|
+
- 'Gemfile'
|
|
133
|
+
- 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
|
|
134
|
+
- 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
|
|
135
|
+
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
136
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
137
|
+
- 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
|
|
138
|
+
- 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
|
|
139
|
+
- 'spec/metanorma/plugin/glossarist/concept_filter_spec.rb'
|
|
140
|
+
- 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
|
|
141
|
+
- 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
|
|
142
|
+
|
|
143
|
+
# Offense count: 6
|
|
144
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
145
|
+
Layout/MultilineBlockLayout:
|
|
146
|
+
Exclude:
|
|
147
|
+
- 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
|
|
148
|
+
- 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
|
|
149
|
+
- 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
|
|
150
|
+
|
|
151
|
+
# Offense count: 1
|
|
152
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
153
|
+
# Configuration parameters: EnforcedStyle.
|
|
154
|
+
# SupportedStyles: symmetrical, new_line, same_line
|
|
155
|
+
Layout/MultilineMethodCallBraceLayout:
|
|
156
|
+
Exclude:
|
|
157
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
158
|
+
|
|
159
|
+
# Offense count: 14
|
|
160
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
161
|
+
# Configuration parameters: AllowInHeredoc.
|
|
162
|
+
Layout/TrailingWhitespace:
|
|
163
|
+
Exclude:
|
|
164
|
+
- 'Gemfile'
|
|
165
|
+
- 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
|
|
166
|
+
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
167
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
168
|
+
- 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
|
|
169
|
+
- 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
|
|
170
|
+
- 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
|
|
171
|
+
- 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
|
|
172
|
+
|
|
173
|
+
# Offense count: 1
|
|
174
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
175
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
176
|
+
Lint/AmbiguousBlockAssociation:
|
|
177
|
+
Exclude:
|
|
178
|
+
- 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
|
|
179
|
+
|
|
180
|
+
# Offense count: 6
|
|
181
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
182
|
+
Metrics/AbcSize:
|
|
183
|
+
Exclude:
|
|
184
|
+
- 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
|
|
185
|
+
- 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
|
|
186
|
+
- 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
|
|
187
|
+
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
188
|
+
|
|
189
|
+
# Offense count: 4
|
|
190
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
191
|
+
Metrics/CyclomaticComplexity:
|
|
192
|
+
Exclude:
|
|
193
|
+
- 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
|
|
194
|
+
- 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
|
|
195
|
+
- 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
|
|
196
|
+
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
197
|
+
|
|
198
|
+
# Offense count: 8
|
|
199
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
200
|
+
Metrics/MethodLength:
|
|
201
|
+
Max: 19
|
|
202
|
+
|
|
203
|
+
# Offense count: 4
|
|
204
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
205
|
+
Metrics/PerceivedComplexity:
|
|
206
|
+
Exclude:
|
|
207
|
+
- 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
|
|
208
|
+
- 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
|
|
209
|
+
- 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
|
|
210
|
+
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
211
|
+
|
|
212
|
+
# Offense count: 1
|
|
213
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
214
|
+
Performance/MapCompact:
|
|
215
|
+
Exclude:
|
|
216
|
+
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
217
|
+
|
|
218
|
+
# Offense count: 1
|
|
219
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
220
|
+
# Configuration parameters: EnforcedStyle.
|
|
221
|
+
# SupportedStyles: be, be_nil
|
|
222
|
+
RSpec/BeNil:
|
|
223
|
+
Exclude:
|
|
224
|
+
- 'spec/metanorma/plugin/glossarist_spec.rb'
|
|
225
|
+
|
|
226
|
+
# Offense count: 14
|
|
227
|
+
# Configuration parameters: Prefixes, AllowedPatterns.
|
|
228
|
+
# Prefixes: when, with, without
|
|
229
|
+
RSpec/ContextWording:
|
|
230
|
+
Exclude:
|
|
231
|
+
- 'spec/metanorma/plugin/glossarist/dataset_preprocessor_spec.rb'
|
|
232
|
+
|
|
233
|
+
# Offense count: 7
|
|
234
|
+
# Configuration parameters: CountAsOne.
|
|
235
|
+
RSpec/ExampleLength:
|
|
236
|
+
Max: 35
|
|
237
|
+
|
|
238
|
+
# Offense count: 18
|
|
239
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
240
|
+
# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
|
|
241
|
+
# DisallowedExamples: works
|
|
242
|
+
RSpec/ExampleWording:
|
|
243
|
+
Exclude:
|
|
244
|
+
- 'spec/metanorma/plugin/glossarist/dataset_preprocessor_spec.rb'
|
|
245
|
+
|
|
246
|
+
# Offense count: 12
|
|
247
|
+
RSpec/MultipleExpectations:
|
|
248
|
+
Max: 7
|
|
249
|
+
|
|
250
|
+
# Offense count: 28
|
|
251
|
+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
|
252
|
+
# SupportedStyles: always, named_only
|
|
253
|
+
RSpec/NamedSubject:
|
|
254
|
+
Exclude:
|
|
255
|
+
- 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
|
|
256
|
+
- 'spec/metanorma/plugin/glossarist/dataset_preprocessor_spec.rb'
|
|
257
|
+
|
|
258
|
+
# Offense count: 22
|
|
259
|
+
# Configuration parameters: AllowedGroups.
|
|
260
|
+
RSpec/NestedGroups:
|
|
261
|
+
Max: 6
|
|
262
|
+
|
|
263
|
+
# Offense count: 19
|
|
264
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
265
|
+
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
|
|
266
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
|
|
267
|
+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
|
268
|
+
# FunctionalMethods: let, let!, subject, watch
|
|
269
|
+
# AllowedMethods: lambda, proc, it
|
|
270
|
+
Style/BlockDelimiters:
|
|
271
|
+
Exclude:
|
|
272
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
273
|
+
- 'spec/metanorma/plugin/glossarist/bibliography_renderer_spec.rb'
|
|
274
|
+
- 'spec/metanorma/plugin/glossarist/concept_renderer_spec.rb'
|
|
275
|
+
- 'spec/metanorma/plugin/glossarist/concept_serializer_spec.rb'
|
|
276
|
+
|
|
277
|
+
# Offense count: 4
|
|
278
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
279
|
+
Style/MultilineIfModifier:
|
|
280
|
+
Exclude:
|
|
281
|
+
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
282
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
283
|
+
- 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
|
|
284
|
+
|
|
285
|
+
# Offense count: 1
|
|
286
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
287
|
+
Style/ReduceToHash:
|
|
288
|
+
Exclude:
|
|
289
|
+
- 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
|
|
290
|
+
|
|
291
|
+
# Offense count: 120
|
|
292
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
293
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
|
294
|
+
# SupportedStyles: single_quotes, double_quotes
|
|
295
|
+
Style/StringLiterals:
|
|
296
|
+
Exclude:
|
|
297
|
+
- 'lib/metanorma-plugin-glossarist.rb'
|
|
298
|
+
- 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb'
|
|
299
|
+
- 'lib/metanorma/plugin/glossarist/concept_filter.rb'
|
|
300
|
+
- 'lib/metanorma/plugin/glossarist/concept_renderer.rb'
|
|
301
|
+
- 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
|
|
302
|
+
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
303
|
+
- 'lib/metanorma/plugin/glossarist/document.rb'
|
|
304
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_blocks/with_glossarist_context.rb'
|
|
305
|
+
- 'lib/metanorma/plugin/glossarist/liquid/custom_filters/filters.rb'
|
|
306
|
+
- 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
|
|
307
|
+
- 'lib/metanorma/plugin/glossarist/sanitize.rb'
|
|
308
|
+
- 'lib/metanorma/plugin/glossarist/version.rb'
|
|
309
|
+
- 'metanorma-plugin-glossarist.gemspec'
|
|
310
|
+
|
|
311
|
+
# Offense count: 3
|
|
312
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
313
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
|
314
|
+
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
|
|
315
|
+
Style/TrailingCommaInArguments:
|
|
316
|
+
Exclude:
|
|
317
|
+
- 'lib/metanorma/plugin/glossarist/dataset_preprocessor.rb'
|
|
318
|
+
- 'lib/metanorma/plugin/glossarist/liquid/multiply_local_file_system.rb'
|
|
319
|
+
|
|
320
|
+
# Offense count: 6
|
|
321
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
322
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
|
323
|
+
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
|
|
324
|
+
Style/TrailingCommaInHashLiteral:
|
|
325
|
+
Exclude:
|
|
326
|
+
- 'lib/metanorma/plugin/glossarist/concept_serializer.rb'
|
data/Gemfile
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
Encoding.default_internal = Encoding::UTF_8
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
3
|
source "https://rubygems.org"
|
|
5
4
|
git_source(:github) { |repo| "https://github.com/#{repo}" }
|
|
6
5
|
|
|
7
|
-
gem "
|
|
8
|
-
gem "
|
|
9
|
-
gem "metanorma", github: "metanorma/metanorma"
|
|
10
|
-
|
|
11
|
-
gem "
|
|
12
|
-
gem "
|
|
13
|
-
gem "
|
|
6
|
+
gem "glossarist"
|
|
7
|
+
gem "metanorma", github: "metanorma/metanorma", branch: "main"
|
|
8
|
+
gem "metanorma-plugin-lutaml", github: "metanorma/metanorma-plugin-lutaml",
|
|
9
|
+
branch: "main"
|
|
10
|
+
gem "metanorma-standoc", github: "metanorma/metanorma-standoc", branch: "main"
|
|
11
|
+
gem "ogc-gml", "~> 1.1"
|
|
12
|
+
gem "rake"
|
|
13
|
+
gem "rspec"
|
|
14
|
+
gem "rubocop"
|
|
15
|
+
gem "rubocop-performance"
|
|
16
|
+
gem "rubocop-rake"
|
|
17
|
+
gem "rubocop-rspec"
|
|
14
18
|
|
|
15
19
|
gemspec
|
|
16
|
-
|
|
17
|
-
begin
|
|
18
|
-
eval_gemfile("Gemfile.devel")
|
|
19
|
-
rescue StandardError
|
|
20
|
-
nil
|
|
21
|
-
end
|
data/README.adoc
CHANGED
|
@@ -286,12 +286,26 @@ which concepts are loaded into the block.
|
|
|
286
286
|
|
|
287
287
|
`sort_by=<field name>`::: Sorts the dataset in ascending order of the given
|
|
288
288
|
field values. The field `term` is a special case, where it sorts according to
|
|
289
|
-
the `default_designation` of the term.
|
|
289
|
+
the `default_designation` of the term. Nested attribute paths are supported
|
|
290
|
+
using dot notation (e.g., `data.id`) and bracket notation for hash/array access
|
|
291
|
+
(e.g., `data.localizations['eng'].data.terms[0].designation`).
|
|
292
|
+
Nested path sorts use natural ordering so that version-like identifiers
|
|
293
|
+
(e.g., `3.1.1.10`) sort correctly after `3.1.1.2`. Concepts missing the
|
|
294
|
+
specified path are sorted last.
|
|
290
295
|
+
|
|
296
|
+
--
|
|
291
297
|
[example]
|
|
292
298
|
`sort_by=term` will sort concepts in ascending order based on the
|
|
293
299
|
default term (which is the first English designation, at `data.localizations['eng'].data.terms[0].designation`).
|
|
294
300
|
|
|
301
|
+
[example]
|
|
302
|
+
`sort_by=data.id` will sort concepts by their identifier.
|
|
303
|
+
|
|
304
|
+
[example]
|
|
305
|
+
`sort_by=data.localizations['eng'].data.terms[0].designation` will sort concepts
|
|
306
|
+
alphabetically by the English designation.
|
|
307
|
+
--
|
|
308
|
+
|
|
295
309
|
`lang=<language code>`::: Loads concepts in the specified language.
|
|
296
310
|
+
|
|
297
311
|
[example]
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Metanorma
|
|
4
|
+
module Plugin
|
|
5
|
+
module Glossarist
|
|
6
|
+
class BibliographyRenderer
|
|
7
|
+
def initialize
|
|
8
|
+
@rendered = {}
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def render_entry(concept, lang: "eng")
|
|
12
|
+
l10n = concept.localization(lang)
|
|
13
|
+
return nil unless l10n
|
|
14
|
+
|
|
15
|
+
entries = source_entries(l10n)
|
|
16
|
+
warn_unresolved_xrefs(l10n)
|
|
17
|
+
entries.empty? ? nil : entries.sort.join("\n")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def render_all(concepts, lang: "eng")
|
|
21
|
+
entries = concepts.filter_map { |c| render_entry(c, lang: lang) }
|
|
22
|
+
entries.sort.join("\n")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def source_entries(l10n)
|
|
28
|
+
sources = l10n.sources
|
|
29
|
+
return [] if sources.nil? || sources.empty?
|
|
30
|
+
|
|
31
|
+
sources.filter_map do |source|
|
|
32
|
+
ref = source.origin&.text
|
|
33
|
+
next if ref.nil? || ref.empty?
|
|
34
|
+
next if @rendered.key?(ref)
|
|
35
|
+
|
|
36
|
+
anchor = ref.gsub(%r{[ /:]}, "_")
|
|
37
|
+
@rendered[ref] = anchor
|
|
38
|
+
"* [[[#{anchor},#{ref}]]]"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def warn_unresolved_xrefs(l10n)
|
|
43
|
+
xref_ids = extract_content_xrefs(l10n)
|
|
44
|
+
return if xref_ids.empty?
|
|
45
|
+
|
|
46
|
+
xref_ids.each do |ref_id|
|
|
47
|
+
next if @rendered.value?(ref_id)
|
|
48
|
+
|
|
49
|
+
warn "[glossarist] unresolved bibliography reference: " \
|
|
50
|
+
"<<#{ref_id}>> — not defined as a source in the dataset"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def extract_content_xrefs(l10n)
|
|
55
|
+
parts = []
|
|
56
|
+
l10n.definition&.each { |d| parts << d.content.to_s }
|
|
57
|
+
l10n.notes&.each { |n| parts << n.content.to_s }
|
|
58
|
+
l10n.examples&.each { |e| parts << e.content.to_s }
|
|
59
|
+
return [] if parts.empty?
|
|
60
|
+
|
|
61
|
+
Sanitize.extract_xrefs(parts.join(" "))
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Metanorma
|
|
4
|
+
module Plugin
|
|
5
|
+
module Glossarist
|
|
6
|
+
class ConceptFilter
|
|
7
|
+
COLLECTION_FILTERS = %w[lang group sort_by].freeze
|
|
8
|
+
|
|
9
|
+
def initialize(filters)
|
|
10
|
+
@filters = filters || {}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def apply(collection)
|
|
14
|
+
result = collection
|
|
15
|
+
result = filter_by_lang(result) if @filters.key?("lang")
|
|
16
|
+
result = filter_by_group(result) if @filters.key?("group")
|
|
17
|
+
result = filter_by_field(result) if field_filter?
|
|
18
|
+
result = sort(result) if @filters.key?("sort_by")
|
|
19
|
+
result
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def field_filter?
|
|
25
|
+
(@filters.keys - COLLECTION_FILTERS).any?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def field_filter_key
|
|
29
|
+
(@filters.keys - COLLECTION_FILTERS).first
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def filter_by_lang(collection)
|
|
33
|
+
lang = @filters["lang"]
|
|
34
|
+
collection.reject { |c| c.localization(lang).nil? }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def filter_by_group(collection)
|
|
38
|
+
group = @filters["group"]
|
|
39
|
+
collection.select { |c| c.data.groups&.include?(group) }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def sort(collection)
|
|
43
|
+
field = @filters["sort_by"]
|
|
44
|
+
return collection unless field
|
|
45
|
+
|
|
46
|
+
case field
|
|
47
|
+
when "term", "default_designation"
|
|
48
|
+
collection.sort_by { |c| c.default_designation.to_s.downcase }
|
|
49
|
+
else
|
|
50
|
+
parts = parse_path(field)
|
|
51
|
+
collection.sort_by { |c| sort_key(c, parts) }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def sort_key(concept, parts)
|
|
56
|
+
hash = ConceptSerializer.new(concept).to_h
|
|
57
|
+
value = dig_path(hash, parts)
|
|
58
|
+
value.nil? ? SORT_LAST : natural_sort_key(value.to_s)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
SORT_LAST = [""].freeze
|
|
62
|
+
|
|
63
|
+
def natural_sort_key(str)
|
|
64
|
+
str.scan(/(\d+)|(\D+)/).map { |num, txt| num ? num.to_i : txt.downcase }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def filter_by_field(collection)
|
|
68
|
+
path = field_filter_key
|
|
69
|
+
value = @filters[path]
|
|
70
|
+
|
|
71
|
+
start_with = path.include?(".start_with(")
|
|
72
|
+
path, match_value = extract_start_with(path, value, start_with)
|
|
73
|
+
|
|
74
|
+
parts = parse_path(path)
|
|
75
|
+
collection.select do |concept|
|
|
76
|
+
hash = ConceptSerializer.new(concept).to_h
|
|
77
|
+
actual = dig_path(hash, parts)
|
|
78
|
+
if start_with
|
|
79
|
+
actual&.start_with?(match_value)
|
|
80
|
+
else
|
|
81
|
+
actual == value
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def extract_start_with(path, value, start_with)
|
|
87
|
+
return [path, value] unless start_with
|
|
88
|
+
|
|
89
|
+
match = path.match(/^([^.]+(?:\.[^.]+)*)\.start_with\(([^)]+)\)$/)
|
|
90
|
+
return [path, value] unless match
|
|
91
|
+
|
|
92
|
+
[match[1], match[2]]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def parse_path(path)
|
|
96
|
+
path.split(".").flat_map do |segment|
|
|
97
|
+
if segment.include?("[")
|
|
98
|
+
parse_indexed_segment(segment)
|
|
99
|
+
else
|
|
100
|
+
[segment]
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def parse_indexed_segment(segment)
|
|
106
|
+
field, index_part = segment.split("[", 2)
|
|
107
|
+
index = index_part&.delete("]'\"")
|
|
108
|
+
if index.match?(/\A\d+\z/)
|
|
109
|
+
[field, index.to_i]
|
|
110
|
+
else
|
|
111
|
+
[field, index]
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def dig_path(hash, parts)
|
|
116
|
+
parts.reduce(hash) do |current, key|
|
|
117
|
+
case current
|
|
118
|
+
when Hash
|
|
119
|
+
current[key] || current[key.to_s]
|
|
120
|
+
when Array
|
|
121
|
+
key.is_a?(Integer) ? current[key] : nil
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|