glossarist 2.3.6 → 2.3.8

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: 46a366e3347c14171eff6007662c77f2a88fb8982e79f9291175db73757bc032
4
- data.tar.gz: 642fce8985472649f1fffd9a6a10f92ef36cf0e70ad8309e21df5d49e7379224
3
+ metadata.gz: 455c768825abe3d31abeb221718eb6d9385478fe1a32645ebaae67b82b7bda14
4
+ data.tar.gz: 9fe994e3a6f2cc3b306c533e620f5faf432f1f4b48a888f059a4ecbeba5fc323
5
5
  SHA512:
6
- metadata.gz: 3d4d9961dbc660975d821e5b34af478142bbfc67ed72648524ee6e0f6392d5d9cd2f64fa9e0cf3af83ff461576c7716d69065119d5f50c98fb5a9939ddffbc38
7
- data.tar.gz: 00ac99f6802c65138601a8900e2c7b2f3132947080a56c2a086c9abc6f4b6b590b78ce95a331446b3ce82d1e0338470624cb8a3713098fd92f2d69f9efd514cd
6
+ metadata.gz: 26e205c1940c3aa3eabeef7553b0e334d63d6365e10f4e97e0fd59acc3c37cfc7f7c19d707dac98c61d021b3b689d86074af3bad2f37a19aa95328703557fe19
7
+ data.tar.gz: ba10c0a69e804726607bed7ca36563ecf20b849a5c100a57bbd9409313b2eea0946ebbbdea048aede5c6596bd7babd72c49c125e58d096ce7c44561afa8eee4c
data/Gemfile CHANGED
@@ -5,6 +5,5 @@ source "https://rubygems.org"
5
5
  gem "pry"
6
6
  gem "rake"
7
7
  gem "rspec"
8
- gem "lutaml-model", github: "lutaml/lutaml-model", branch: "main"
9
8
 
10
9
  gemspec
@@ -17,8 +17,8 @@ module Glossarist
17
17
  attribute :version, :string
18
18
 
19
19
  # @return [String]
20
- # Referred clause of the document.
21
- attribute :clause, :string
20
+ # Referred locality of the document.
21
+ attribute :locality, Locality
22
22
 
23
23
  # Link to document.
24
24
  # @return [String]
@@ -32,6 +32,8 @@ module Glossarist
32
32
 
33
33
  attribute :ref, :string
34
34
 
35
+ attribute :custom_locality, CustomLocality, collection: true
36
+
35
37
  yaml do
36
38
  map :id, to: :id, with: { from: :id_from_yaml, to: :id_to_yaml }
37
39
  map :text, to: :text, with: { from: :text_from_yaml, to: :text_to_yaml }
@@ -40,10 +42,12 @@ module Glossarist
40
42
  map :version, to: :version,
41
43
  with: { from: :version_from_yaml, to: :version_to_yaml }
42
44
  map :ref, to: :ref, with: { from: :ref_from_yaml, to: :ref_to_yaml }
43
-
44
- map :clause, to: :clause
45
+ map %i[clause locality],
46
+ to: :locality,
47
+ with: { from: :clause_from_yaml, to: :clause_to_yaml }
45
48
  map :link, to: :link
46
49
  map :original, to: :original
50
+ map %i[custom_locality customLocality], to: :custom_locality
47
51
  end
48
52
 
49
53
  def ref_from_yaml(model, value)
@@ -108,6 +112,42 @@ module Glossarist
108
112
  end
109
113
  end
110
114
 
115
+ def clause_from_yaml(model, value)
116
+ # accepts old format like
117
+ # clause: "11"
118
+ # or new format like
119
+ # locality: { type: "clause", reference_from: "11", reference_to: "12" }
120
+ locality = Locality.new
121
+
122
+ if value.is_a?(Hash)
123
+ locality.type = value["type"] || "clause"
124
+ locality.reference_from = value["reference_from"] || value
125
+ locality.reference_to = value["reference_to"] if value["reference_to"]
126
+ locality.validate!
127
+ else
128
+ locality.type = "clause"
129
+ locality.reference_from = value
130
+ locality.validate!
131
+ end
132
+
133
+ model.locality = locality
134
+ end
135
+
136
+ def clause_to_yaml(model, doc) # rubocop:disable Metrics/AbcSize
137
+ if model.locality
138
+ doc["locality"] = {}
139
+ doc["locality"]["type"] = model.locality.type
140
+
141
+ if model.locality.reference_from
142
+ doc["locality"]["reference_from"] = model.locality.reference_from
143
+ end
144
+
145
+ if model.locality.reference_to
146
+ doc["locality"]["reference_to"] = model.locality.reference_to
147
+ end
148
+ end
149
+ end
150
+
111
151
  def plain?
