tc211-termbase 0.2.3 → 0.2.4

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: 423950f471ef5d9c689a3542150d988fc997489a12b4ffe3668520d84bf6561f
4
- data.tar.gz: f32b9f74dd1bb3310338785e58eb3488ba88656fa859fc3816e4615d9bad65a1
3
+ metadata.gz: 4e368538397b597d92173769f193389c8f8917aa228c84518777a5637e0e8474
4
+ data.tar.gz: a397b469e62394c577da6fd2527264a79d72d2249cb72144be4e593951b14c9f
5
5
  SHA512:
6
- metadata.gz: d4bb9c3b774042e3fe3674d30f1eb8211be2e0ac26f4834ee53646056d0b2fae276f9011776df5e7c36eae2bc450dda178ec32d03d0db9336eff50a55d16dd02
7
- data.tar.gz: 2dd00314060b0984f353112988ecf931310ab41f8b9a2737a5e9e55fcc8756f321a24085a7823fb3dd3a6e00c1c7357b84b4abe26bcc2741b2f38f78bb22d063
6
+ metadata.gz: 7694a9117a74cf937efde25496560a4d6c40a58f6d14aede4bcb78e3d0c16df39173680b7704d6824c13e66410d2244d68ff4685f3d893599c6f683e7a66d068
7
+ data.tar.gz: 4151e3efee8bcc149bd5709b25668d75d757e4237ea6b605678ea240e274e3c170a672df72b34958ae5751468c6ecebbf9c1406d5564597e419f88e1671c9fdc
@@ -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
@@ -339,6 +339,14 @@ module Tc211::Termbase
339
339
  }
340
340
  end
341
341
 
342
+ def authoritative_source_array
343
+ return unless authoritative_source
344
+
345
+ [
346
+ "link" => authoritative_source["link"],
347
+ ]
348
+ end
349
+
342
350
  def lineage_source_hash
343
351
  return unless lineage_source
344
352
 
@@ -352,7 +360,7 @@ module Tc211::Termbase
352
360
  end
353
361
 
354
362
  def to_localized_concept_hash
355
- localized_concept_hash = to_hash
363
+ concept_hash = to_hash
356
364
 
357
365
  %w[
358
366
  review_status
@@ -365,13 +373,17 @@ module Tc211::Termbase
365
373
  lineage_source_similarity
366
374
  country_code
367
375
  ].each do |key|
368
- localized_concept_hash.delete(key)
376
+ concept_hash.delete(key)
369
377
  end
370
378
 
371
- localized_concept_hash["id"] = localized_concept_hash["id"].to_s
372
- localized_concept_hash["sources"] = sources_hash
379
+ concept_hash["id"] = concept_hash["id"].to_s
380
+ concept_hash["sources"] = sources_hash
381
+
382
+ if authoritative_source_array
383
+ concept_hash["authoritativeSource"] = authoritative_source_array
384
+ end
373
385
 
374
- localized_concept_hash
386
+ concept_hash
375
387
  end
376
388
  end
377
389
  end
@@ -1,5 +1,5 @@
1
1
  module Tc211
2
2
  module Termbase
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
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.4
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-03-04 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