tc211-termbase 0.2.3 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 423950f471ef5d9c689a3542150d988fc997489a12b4ffe3668520d84bf6561f
4
- data.tar.gz: f32b9f74dd1bb3310338785e58eb3488ba88656fa859fc3816e4615d9bad65a1
3
+ metadata.gz: f68f93b8b87b009b39bc7332df0a30083e25d25d9107fe964a9fc048c587d7fa
4
+ data.tar.gz: 5fbcd25491ac31ed2f729e85db945be245eb75cab528351b0d625312aee6a6bc
5
5
  SHA512:
6
- metadata.gz: d4bb9c3b774042e3fe3674d30f1eb8211be2e0ac26f4834ee53646056d0b2fae276f9011776df5e7c36eae2bc450dda178ec32d03d0db9336eff50a55d16dd02
7
- data.tar.gz: 2dd00314060b0984f353112988ecf931310ab41f8b9a2737a5e9e55fcc8756f321a24085a7823fb3dd3a6e00c1c7357b84b4abe26bcc2741b2f38f78bb22d063
6
+ metadata.gz: afba8f8fc41d22fd6cbbd9bc9c40db3d7a3ef31011586a4fdb9e6d3d19f7531a066cb9deaf43abc603eee982d31fea60c172876ccc2fa496fe7c23b51c7433ab
7
+ data.tar.gz: fd1210037b404f703f951fc881681430e9022677650edd535999f43977a5e0a56b557e6e9df524a77ee545c95cb5c1aaea9e71ad41e0494d1fdafe51e7f43eb1
@@ -59,7 +59,9 @@ module Tc211::Termbase
59
59
  end
60
60
 
61
61
  def to_glossarist_concept
62
- concept = Glossarist::ManagedConcept.new(data: { id: id.to_s })
62
+ concept = Tc211::Termbase::Glossarist::ManagedConcept.new(
63
+ data: { id: id.to_s },
64
+ )
63
65
 
64
66
  localized_concepts = []
65
67
 
@@ -26,7 +26,7 @@ module Tc211::Termbase
26
26
  end
27
27
 
28
28
  def to_concept_collection
29
- collection = Glossarist::ManagedConceptCollection.new
29
+ collection = ::Glossarist::ManagedConceptCollection.new
30
30
 
31
31
  values.each do |term_concept|
32
32
  next if term_concept.nil?
@@ -0,0 +1,33 @@
1
+ module Tc211
2
+ module Termbase
3
+ module Glossarist
4
+ class Concept < ::Glossarist::LocalizedConcept
5
+ attr_accessor :status, :dateAccepted
6
+
7
+ def uuid
8
+ @uuid ||= ::Glossarist::Utilities::UUID.uuid_v5(
9
+ ::Glossarist::Utilities::UUID::OID_NAMESPACE,
10
+ to_h(only_data: true).to_yaml,
11
+ )
12
+ end
13
+
14
+ def to_h(only_data: false)
15
+ data_hash = super()
16
+ return data_hash if only_data
17
+
18
+ data_hash.merge(register_info)
19
+ end
20
+
21
+ def register_info
22
+ date_accepted = dates.find(&:accepted?)
23
+
24
+ {
25
+ "dateAccepted" => date_accepted&.date&.dup,
26
+ "id" => uuid,
27
+ "status" => entry_status,
28
+ }.compact
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ module Tc211
2
+ module Termbase
3
+ module Glossarist
4
+ class ManagedConcept < ::Glossarist::ManagedConcept
5
+ attr_accessor :status
6
+
7
+ def uuid
8
+ @uuid ||= ::Glossarist::Utilities::UUID.uuid_v5(
9
+ ::Glossarist::Utilities::UUID::OID_NAMESPACE,
10
+ to_h(only_data: true).to_yaml,
11
+ )
12
+ end
13
+
14
+ def to_h(only_data: false)
15
+ data_hash = super()
16
+ return data_hash if only_data
17
+
18
+ data_hash.merge(register_info)
19
+ end
20
+
21
+ def register_info
22
+ date_accepted = default_lang.dates.find(&:accepted?)
23
+
24
+ {
25
+ "dateAccepted" => date_accepted&.date&.dup,
26
+ "id" => uuid,
27
+ "related" => related&.map(&:to_h) || [],
28
+ "status" => default_lang.entry_status,
29
+ }.compact
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -213,6 +213,11 @@ module Tc211::Termbase
213
213
  @review_indicator = value
214
214
  end