112
152
  (source && id && version).nil?
113
153
  end
@@ -60,7 +60,9 @@ module Glossarist
60
60
 
61
61
  # Writes all concepts to files.
62
62
  def save_concepts
63
- @index.each_value &method(:save_concept_to_file)
63
+ @index.each_value do |concept|
64
+ save_concept_to_file(concept)
65
+ end
64
66
  end
65
67
 
66
68
  def load_concept_from_file(filename)
@@ -19,7 +19,9 @@ module Glossarist
19
19
  end
20
20
 
21
21
  def save_to_files(managed_concepts)
22
- managed_concepts.each &method(:save_concept_to_file)
22
+ managed_concepts.each do |concept|
23
+ save_concept_to_file(concept)
24
+ end
23
25
  end
24
26
 
25
27
  def load_concept_from_file(filename)
@@ -0,0 +1,16 @@
1
+ module Glossarist
2
+ class CustomLocality < Lutaml::Model::Serializable
3
+ # The name of the custom locality.
4
+ # @return [String]
5
+ attribute :name, :string
6
+
7
+ # The value of the custom locality, which can be any string.
8
+ # @return [String]
9
+ attribute :value, :string
10
+
11
+ yaml do
12
+ map :name, to: :name
13
+ map :value, to: :value
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ module Glossarist
2
+ class Locality < Lutaml::Model::Serializable
3
+ # @return [String]
4
+ attribute :type, :string, pattern: %r{
5
+ section|clause|part|paragraph|chapter|page|title|line|
6
+ whole|table|annex|figure|note|list|example|volume|issue|time|anchor|
7
+ locality:[a-zA-Z0-9_]+
8
+ }x
9
+
10
+ # @return [String]
11
+ attribute :reference_from, :string
12
+
13
+ # @return [String]
14
+ attribute :reference_to, :string
15
+
16
+ yaml do
17
+ map :type, to: :type
18
+ map :reference_from, to: :reference_from
19
+ map :reference_to, to: :reference_to
20
+ end
21
+ end
22
+ end
@@ -85,7 +85,7 @@ module Glossarist
85
85
  model.identifier = value || model.identifier
86
86
  end
87
87
 
88
- def localized_concepts=(localized_concepts_collection)
88
+ def localized_concepts=(localized_concepts_collection) # rubocop:disable Metrics/AbcSize
89
89
  return unless localized_concepts_collection
90
90
 
91
91
  if localized_concepts_collection.is_a?(Hash)
@@ -4,5 +4,5 @@
4
4
  #
5
5
 
6
6
  module Glossarist
7
- VERSION = "2.3.6"
7
+ VERSION = "2.3.8"
8
8
  end
data/lib/glossarist.rb CHANGED
@@ -13,6 +13,8 @@ require_relative "glossarist/glossary_definition"
13
13
 
14
14
  require_relative "glossarist/designation"
15
15
  require_relative "glossarist/asset"
16
+ require_relative "glossarist/locality"
17
+ require_relative "glossarist/custom_locality"
16
18
  require_relative "glossarist/citation"
17
19
  require_relative "glossarist/collection"
18
20
  require_relative "glossarist/concept_date"
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.3.6
4
+ version: 2.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-05-09 00:00:00.000000000 Z
11
+ date: 2025-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model
@@ -91,6 +91,7 @@ files:
91
91
  - lib/glossarist/concept_set.rb
92
92
  - lib/glossarist/concept_source.rb
93
93
  - lib/glossarist/config.rb
94
+ - lib/glossarist/custom_locality.rb
94
95
  - lib/glossarist/designation.rb
95
96
  - lib/glossarist/designation/abbreviation.rb
96
97
  - lib/glossarist/designation/base.rb
@@ -105,6 +106,7 @@ files:
105
106
  - lib/glossarist/error/invalid_type_error.rb
106
107
  - lib/glossarist/error/parse_error.rb
107
108
  - lib/glossarist/glossary_definition.rb
109
+ - lib/glossarist/locality.rb
108
110
  - lib/glossarist/localized_concept.rb
109
111
  - lib/glossarist/managed_concept.rb
110
112
  - lib/glossarist/managed_concept_collection.rb