glossarist 2.3.6 → 2.3.7

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: c0af35cdd40da6ea573d2dd4424a70c97016427ae9027b959f4235b322f8fcb5
4
+ data.tar.gz: b0e28310c983727e41ca6f35ddb1099a58dddead5fa30aa0a204851d0b8dc85f
5
5
  SHA512:
6
- metadata.gz: 3d4d9961dbc660975d821e5b34af478142bbfc67ed72648524ee6e0f6392d5d9cd2f64fa9e0cf3af83ff461576c7716d69065119d5f50c98fb5a9939ddffbc38
7
- data.tar.gz: 00ac99f6802c65138601a8900e2c7b2f3132947080a56c2a086c9abc6f4b6b590b78ce95a331446b3ce82d1e0338470624cb8a3713098fd92f2d69f9efd514cd
6
+ metadata.gz: ac19ff4ea8fdb5a81b4acaabade8b77879a0be14edef108af43cce863a9caa00dc8df4574634e3f58e697b6fd7ec7b05af001ccdbfbc37b01f9e05dff5b40927
7
+ data.tar.gz: fbd2b877dd317ed884c694917e1828886a8d6939fa887c86a410027c155f3baca5bfa2497921c0cf2decd66527da544c52a0ee1ce3426cf4919962d605de2c10
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,35 @@ 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
+ locality.type = value["type"] || "clause"
122
+ locality.reference_from = value["reference_from"] || value
123
+ locality.reference_to = value["reference_to"] if value["reference_to"]
124
+ locality.validate!
125
+
126
+ model.locality = locality
127
+ end
128
+
129
+ def clause_to_yaml(model, doc) # rubocop:disable Metrics/AbcSize
130
+ if model.locality
131
+ doc["locality"] = {}
132
+ doc["locality"]["type"] = model.locality.type
133
+
134
+ if model.locality.reference_from
135
+ doc["locality"]["reference_from"] = model.locality.reference_from
136
+ end
137
+
138
+ if model.locality.reference_to
139
+ doc["locality"]["reference_to"] = model.locality.reference_to
140
+ end
141
+ end
142
+ end
143
+
111
144
  def plain?
112
145
  (source && id && version).nil?
113
146
  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.7"
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.7
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-03 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