glossarist 2.2.1 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +65 -0
- data/README.adoc +2 -2
- data/config.yml +1 -1
- data/glossarist.gemspec +1 -0
- data/lib/glossarist/asset.rb +4 -9
- data/lib/glossarist/citation.rb +73 -41
- data/lib/glossarist/collection.rb +2 -11
- data/lib/glossarist/collections/asset_collection.rb +0 -3
- data/lib/glossarist/collections/bibliography_collection.rb +1 -1
- data/lib/glossarist/concept.rb +67 -206
- data/lib/glossarist/concept_data.rb +66 -0
- data/lib/glossarist/concept_date.rb +7 -11
- data/lib/glossarist/concept_manager.rb +19 -29
- data/lib/glossarist/concept_set.rb +6 -4
- data/lib/glossarist/concept_source.rb +15 -58
- data/lib/glossarist/config.rb +4 -4
- data/lib/glossarist/designation/abbreviation.rb +15 -16
- data/lib/glossarist/designation/base.rb +16 -15
- data/lib/glossarist/designation/expression.rb +18 -26
- data/lib/glossarist/designation/grammar_info.rb +29 -45
- data/lib/glossarist/designation/graphical_symbol.rb +12 -8
- data/lib/glossarist/designation/letter_symbol.rb +13 -11
- data/lib/glossarist/designation/symbol.rb +11 -13
- data/lib/glossarist/designation.rb +3 -3
- data/lib/glossarist/detailed_definition.rb +6 -24
- data/lib/glossarist/error.rb +4 -4
- data/lib/glossarist/glossary_definition.rb +6 -3
- data/lib/glossarist/localized_concept.rb +17 -61
- data/lib/glossarist/managed_concept.rb +74 -146
- data/lib/glossarist/managed_concept_collection.rb +15 -24
- data/lib/glossarist/managed_concept_data.rb +47 -0
- data/lib/glossarist/non_verb_rep.rb +10 -13
- data/lib/glossarist/related_concept.rb +14 -21
- data/lib/glossarist/utilities/uuid.rb +10 -5
- data/lib/glossarist/utilities.rb +0 -2
- data/lib/glossarist/version.rb +1 -1
- data/lib/glossarist.rb +10 -9
- metadata +23 -13
- data/lib/glossarist/model.rb +0 -40
- data/lib/glossarist/utilities/boolean_attributes.rb +0 -35
- data/lib/glossarist/utilities/enum/class_methods.rb +0 -99
- data/lib/glossarist/utilities/enum/enum_collection.rb +0 -45
- data/lib/glossarist/utilities/enum/instance_methods.rb +0 -55
- data/lib/glossarist/utilities/enum.rb +0 -21
- data/lib/glossarist/v1_reader.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04b9e5d5f00de57e8d2c9aff73d25697758be004f33c5d02c0fdbf6254c69521
|
4
|
+
data.tar.gz: bca6a55ce2c23c374ab5d0e8745803f5ea77af3535ab94835726eeb06f331600
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fa6e324a0f5a72a682a30492fa440731570da4f1b976b293318bd331b888743702e8241b9135a8a4aacc56cbdf266ca1319de9519fa8c0c09f56d9e9fa0e308
|
7
|
+
data.tar.gz: '09cc267101990c505ffeb3798887fc79d42b8c0aef6aa25424971095d5c745fa1a9bd9142f99adf7c012c7dce0d670e07ddfb932d85ca65603d6c5c9b9cbbd0f'
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2025-01-16 08:32:21 UTC using RuboCop version 1.70.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: Severity, Include.
|
11
|
+
# Include: **/*.gemspec
|
12
|
+
Gemspec/RequiredRubyVersion:
|
13
|
+
Exclude:
|
14
|
+
- 'glossarist.gemspec'
|
15
|
+
|
16
|
+
# Offense count: 64
|
17
|
+
# This cop supports safe autocorrection (--autocorrect).
|
18
|
+
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
|
19
|
+
# URISchemes: http, https
|
20
|
+
Layout/LineLength:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
# Offense count: 1
|
24
|
+
# Configuration parameters: AllowedMethods.
|
25
|
+
# AllowedMethods: enums
|
26
|
+
Lint/ConstantDefinitionInBlock:
|
27
|
+
Exclude:
|
28
|
+
- 'spec/unit/utilities/common_functions_spec.rb'
|
29
|
+
|
30
|
+
# Offense count: 2
|
31
|
+
Lint/DuplicateMethods:
|
32
|
+
Exclude:
|
33
|
+
- 'lib/glossarist/managed_concept.rb'
|
34
|
+
|
35
|
+
# Offense count: 3
|
36
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
37
|
+
Metrics/AbcSize:
|
38
|
+
Exclude:
|
39
|
+
- 'lib/glossarist/concept_manager.rb'
|
40
|
+
- 'lib/glossarist/utilities/uuid.rb'
|
41
|
+
|
42
|
+
# Offense count: 2
|
43
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
44
|
+
Metrics/CyclomaticComplexity:
|
45
|
+
Exclude:
|
46
|
+
- 'lib/glossarist/designation/expression.rb'
|
47
|
+
- 'lib/glossarist/managed_concept.rb'
|
48
|
+
|
49
|
+
# Offense count: 6
|
50
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
51
|
+
Metrics/MethodLength:
|
52
|
+
Max: 20
|
53
|
+
|
54
|
+
# Offense count: 1
|
55
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
56
|
+
Metrics/PerceivedComplexity:
|
57
|
+
Exclude:
|
58
|
+
- 'lib/glossarist/designation/expression.rb'
|
59
|
+
|
60
|
+
# Offense count: 6
|
61
|
+
# This cop supports safe autocorrection (--autocorrect).
|
62
|
+
# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
|
63
|
+
# SupportedStyles: annotated, template, unannotated
|
64
|
+
Style/FormatStringToken:
|
65
|
+
EnforcedStyle: unannotated
|
data/README.adoc
CHANGED
@@ -210,7 +210,7 @@ There are two ways to initialize and populate a concept date
|
|
210
210
|
[,ruby]
|
211
211
|
----
|
212
212
|
concept_date = Glossarist::ConceptDate.new({
|
213
|
-
date: "2010-11-01T00:00:00
|
213
|
+
date: "2010-11-01T00:00:00+00:00",
|
214
214
|
type: :accepted,
|
215
215
|
})
|
216
216
|
----
|
@@ -221,7 +221,7 @@ concept_date = Glossarist::ConceptDate.new({
|
|
221
221
|
----
|
222
222
|
concept_date = Glossarist::ConceptDate.new
|
223
223
|
concept_date.type = :accepted
|
224
|
-
concept_date.date = "2010-11-01T00:00:00
|
224
|
+
concept_date.date = "2010-11-01T00:00:00+00:00"
|
225
225
|
----
|
226
226
|
|
227
227
|
[[id,detailed-definition]]
|
data/config.yml
CHANGED
data/glossarist.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
+
spec.add_dependency "lutaml-model", "~> 0.5.0"
|
33
34
|
spec.add_dependency "relaton", "~> 1.19"
|
34
35
|
spec.add_dependency "thor"
|
35
36
|
end
|
data/lib/glossarist/asset.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# (c) Copyright 2021 Ribose Inc.
|
4
|
-
#
|
5
|
-
|
6
1
|
module Glossarist
|
7
|
-
class Asset
|
8
|
-
|
2
|
+
class Asset < Lutaml::Model::Serializable
|
3
|
+
attribute :path, :string
|
9
4
|
|
10
|
-
|
11
|
-
|
5
|
+
yaml do
|
6
|
+
map :path, to: :path
|
12
7
|
end
|
13
8
|
|
14
9
|
def eql?(asset)
|
data/lib/glossarist/citation.rb
CHANGED
@@ -1,69 +1,101 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# (c) Copyright 2021 Ribose Inc.
|
4
|
-
#
|
5
|
-
|
6
1
|
module Glossarist
|
7
|
-
class Citation < Model
|
2
|
+
class Citation < Lutaml::Model::Serializable
|
8
3
|
# Unstructured (plain text) reference.
|
9
4
|
# @return [String]
|
10
|
-
|
5
|
+
attribute :text, :string
|
11
6
|
|
12
7
|
# Source in structured reference.
|
13
8
|
# @return [String]
|
14
|
-
|
9
|
+
attribute :source, :string
|
15
10
|
|
16
11
|
# Document ID in structured reference.
|
17
12
|
# @return [String]
|
18
|
-
|
13
|
+
attribute :id, :string
|
19
14
|
|
20
15
|
# Document version in structured reference.
|
21
16
|
# @return [String]
|
22
|
-
|
17
|
+
attribute :version, :string
|
23
18
|
|
24
19
|
# @return [String]
|
25
20
|
# Referred clause of the document.
|
26
|
-
|
21
|
+
attribute :clause, :string
|
27
22
|
|
28
23
|
# Link to document.
|
29
24
|
# @return [String]
|
30
|
-
|
25
|
+
attribute :link, :string
|
31
26
|
|
32
27
|
# Original ref text before parsing.
|
33
28
|
# @return [String]
|
34
29
|
# @note This attribute is likely to be removed or reworked in future.
|
35
30
|
# It is arguably not relevant to Glossarist itself.
|
36
|
-
|
31
|
+
attribute :original, :string
|
32
|
+
|
33
|
+
attribute :ref, :string
|
34
|
+
|
35
|
+
yaml do
|
36
|
+
map :id, to: :id, with: { from: :id_from_yaml, to: :id_to_yaml }
|
37
|
+
map :text, to: :text, with: { from: :text_from_yaml, to: :text_to_yaml }
|
38
|
+
map :source, to: :source,
|
39
|
+
with: { from: :source_from_yaml, to: :source_to_yaml }
|
40
|
+
map :version, to: :version,
|
41
|
+
with: { from: :version_from_yaml, to: :version_to_yaml }
|
42
|
+
map :ref, to: :ref, with: { from: :ref_from_yaml, to: :ref_to_yaml }
|
43
|
+
|
44
|
+
map :clause, to: :clause
|
45
|
+
map :link, to: :link
|
46
|
+
map :original, to: :original
|
47
|
+
end
|
37
48
|
|
38
|
-
|
39
|
-
|
40
|
-
def plain?
|
41
|
-
(source && id && version).nil?
|
49
|
+
def ref_from_yaml(model, value)
|
50
|
+
model.ref = value
|
42
51
|
end
|
43
52
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
53
|
+
def ref_to_yaml(model, doc)
|
54
|
+
doc["ref"] = if model.structured?
|
55
|
+
ref_hash(model)
|
56
|
+
else
|
57
|
+
model.text
|
58
|
+
end
|
48
59
|
end
|
49
60
|
|
50
|
-
def
|
51
|
-
|
52
|
-
"ref" => ref_to_h,
|
53
|
-
"clause" => clause,
|
54
|
-
"link" => link,
|
55
|
-
"original" => original,
|
56
|
-
}.compact
|
61
|
+
def id_from_yaml(model, value)
|
62
|
+
model.id = value
|
57
63
|
end
|
58
64
|
|
59
|
-
def
|
60
|
-
|
65
|
+
def id_to_yaml(_model, _doc)
|
66
|
+
# skip, will be handled in ref
|
67
|
+
end
|
61
68
|
|
62
|
-
|
63
|
-
|
64
|
-
|
69
|
+
def text_from_yaml(model, value)
|
70
|
+
model.text = value
|
71
|
+
end
|
72
|
+
|
73
|
+
def text_to_yaml(_model, _doc)
|
74
|
+
# skip, will be handled in ref
|
75
|
+
end
|
76
|
+
|
77
|
+
def source_from_yaml(model, value)
|
78
|
+
model.source = value
|
79
|
+
end
|
65
80
|
|
66
|
-
|
81
|
+
def source_to_yaml(_model, _doc)
|
82
|
+
# skip, will be handled in ref
|
83
|
+
end
|
84
|
+
|
85
|
+
def version_from_yaml(model, value)
|
86
|
+
model.version = value
|
87
|
+
end
|
88
|
+
|
89
|
+
def version_to_yaml(_model, _doc)
|
90
|
+
# skip, will be handled in ref
|
91
|
+
end
|
92
|
+
|
93
|
+
def ref_hash(model = self)
|
94
|
+
{
|
95
|
+
"source" => model.source,
|
96
|
+
"id" => model.id,
|
97
|
+
"version" => model.version,
|
98
|
+
}.compact
|
67
99
|
end
|
68
100
|
|
69
101
|
def ref=(ref)
|
@@ -76,14 +108,14 @@ module Glossarist
|
|
76
108
|
end
|
77
109
|
end
|
78
110
|
|
79
|
-
|
111
|
+
def plain?
|
112
|
+
(source && id && version).nil?
|
113
|
+
end
|
80
114
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
text
|
86
|
-
end
|
115
|
+
# Whether it is a structured ref.
|
116
|
+
# @return [Boolean]
|
117
|
+
def structured?
|
118
|
+
!plain?
|
87
119
|
end
|
88
120
|
end
|
89
121
|
end
|
@@ -1,8 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# (c) Copyright 2021 Ribose Inc.
|
4
|
-
#
|
5
|
-
|
6
1
|
module Glossarist
|
7
2
|
# @todo Add support for lazy concept loading.
|
8
3
|
# @todo Consider extracting persistence backend to a separate class.
|
@@ -33,7 +28,6 @@ module Glossarist
|
|
33
28
|
def fetch(id)
|
34
29
|
@index[id]
|
35
30
|
end
|
36
|
-
|
37
31
|
alias :[] :fetch
|
38
32
|
|
39
33
|
# If concept with given ID is present in this collection, returns that
|
@@ -44,7 +38,7 @@ module Glossarist
|
|
44
38
|
# Concept ID
|
45
39
|
# @return [Concept]
|
46
40
|
def fetch_or_initialize(id)
|
47
|
-
fetch(id) or store(Concept.
|
41
|
+
fetch(id) or store(Concept.of_yaml({ id: id }))
|
48
42
|
end
|
49
43
|
|
50
44
|
# Adds concept to the collection. If collection contains a concept with
|
@@ -55,7 +49,6 @@ module Glossarist
|
|
55
49
|
def store(concept)
|
56
50
|
@index[concept.id] = concept
|
57
51
|
end
|
58
|
-
|
59
52
|
alias :<< :store
|
60
53
|
|
61
54
|
# Reads all concepts from files.
|
@@ -70,10 +63,8 @@ module Glossarist
|
|
70
63
|
@index.each_value &method(:save_concept_to_file)
|
71
64
|
end
|
72
65
|
|
73
|
-
private
|
74
|
-
|
75
66
|
def load_concept_from_file(filename)
|
76
|
-
Concept.
|
67
|
+
Concept.from_yaml(File.read(filename))
|
77
68
|
rescue Psych::SyntaxError => e
|
78
69
|
raise Glossarist::ParseError.new(filename: filename, line: e.line)
|
79
70
|
end
|
data/lib/glossarist/concept.rb
CHANGED
@@ -1,244 +1,105 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# (c) Copyright 2021 Ribose Inc.
|
4
|
-
#
|
5
|
-
|
6
1
|
module Glossarist
|
7
|
-
class Concept < Model
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
attr_reader :notes
|
39
|
-
|
40
|
-
# Concept examples
|
41
|
-
# @return [Array<DetailedDefinition>]
|
42
|
-
attr_reader :examples
|
43
|
-
|
44
|
-
# Contains list of extended attributes
|
45
|
-
attr_accessor :extension_attributes
|
46
|
-
|
47
|
-
attr_accessor :lineage_source
|
48
|
-
attr_accessor :lineage_source_similarity
|
49
|
-
|
50
|
-
attr_accessor :release
|
51
|
-
|
52
|
-
def initialize(*args)
|
53
|
-
@localizations = {}
|
54
|
-
@sources = Glossarist::Collections::Collection.new(klass: ConceptSource)
|
55
|
-
@related = Glossarist::Collections::Collection.new(klass: RelatedConcept)
|
56
|
-
@definition = Glossarist::Collections::Collection.new(klass: DetailedDefinition)
|
57
|
-
@notes = Glossarist::Collections::Collection.new(klass: DetailedDefinition)
|
58
|
-
@examples = Glossarist::Collections::Collection.new(klass: DetailedDefinition)
|
59
|
-
@dates = Glossarist::Collections::Collection.new(klass: ConceptDate)
|
60
|
-
|
61
|
-
@designations = Glossarist::Collections::DesignationCollection.new
|
62
|
-
@extension_attributes = {}
|
63
|
-
|
64
|
-
normalize_args(args)
|
65
|
-
|
66
|
-
super
|
67
|
-
end
|
68
|
-
|
69
|
-
def uuid
|
70
|
-
@uuid ||= Glossarist::Utilities::UUID.uuid_v5(
|
71
|
-
Glossarist::Utilities::UUID::OID_NAMESPACE,
|
72
|
-
to_h_no_uuid.to_yaml,
|
73
|
-
)
|
2
|
+
class Concept < Lutaml::Model::Serializable
|
3
|
+
attribute :data, ConceptData, default: -> { ConceptData.new }
|
4
|
+
attribute :id, :string
|
5
|
+
attribute :uuid, :string
|
6
|
+
attribute :subject, :string
|
7
|
+
attribute :non_verb_rep, :string
|
8
|
+
attribute :extension_attributes, :string
|
9
|
+
attribute :lineage_source, :string
|
10
|
+
attribute :localizations, :hash
|
11
|
+
attribute :extension_attributes, :hash
|
12
|
+
attribute :termid, :string
|
13
|
+
|
14
|
+
yaml do
|
15
|
+
map :data, to: :data
|
16
|
+
map :termid, to: :termid
|
17
|
+
map :subject, to: :subject
|
18
|
+
map :non_verb_rep, to: :non_verb_rep
|
19
|
+
map :extension_attributes, to: :extension_attributes
|
20
|
+
map :lineage_source, to: :lineage_source
|
21
|
+
map :localizations, to: :localizations
|
22
|
+
map :extension_attributes, to: :extension_attributes
|
23
|
+
|
24
|
+
map :date_accepted,
|
25
|
+
with: { from: :date_accepted_from_yaml, to: :date_accepted_to_yaml }
|
26
|
+
map :uuid, to: :uuid, with: { to: :uuid_to_yaml, from: :uuid_from_yaml }
|
27
|
+
map :id, to: :id, with: { to: :id_to_yaml, from: :id_from_yaml }
|
28
|
+
map :identifier, to: :id, with: { to: :id_to_yaml, from: :id_from_yaml }
|
29
|
+
end
|
30
|
+
|
31
|
+
def designations
|
32
|
+
data.terms
|
74
33
|
end
|
34
|
+
alias :terms :designations
|
75
35
|
|
76
|
-
def
|
77
|
-
|
78
|
-
# so adding a temporary check until every glossary is updated using glossarist.
|
79
|
-
if !id.nil? && (id.is_a?(String) || id.is_a?(Integer))
|
80
|
-
@id = id
|
81
|
-
else
|
82
|
-
raise(Glossarist::Error, "Expect id to be a String or Integer, Got #{id.class} (#{id})")
|
83
|
-
end
|
36
|
+
def definition
|
37
|
+
data.definition
|
84
38
|
end
|
85
39
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
# List of authorative sources.
|
90
|
-
# @todo Alias +authoritative_source+ exists for legacy reasons and may be
|
91
|
-
# removed.
|
92
|
-
# @return [Array<ConceptSource>]
|
93
|
-
attr_reader :sources
|
94
|
-
|
95
|
-
# return [Array<ConceptDate>]
|
96
|
-
attr_reader :dates
|
97
|
-
|
98
|
-
def examples=(examples)
|
99
|
-
@examples.clear!
|
100
|
-
examples&.each { |example| @examples << example }
|
40
|
+
def definition=(value)
|
41
|
+
data.definition = value
|
101
42
|
end
|
102
43
|
|
103
|
-
def
|
104
|
-
|
105
|
-
notes&.each { |note| @notes << note }
|
44
|
+
def sources
|
45
|
+
data.sources
|
106
46
|
end
|
107
47
|
|
108
|
-
def
|
109
|
-
|
110
|
-
definition&.each { |definition| @definition << definition }
|
48
|
+
def examples
|
49
|
+
data.examples
|
111
50
|
end
|
112
51
|
|
113
|
-
def
|
114
|
-
|
115
|
-
designations&.each { |designation| @designations << designation }
|
52
|
+
def notes
|
53
|
+
data.notes
|
116
54
|
end
|
117
55
|
|
118
|
-
alias :terms= :designations=
|
119
|
-
|
120
56
|
def preferred_designations
|
121
|
-
|
57
|
+
data.terms.select(&:preferred?)
|
122
58
|
end
|
123
|
-
|
124
59
|
alias :preferred_terms :preferred_designations
|
125
60
|
|
126
|
-
def
|
127
|
-
|
128
|
-
dates&.each { |date| @dates << date }
|
129
|
-
end
|
130
|
-
|
131
|
-
def sources=(sources)
|
132
|
-
@sources.clear!
|
133
|
-
sources&.each { |source| @sources << source }
|
61
|
+
def date_accepted
|
62
|
+
data.date_accepted
|
134
63
|
end
|
135
64
|
|
136
65
|
def authoritative_source
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
def authoritative_source=(sources)
|
141
|
-
sources&.each do |source|
|
142
|
-
@sources << source.merge({ "type" => "authoritative" })
|
143
|
-
end
|
66
|
+
data.authoritative_source
|
144
67
|
end
|
145
68
|
|
146
|
-
def
|
147
|
-
|
148
|
-
"type" => "accepted",
|
149
|
-
"date" => date,
|
150
|
-
}
|
151
|
-
|
152
|
-
@dates ||= []
|
153
|
-
@dates << ConceptDate.new(date_hash)
|
69
|
+
def uuid_to_yaml(model, doc)
|
70
|
+
doc["id"] = model.uuid if model.uuid
|
154
71
|
end
|
155
72
|
|
156
|
-
def
|
157
|
-
|
158
|
-
@dates.find { |date| date.accepted? }
|
73
|
+
def uuid_from_yaml(model, value)
|
74
|
+
model.uuid = value
|
159
75
|
end
|
160
76
|
|
161
|
-
def
|
162
|
-
{
|
163
|
-
"data" => {
|
164
|
-
"dates" => dates&.map(&:to_h),
|
165
|
-
"definition" => definition&.map(&:to_h),
|
166
|
-
"examples" => examples&.map(&:to_h),
|
167
|
-
"id" => id,
|
168
|
-
"lineage_source_similarity" => lineage_source_similarity,
|
169
|
-
"notes" => notes&.map(&:to_h),
|
170
|
-
"release" => release,
|
171
|
-
"sources" => sources.empty? ? nil : sources&.map(&:to_h),
|
172
|
-
"terms" => (terms&.map(&:to_h) || []),
|
173
|
-
"related" => related&.map(&:to_h),
|
174
|
-
"domain" => domain,
|
175
|
-
}.compact,
|
176
|
-
|
177
|
-
"date_accepted" => date_accepted&.date,
|
178
|
-
|
179
|
-
}.compact
|
180
|
-
end
|
77
|
+
def id_to_yaml(model, doc); end
|
181
78
|
|
182
|
-
def
|
183
|
-
|
79
|
+
def id_from_yaml(model, value)
|
80
|
+
model.id = value
|
184
81
|
end
|
185
82
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
# rubocop:disable Metrics/AbcSize, Style/RescueModifier
|
191
|
-
def self.from_h(hash)
|
192
|
-
new.tap do |concept|
|
193
|
-
concept.id = hash.dig("termid") || hash.dig("id")
|
194
|
-
concept.sources = hash.dig("sources")
|
195
|
-
concept.related = hash.dig("related")
|
196
|
-
concept.definition = hash.dig("definition")
|
197
|
-
|
198
|
-
hash.values
|
199
|
-
.grep(Hash)
|
200
|
-
.map { |subhash| Config.class_for(:localized_concept).from_h(subhash) rescue nil }
|
201
|
-
.compact
|
202
|
-
|
203
|
-
concept.related = hash.dig("related") || []
|
83
|
+
def date_accepted_to_yaml(model, doc)
|
84
|
+
if model.date_accepted
|
85
|
+
doc["date_accepted"] =
|
86
|
+
model.date_accepted.date.iso8601
|
204
87
|
end
|
205
88
|
end
|
206
|
-
# rubocop:enable Metrics/AbcSize, Style/RescueModifier
|
207
89
|
|
208
|
-
|
209
|
-
|
210
|
-
def related
|
211
|
-
@related.empty? ? nil : @related
|
212
|
-
end
|
90
|
+
def date_accepted_from_yaml(model, value)
|
91
|
+
return if model.date_accepted
|
213
92
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
end
|
218
|
-
|
219
|
-
Glossarist::GlossaryDefinition::CONCEPT_DATE_TYPES.each do |type|
|
220
|
-
# Sets the ConceptDate and add it to dates list of the specified type.
|
221
|
-
define_method("date_#{type}=") do |date|
|
222
|
-
date_hash = {
|
223
|
-
"type" => type,
|
224
|
-
"date" => date,
|
225
|
-
}
|
226
|
-
@dates ||= []
|
227
|
-
@dates << ConceptDate.new(date_hash)
|
228
|
-
end
|
93
|
+
model.data.dates ||= []
|
94
|
+
model.data.dates << ConceptDate.of_yaml({ "date" => value,
|
95
|
+
"type" => "accepted" })
|
229
96
|
end
|
230
97
|
|
231
|
-
def
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
if arg["sources"]
|
238
|
-
arg.delete("authoritative_source")
|
239
|
-
arg.delete("authoritativeSource")
|
240
|
-
end
|
241
|
-
end
|
98
|
+
def uuid
|
99
|
+
@uuid ||= Glossarist::Utilities::UUID.uuid_v5(
|
100
|
+
Glossarist::Utilities::UUID::OID_NAMESPACE,
|
101
|
+
data.to_yaml,
|
102
|
+
)
|
242
103
|
end
|
243
104
|
end
|
244
105
|
end
|