glossarist 2.14.7 → 2.14.9.pre.alpha.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d7e9c15feb04132c6f4c646fff03f75e9603d82cd5f3b5227ae68d8d86de0f1
4
- data.tar.gz: 37533585b2a03023fe7df4b02ba2ba0433145b8c53899c2035ea0345f95dcc65
3
+ metadata.gz: 4a44ef570dcddda66267ffa8c081d6a768cb34652d32eec1c28ba5f73a44693a
4
+ data.tar.gz: 45db447e51af2dcce1d3af2beec43394b04395506791a76bdfd9949259b033bf
5
5
  SHA512:
6
- metadata.gz: ab12bf6c2d0381345d9a555e03c48bb4fa4ef6ecd23ea8a013e9e0b501ebabb5784707af479f5fbcb8121f862cc02b78120a35eee83ed3eeaa97751b7ab4ffc6
7
- data.tar.gz: 0baef80b82bade98dc4b90c60517ae8793ec84ec57d34a7683d4e254aee2959a4fb454dbdf6791b3d4cf89854144a1735b59682eebbea79fbd39659c9257bf9f
6
+ metadata.gz: f52184d95196df06b8ca93b3b71a7ca279cfb1627ba39408db76cb20147509e44cc2e231bd5c94a15729575d25386a1941218fad82480570eb59236cb4f986a5
7
+ data.tar.gz: bde585891da84147fc67cad41718c63cba4bb43ad828c3a88f3491a70fd2718aa5b67c2471e49e30b27e88e7ec52c0c66c22825e632344fb685d0a27239a1228
@@ -14,6 +14,11 @@ module Glossarist
14
14
  end
15
15
  end
16
16
 
17
+ # Segments that begin the item path of an ISO URN (the "element"
18
+ # segments of ISO 6701-style URNs); everything before the first of
19
+ # these is the cited document's identity.
20
+ URN_ELEMENT_SEGMENTS = %w[tech term doc fig tab sec loc rem].freeze
21
+
17
22
  attribute :ref, Ref
18
23
  attribute :text, :string
19
24
  attribute :locality, Locality
@@ -40,6 +45,21 @@ module Glossarist
40
45
  @text || label
41
46
  end
42
47
 
48
+ # The cited document's identity URN — the source URN minus its item
49
+ # path. For "urn:iso:std:iso:10303:-2:ed-1:en:tech:ACTIVITY_MIM"
50
+ # this is "urn:iso:std:iso:10303:-2:ed-1:en". Non-URN sources have
51
+ # no document identity.
52
+ def document_urn
53
+ split_urn_source&.first || urn_source
54
+ end
55
+
56
+ # The item path inside the cited document — the URN's element
57
+ # segments ("tech:ACTIVITY_MIM:tech:ACTIVITY_MIM"). Nil when the
58
+ # source is not a URN or carries no element segments.
59
+ def item_path
60
+ split_urn_source&.last
61
+ end
62
+
43
63
  def locality_from_yaml(model, value)
44
64
  locality = Locality.new
45
65
 
@@ -70,5 +90,23 @@ module Glossarist
70
90
  model.locality.reference_to
71
91
  end
72
92
  end
93
+
94
+ private
95
+
96
+ def urn_source
97
+ source = ref&.source
98
+ source&.start_with?("urn:") ? source : nil
99
+ end
100
+
101
+ def split_urn_source
102
+ source = urn_source
103
+ return nil unless source
104
+
105
+ segments = source.split(":")
106
+ idx = segments.index { |s| URN_ELEMENT_SEGMENTS.include?(s) }
107
+ return nil unless idx
108
+
109
+ [segments[0...idx].join(":"), segments[idx..].join(":")]
110
+ end
73
111
  end
74
112
  end
@@ -30,6 +30,19 @@ module Glossarist
30
30
  map :identifier, to: :id, with: { to: :id_to_yaml, from: :id_from_yaml }
31
31
  end
32
32
 
33
+ def self.of_yaml(hash, options = {})
34
+ if hash.is_a?(Hash)
35
+ extensions = hash.select do |key, _value|
36
+ Config.extension_attributes.include?(key.to_s)
37
+ end
38
+ unless extensions.empty?
39
+ existing = hash["extension_attributes"] || hash["extensionAttributes"] || {}
40
+ hash = hash.merge("extension_attributes" => existing.merge(extensions))
41
+ end
42
+ end
43
+ super
44
+ end
45
+
33
46
  def designations
34
47
  data.terms
35
48
  end
@@ -136,16 +136,22 @@ module Glossarist
136
136
  concept_id = concept.is_a?(ManagedConcept) ? concept.data&.id : nil
137
137
  return [] unless concept_id
138
138
 
139
- all_section_ids = collect_all_section_ids
140
- all_section_ids.select { |sid| concept_id.start_with?("#{sid}-", "#{sid}.") }
139
+ all_section_ids
140
+ .select { |sid| concept_id.start_with?("#{sid}-", "#{sid}.") }
141
141
  .max_by(&:length)
142
142
  &.then { |sid| [sid] } || []
143
143
  end
144
144
 
145
- def collect_all_section_ids
146
- ids = []
147
- walk_section_tree(sections, []) { |section, _| ids << section.id }
148
- ids
145
+ # One flattened section-id list, computed once: derivation runs per
146
+ # concept without explicit section domains, and re-walking the whole
147
+ # section tree per concept is quadratic on large registers (ISO
148
+ # 10303-2: 7,363 concepts x 1,240 sections).
149
+ def all_section_ids
150
+ @all_section_ids ||= begin
151
+ ids = []
152
+ walk_section_tree(sections, []) { |section, _| ids << section.id }
153
+ ids
154
+ end
149
155
  end
150
156
  end
151
157
  end
@@ -5,6 +5,8 @@ module Glossarist
5
5
  attribute :entry_status, :string
6
6
 
7
7
  key_value do
8
+ map :status, to: :entry_status,
9
+ with: { from: :status_from_yaml, to: :status_to_yaml }
8
10
  map :classification, to: :classification
9
11
  map %i[review_type reviewType], to: :review_type
10
12
  end
@@ -20,8 +22,6 @@ module Glossarist
20
22
  super
21
23
  end
22
24
 
23
- alias_method :status=, :entry_status=
24
-
25
25
  def language_code
26
26
  data.language_code
27
27
  end
@@ -38,6 +38,16 @@ module Glossarist
38
38
  data.entry_status = value
39
39
  end
40
40
 
41
+ alias_method :status=, :entry_status=
42
+
43
+ # Legacy top-level `status` is read only: it fills entry_status when
44
+ # data.entry_status is absent, and is never written back out.
45
+ def status_from_yaml(model, value)
46
+ model.entry_status ||= value
47
+ end
48
+
49
+ def status_to_yaml(_model, _doc); end
50
+
41
51
  def all_sources
42
52
  data.all_sources
43
53
  end
@@ -4,5 +4,5 @@
4
4
  #
5
5
 
6
6
  module Glossarist
7
- VERSION = "2.14.7"
7
+ VERSION = "2.14.9.pre.alpha.1"
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glossarist
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.7
4
+ version: 2.14.9.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-25 00:00:00.000000000 Z
11
+ date: 2026-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model