215
215
 
216
+ def authoritative_source=(source)
217
+ clean_source!(source)
218
+ @authoritative_source = source
219
+ end
220
+
216
221
  # authoritative-source-similarity
217
222
  # Must be one of the following codes:
218
223
  # identical = 1
@@ -228,6 +233,11 @@ module Tc211::Termbase
228
233
  @authoritative_source_similarity = value
229
234
  end
230
235
 
236
+ def lineage_source=(source)
237
+ clean_source!(source)
238
+ @lineage_source = source
239
+ end
240
+
231
241
  # lineage-source-similarity
232
242
  # Must be one of the following codes:
233
243
  # identical = 1
@@ -243,6 +253,15 @@ module Tc211::Termbase
243
253
  @lineage_source_similarity = value
244
254
  end
245
255
 
256
+ def clean_source!(source)
257
+ if source.is_a?(Hash)
258
+ source["ref"]&.gsub!(/\(E\),?\s*/, "")
259
+ source["clause"]&.gsub!(/\(E\),?\s*/, "")
260
+ else
261
+ source.gsub!(/\(E\),?\s*/, "")
262
+ end
263
+ end
264
+
246
265
  ## value Must be one of pending tentative final
247
266
  def review_status=(value)
248
267
  unless ["", "pending", "tentative", "final"].include?(value)
@@ -339,6 +358,14 @@ module Tc211::Termbase
339
358
  }
340
359
  end
341
360
 
361
+ def authoritative_source_array
362
+ return unless authoritative_source
363
+
364
+ [
365
+ "link" => authoritative_source["link"],
366
+ ]
367
+ end
368
+
342
369
  def lineage_source_hash
343
370
  return unless lineage_source
344
371
 
@@ -352,7 +379,7 @@ module Tc211::Termbase
352
379
  end
353
380
 
354
381
  def to_localized_concept_hash
355
- localized_concept_hash = to_hash
382
+ concept_hash = to_hash
356
383
 
357
384
  %w[
358
385
  review_status
@@ -365,13 +392,17 @@ module Tc211::Termbase
365
392
  lineage_source_similarity
366
393
  country_code
367
394
  ].each do |key|
368
- localized_concept_hash.delete(key)
395
+ concept_hash.delete(key)
369
396
  end
370
397
 
371
- localized_concept_hash["id"] = localized_concept_hash["id"].to_s
372
- localized_concept_hash["sources"] = sources_hash
398
+ concept_hash["id"] = concept_hash["id"].to_s
399
+ concept_hash["sources"] = sources_hash
400
+
401
+ if authoritative_source_array
402
+ concept_hash["authoritativeSource"] = authoritative_source_array
403
+ end
373
404
 
374
- localized_concept_hash
405
+ concept_hash
375
406
  end
376
407
  end
377
408
  end
@@ -1,5 +1,5 @@
1
1
  module Tc211
2
2
  module Termbase
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.5"
4
4
  end
5
5
  end
@@ -1,10 +1,27 @@
1
1
  require "glossarist"
2
2
  require "tc211/termbase/version"
3
3
 
4
+ require_relative "termbase/glossarist/concept"
5
+ require_relative "termbase/glossarist/managed_concept"
6
+
4
7
  module Tc211
5
8
  module Termbase
6
9
  class Error < StandardError; end
10
+
7
11
  # Your code goes here...
12
+ ::Glossarist.configure do |config|
13
+ config.register_extension_attributes(["authoritativeSource"])
14
+
15
+ config.register_class(
16
+ :localized_concept,
17
+ Tc211::Termbase::Glossarist::Concept,
18
+ )
19
+
20
+ config.register_class(
21
+ :managed_concept,
22
+ Tc211::Termbase::Glossarist::ManagedConcept,
23
+ )
24
+ end
8
25
  end
9
26
  end
10
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tc211-termbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-21 00:00:00.000000000 Z
11
+ date: 2024-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: creek
@@ -117,6 +117,8 @@ files:
117
117
  - lib/tc211/termbase/cli/command.rb
118
118
  - lib/tc211/termbase/concept.rb
119
119
  - lib/tc211/termbase/concept_collection.rb
120
+ - lib/tc211/termbase/glossarist/concept.rb
121
+ - lib/tc211/termbase/glossarist/managed_concept.rb
120
122
  - lib/tc211/termbase/information_sheet.rb
121
123
  - lib/tc211/termbase/metadata_section.rb
122
124
  - lib/tc211/termbase/relaton_db.rb