glossarist 2.3.0 → 2.3.2
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 +4 -4
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +65 -0
- data/README.adoc +2 -2
- data/config.yml +1 -1
- data/exe/glossarist +5 -3
- 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 +66 -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 +27 -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 -62
- data/lib/glossarist/managed_concept.rb +73 -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
@@ -1,35 +1,36 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
module Glossarist
|
4
2
|
module Designation
|
5
|
-
class Base < Model
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
class Base < Lutaml::Model::Serializable
|
4
|
+
attribute :designation, :string
|
5
|
+
attribute :geographical_area, :string
|
6
|
+
attribute :normative_status, :string,
|
7
|
+
values: Glossarist::GlossaryDefinition::DESIGNATION_BASE_NORMATIVE_STATUSES
|
8
|
+
attribute :type, :string
|
11
9
|
|
12
|
-
|
13
|
-
|
10
|
+
yaml do
|
11
|
+
map :type, to: :type
|
12
|
+
map %i[normative_status normativeStatus], to: :normative_status
|
13
|
+
map %i[geographical_area geographicalArea], to: :geographical_area
|
14
|
+
map :designation, to: :designation
|
15
|
+
end
|
14
16
|
|
15
|
-
def self.
|
17
|
+
def self.of_yaml(hash, options = {})
|
16
18
|
type = hash["type"]
|
17
19
|
|
18
20
|
if type.nil? || /\w/ !~ type
|
19
21
|
raise ArgumentError, "designation type is missing"
|
20
22
|
end
|
21
23
|
|
22
|
-
designation_subclass = SERIALIZED_TYPES[type]
|
23
|
-
|
24
24
|
if self == Base
|
25
25
|
# called on Base class, delegate it to proper subclass
|
26
|
-
SERIALIZED_TYPES[type].
|
26
|
+
SERIALIZED_TYPES[type].of_yaml(hash)
|
27
27
|
else
|
28
28
|
# called on subclass, instantiate object
|
29
29
|
unless SERIALIZED_TYPES[self] == type
|
30
30
|
raise ArgumentError, "unexpected designation type: #{type}"
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
|
+
super(hash, options)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
@@ -1,24 +1,26 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require_relative "base"
|
2
|
+
require_relative "grammar_info"
|
4
3
|
|
5
4
|
module Glossarist
|
6
5
|
module Designation
|
7
6
|
class Expression < Base
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
attribute :prefix, :string
|
8
|
+
attribute :usage_info, :string
|
9
|
+
|
10
|
+
attribute :gender, :string
|
11
|
+
attribute :plurality, :string
|
12
|
+
attribute :part_of_speech, :string
|
13
|
+
attribute :grammar_info, GrammarInfo, collection: true
|
14
|
+
attribute :type, :string, default: -> { "expression" }
|
15
|
+
|
16
|
+
yaml do
|
17
|
+
map :type, to: :type, render_default: true
|
18
|
+
map :prefix, to: :prefix
|
19
|
+
map %i[usage_info usageInfo], to: :usage_info
|
20
|
+
map %i[grammar_info grammarInfo], to: :grammar_info
|
17
21
|
end
|
18
22
|
|
19
|
-
|
20
|
-
# might be removed in the future.
|
21
|
-
def self.from_h(hash)
|
23
|
+
def self.of_yaml(hash, options = {})
|
22
24
|
gender = hash.delete("gender") || hash.delete(:gender)
|
23
25
|
number = hash.delete("plurality") || hash.delete(:plurality)
|
24
26
|
part_of_speech = hash.delete("part_of_speech") || hash.delete(:part_of_speech)
|
@@ -31,19 +33,9 @@ module Glossarist
|
|
31
33
|
}.compact]
|
32
34
|
end
|
33
35
|
|
34
|
-
|
35
|
-
end
|
36
|
+
hash["type"] = "expression" unless hash["type"]
|
36
37
|
|
37
|
-
|
38
|
-
{
|
39
|
-
"type" => "expression",
|
40
|
-
"prefix" => prefix,
|
41
|
-
"normative_status" => normative_status,
|
42
|
-
"usage_info" => usage_info,
|
43
|
-
"designation" => designation,
|
44
|
-
"geographical_area" => geographical_area,
|
45
|
-
"grammar_info" => grammar_info&.map(&:to_h),
|
46
|
-
}.compact
|
38
|
+
super(hash, options)
|
47
39
|
end
|
48
40
|
end
|
49
41
|
end
|
@@ -1,57 +1,39 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "../utilities"
|
4
|
-
|
5
1
|
module Glossarist
|
6
2
|
module Designation
|
7
|
-
class GrammarInfo
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
3
|
+
class GrammarInfo < Lutaml::Model::Serializable
|
4
|
+
attribute :gender, :string,
|
5
|
+
values: Glossarist::GlossaryDefinition::GRAMMAR_INFO_GENDERS, collection: true
|
6
|
+
attribute :number, :string,
|
7
|
+
values: Glossarist::GlossaryDefinition::GRAMMAR_INFO_NUMBERS, collection: true
|
8
|
+
attribute :part_of_speech, :string,
|
9
|
+
values: Glossarist::GlossaryDefinition::GRAMMAR_INFO_BOOLEAN_ATTRIBUTES
|
10
|
+
|
11
|
+
yaml do
|
12
|
+
map :gender, to: :gender
|
13
|
+
map :number, to: :number
|
14
|
+
|
15
|
+
map %i[part_of_speech partOfSpeech], with: { to: :part_of_speech_to_yaml, from: :part_of_speech_from_yaml }
|
16
|
+
Glossarist::GlossaryDefinition::GRAMMAR_INFO_BOOLEAN_ATTRIBUTES.each do |bool_attr|
|
17
|
+
map bool_attr,
|
18
|
+
with: { to: :"part_of_speech_#{bool_attr}_to_yaml",
|
19
|
+
from: :"part_of_speech_#{bool_attr}_from_yaml" }
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def part_of_speech_from_yaml(model, value)
|
24
|
+
model.part_of_speech = value
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
{
|
29
|
-
"preposition" => preposition?,
|
30
|
-
"participle" => participle?,
|
31
|
-
"adj" => adj?,
|
32
|
-
"verb" => verb?,
|
33
|
-
"adverb" => adverb?,
|
34
|
-
"noun" => noun?,
|
35
|
-
"gender" => gender,
|
36
|
-
"number" => number,
|
37
|
-
}
|
38
|
-
end
|
27
|
+
def part_of_speech_to_yaml(model, doc); end
|
39
28
|
|
40
|
-
|
29
|
+
Glossarist::GlossaryDefinition::GRAMMAR_INFO_BOOLEAN_ATTRIBUTES.each do |bool_attr|
|
30
|
+
define_method(:"part_of_speech_#{bool_attr}_from_yaml") do |model, value|
|
31
|
+
model.public_send("#{bool_attr}=", value)
|
32
|
+
end
|
41
33
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
:gender,
|
46
|
-
:number,
|
47
|
-
:preposition,
|
48
|
-
:participle,
|
49
|
-
:adj,
|
50
|
-
:verb,
|
51
|
-
:adverb,
|
52
|
-
:noun,
|
53
|
-
:part_of_speech,
|
54
|
-
])
|
34
|
+
define_method(:"part_of_speech_#{bool_attr}_to_yaml") do |model, doc|
|
35
|
+
doc[bool_attr] = model.public_send("#{bool_attr}?")
|
36
|
+
end
|
55
37
|
end
|
56
38
|
end
|
57
39
|
end
|
@@ -1,16 +1,20 @@
|
|
1
|
-
|
1
|
+
require_relative "symbol"
|
2
2
|
|
3
3
|
module Glossarist
|
4
4
|
module Designation
|
5
5
|
class GraphicalSymbol < Symbol
|
6
|
-
|
7
|
-
|
6
|
+
attribute :text, :string
|
7
|
+
attribute :image, :string
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
yaml do
|
10
|
+
map :text, to: :text
|
11
|
+
map :image, to: :image
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.of_yaml(hash, options = {})
|
15
|
+
hash["type"] = "graphical_symbol"
|
16
|
+
|
17
|
+
super
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
@@ -1,18 +1,20 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
module Glossarist
|
4
2
|
module Designation
|
5
3
|
class LetterSymbol < Symbol
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
attribute :text, :string
|
5
|
+
attribute :language, :string
|
6
|
+
attribute :script, :string
|
7
|
+
|
8
|
+
yaml do
|
9
|
+
map :text, to: :text
|
10
|
+
map :language, to: :language
|
11
|
+
map :script, to: :script
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.of_yaml(hash, options = {})
|
15
|
+
hash["type"] = "letter_symbol"
|
9
16
|
|
10
|
-
|
11
|
-
super.merge(
|
12
|
-
"text" => text,
|
13
|
-
"language" => language,
|
14
|
-
"script" => script,
|
15
|
-
)
|
17
|
+
super
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -1,20 +1,18 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "base"
|
4
|
-
|
5
1
|
module Glossarist
|
6
2
|
module Designation
|
7
3
|
class Symbol < Base
|
8
|
-
|
4
|
+
attribute :international, :boolean
|
5
|
+
attribute :type, :string
|
6
|
+
|
7
|
+
yaml do
|
8
|
+
map :international, to: :international
|
9
|
+
map :type, to: :type, render_default: true
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.of_yaml(hash, options = {})
|
13
|
+
hash["type"] = "symbol" unless hash["type"]
|
9
14
|
|
10
|
-
|
11
|
-
{
|
12
|
-
"type" => Glossarist::Designation::SERIALIZED_TYPES[self.class],
|
13
|
-
"normative_status" => normative_status,
|
14
|
-
"geographical_area" => geographical_area,
|
15
|
-
"designation" => designation,
|
16
|
-
"international" => international,
|
17
|
-
}.compact
|
15
|
+
super
|
18
16
|
end
|
19
17
|
end
|
20
18
|
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# (c) Copyright 2021 Ribose Inc.
|
4
4
|
#
|
5
5
|
|
6
|
-
require_relative "designation/abbreviation"
|
7
6
|
require_relative "designation/base"
|
8
7
|
require_relative "designation/expression"
|
8
|
+
require_relative "designation/abbreviation"
|
9
9
|
require_relative "designation/grammar_info"
|
10
10
|
require_relative "designation/symbol"
|
11
11
|
require_relative "designation/graphical_symbol"
|
@@ -21,7 +21,7 @@ module Glossarist
|
|
21
21
|
GraphicalSymbol => "graphical_symbol",
|
22
22
|
LetterSymbol => "letter_symbol",
|
23
23
|
}
|
24
|
-
|
25
|
-
|
24
|
+
.tap { |h| h.merge!(h.invert) }
|
25
|
+
.freeze
|
26
26
|
end
|
27
27
|
end
|
@@ -1,31 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Glossarist
|
4
|
-
class DetailedDefinition < Model
|
4
|
+
class DetailedDefinition < Lutaml::Model::Serializable
|
5
|
+
attribute :content, :string
|
6
|
+
attribute :sources, ConceptSource, collection: true
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
else
|
10
|
-
self.content = attributes
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [String]
|
15
|
-
attr_accessor :content
|
16
|
-
|
17
|
-
# @return [Array<ConceptSource>]
|
18
|
-
attr_reader :sources
|
19
|
-
|
20
|
-
def sources=(sources)
|
21
|
-
@sources = sources.map { |s| ConceptSource.new(s) }
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_h
|
25
|
-
{
|
26
|
-
"content" => content,
|
27
|
-
"sources" => sources&.map(&:to_h),
|
28
|
-
}.compact
|
8
|
+
yaml do
|
9
|
+
map :content, to: :content
|
10
|
+
map :sources, to: :sources
|
29
11
|
end
|
30
12
|
end
|
31
13
|
end
|
data/lib/glossarist/error.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require_relative "error/invalid_type_error"
|
2
|
-
require_relative "error/invalid_language_code_error"
|
3
|
-
require_relative "error/parse_error"
|
4
|
-
|
5
1
|
module Glossarist
|
6
2
|
class Error < StandardError
|
7
3
|
end
|
8
4
|
end
|
5
|
+
|
6
|
+
require_relative "error/invalid_type_error"
|
7
|
+
require_relative "error/invalid_language_code_error"
|
8
|
+
require_relative "error/parse_error"
|
@@ -4,7 +4,8 @@ require "yaml"
|
|
4
4
|
|
5
5
|
module Glossarist
|
6
6
|
module GlossaryDefinition
|
7
|
-
config = YAML.load_file(File.expand_path("
|
7
|
+
config = YAML.load_file(File.expand_path("../../config.yml",
|
8
|
+
__dir__)) || {}
|
8
9
|
|
9
10
|
CONCEPT_SOURCE_STATUSES = config.dig("concept_source", "status").freeze
|
10
11
|
|
@@ -14,13 +15,15 @@ module Glossarist
|
|
14
15
|
|
15
16
|
ABBREVIATION_TYPES = config.dig("abbreviation", "type").freeze
|
16
17
|
|
17
|
-
GRAMMAR_INFO_BOOLEAN_ATTRIBUTES = config.dig("grammar_info",
|
18
|
+
GRAMMAR_INFO_BOOLEAN_ATTRIBUTES = config.dig("grammar_info",
|
19
|
+
"boolean_attribute").freeze
|
18
20
|
|
19
21
|
GRAMMAR_INFO_GENDERS = config.dig("grammar_info", "gender").freeze
|
20
22
|
|
21
23
|
GRAMMAR_INFO_NUMBERS = config.dig("grammar_info", "number").freeze
|
22
24
|
|
23
|
-
DESIGNATION_BASE_NORMATIVE_STATUSES = config.dig("designation", "base",
|
25
|
+
DESIGNATION_BASE_NORMATIVE_STATUSES = config.dig("designation", "base",
|
26
|
+
"normative_status").freeze
|
24
27
|
|
25
28
|
CONCEPT_DATE_TYPES = config.dig("concept_date", "type").freeze
|
26
29
|
|
@@ -1,75 +1,30 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# (c) Copyright 2021 Ribose Inc.
|
4
|
-
#
|
5
|
-
|
6
1
|
module Glossarist
|
7
2
|
class LocalizedConcept < Concept
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
attr_reader :language_code
|
12
|
-
|
13
|
-
# Must be one of the following:
|
14
|
-
# +notValid+, +valid+, +superseded+, +retired+.
|
15
|
-
# @todo Proper type checking.
|
16
|
-
# @note Works with strings, but soon they may be replaced with symbols.
|
17
|
-
# @return [String]
|
18
|
-
attr_accessor :entry_status
|
19
|
-
alias_method :status=, :entry_status=
|
20
|
-
|
21
|
-
# Must be one of the following:
|
22
|
-
# +preferred+, +admitted+, +deprecated+.
|
23
|
-
# @todo Proper type checking.
|
24
|
-
# @note Works with strings, but soon they may be replaced with symbols.
|
25
|
-
# @return [String]
|
26
|
-
attr_accessor :classification
|
27
|
-
|
28
|
-
# Temporary fields
|
29
|
-
# @todo Need to remove these once the isotc211-glossary is fixed
|
30
|
-
attr_accessor *%i[
|
31
|
-
review_date
|
32
|
-
review_decision_date
|
33
|
-
review_decision_event
|
34
|
-
review_type
|
35
|
-
]
|
3
|
+
attribute :classification, :string
|
4
|
+
attribute :review_type, :string
|
5
|
+
attribute :entry_status, :string
|
36
6
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
else
|
41
|
-
raise Glossarist::InvalidLanguageCodeError.new(code: language_code)
|
42
|
-
end
|
7
|
+
yaml do
|
8
|
+
map :classification, to: :classification
|
9
|
+
map %i[review_type reviewType], to: :review_type
|
43
10
|
end
|
44
11
|
|
45
|
-
|
46
|
-
hash = super
|
47
|
-
|
48
|
-
hash["data"].merge!({
|
49
|
-
"language_code" => language_code,
|
50
|
-
"entry_status" => entry_status,
|
51
|
-
"sources" => sources.empty? ? nil : sources&.map(&:to_h),
|
52
|
-
"classification" => classification,
|
53
|
-
"dates" => dates&.map(&:to_h),
|
54
|
-
"review_date" => review_date,
|
55
|
-
"review_decision_date" => review_decision_date,
|
56
|
-
"review_decision_event" => review_decision_event,
|
57
|
-
}.compact).merge!(@extension_attributes)
|
58
|
-
|
59
|
-
hash["status"] = entry_status if entry_status
|
12
|
+
alias_method :status=, :entry_status=
|
60
13
|
|
61
|
-
|
14
|
+
def language_code
|
15
|
+
data.language_code
|
62
16
|
end
|
63
17
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
18
|
+
def entry_status
|
19
|
+
data.entry_status
|
20
|
+
end
|
67
21
|
|
68
|
-
|
22
|
+
def language_code=(value)
|
23
|
+
data.language_code = value
|
69
24
|
end
|
70
25
|
|
71
|
-
|
72
|
-
|
73
|
-
|
26
|
+
def entry_status=(value)
|
27
|
+
data.entry_status = value
|
28
|
+
end
|
74
29
|
end
|
75
30
|
end
|