glossarist 2.3.0 → 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 -62
- 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
@@ -21,12 +21,13 @@ module Glossarist
|
|
21
21
|
#
|
22
22
|
# See RFC 4122 for details of UUID at: https://www.ietf.org/rfc/rfc4122.txt
|
23
23
|
def self.uuid_from_hash(hash_class, namespace, name)
|
24
|
-
if
|
24
|
+
if [Digest::MD5, OpenSSL::Digest::MD5].include?(hash_class)
|
25
25
|
version = 3
|
26
|
-
elsif
|
26
|
+
elsif [Digest::SHA1, OpenSSL::Digest::SHA1].include?(hash_class)
|
27
27
|
version = 5
|
28
28
|
else
|
29
|
-
raise ArgumentError,
|
29
|
+
raise ArgumentError,
|
30
|
+
"Expected OpenSSL::Digest::SHA1 or OpenSSL::Digest::MD5, got #{hash_class.name}."
|
30
31
|
end
|
31
32
|
|
32
33
|
uuid_namespace = pack_uuid_namespace(namespace)
|
@@ -58,12 +59,16 @@ module Glossarist
|
|
58
59
|
end
|
59
60
|
|
60
61
|
def self.pack_uuid_namespace(namespace)
|
61
|
-
if [DNS_NAMESPACE, OID_NAMESPACE, URL_NAMESPACE,
|
62
|
+
if [DNS_NAMESPACE, OID_NAMESPACE, URL_NAMESPACE,
|
63
|
+
X500_NAMESPACE].include?(namespace)
|
62
64
|
namespace
|
63
65
|
else
|
64
66
|
match_data = namespace.match(/\A(\h{8})-(\h{4})-(\h{4})-(\h{4})-(\h{4})(\h{8})\z/)
|
65
67
|
|
66
|
-
|
68
|
+
unless match_data.present?
|
69
|
+
raise ArgumentError,
|
70
|
+
"Only UUIDs are valid namespace identifiers"
|
71
|
+
end
|
67
72
|
|
68
73
|
match_data.captures.map { |s| s.to_i(16) }.pack("NnnnnN")
|
69
74
|
end
|
data/lib/glossarist/utilities.rb
CHANGED
data/lib/glossarist/version.rb
CHANGED
data/lib/glossarist.rb
CHANGED
@@ -5,28 +5,29 @@
|
|
5
5
|
|
6
6
|
require "psych"
|
7
7
|
require "thor"
|
8
|
+
require "lutaml/model"
|
8
9
|
|
9
10
|
require_relative "glossarist/utilities"
|
10
11
|
require_relative "glossarist/version"
|
11
12
|
require_relative "glossarist/glossary_definition"
|
12
13
|
|
14
|
+
require_relative "glossarist/designation"
|
13
15
|
require_relative "glossarist/asset"
|
14
|
-
require_relative "glossarist/model"
|
15
|
-
require_relative "glossarist/concept_date"
|
16
|
-
require_relative "glossarist/detailed_definition"
|
17
|
-
require_relative "glossarist/related_concept"
|
18
16
|
require_relative "glossarist/citation"
|
17
|
+
require_relative "glossarist/collection"
|
18
|
+
require_relative "glossarist/concept_date"
|
19
|
+
require_relative "glossarist/concept_manager"
|
19
20
|
require_relative "glossarist/concept_set"
|
20
21
|
require_relative "glossarist/concept_source"
|
21
|
-
require_relative "glossarist/
|
22
|
-
require_relative "glossarist/
|
22
|
+
require_relative "glossarist/detailed_definition"
|
23
|
+
require_relative "glossarist/related_concept"
|
24
|
+
require_relative "glossarist/concept_data"
|
23
25
|
require_relative "glossarist/concept"
|
24
26
|
require_relative "glossarist/localized_concept"
|
25
|
-
require_relative "glossarist/
|
26
|
-
require_relative "glossarist/concept_manager"
|
27
|
+
require_relative "glossarist/managed_concept_data"
|
27
28
|
require_relative "glossarist/managed_concept"
|
29
|
+
require_relative "glossarist/managed_concept_collection"
|
28
30
|
require_relative "glossarist/non_verb_rep"
|
29
|
-
require_relative "glossarist/v1_reader"
|
30
31
|
|
31
32
|
require_relative "glossarist/collections"
|
32
33
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glossarist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lutaml-model
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.5.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: relaton
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,7 +52,7 @@ dependencies:
|
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
|
-
description:
|
55
|
+
description:
|
42
56
|
email:
|
43
57
|
- open.source@ribose.com
|
44
58
|
executables:
|
@@ -53,6 +67,7 @@ files:
|
|
53
67
|
- ".hound.yml"
|
54
68
|
- ".rspec"
|
55
69
|
- ".rubocop.yml"
|
70
|
+
- ".rubocop_todo.yml"
|
56
71
|
- Gemfile
|
57
72
|
- LICENSE.txt
|
58
73
|
- README.adoc
|
@@ -70,6 +85,7 @@ files:
|
|
70
85
|
- lib/glossarist/collections/collection.rb
|
71
86
|
- lib/glossarist/collections/designation_collection.rb
|
72
87
|
- lib/glossarist/concept.rb
|
88
|
+
- lib/glossarist/concept_data.rb
|
73
89
|
- lib/glossarist/concept_date.rb
|
74
90
|
- lib/glossarist/concept_manager.rb
|
75
91
|
- lib/glossarist/concept_set.rb
|
@@ -92,18 +108,12 @@ files:
|
|
92
108
|
- lib/glossarist/localized_concept.rb
|
93
109
|
- lib/glossarist/managed_concept.rb
|
94
110
|
- lib/glossarist/managed_concept_collection.rb
|
95
|
-
- lib/glossarist/
|
111
|
+
- lib/glossarist/managed_concept_data.rb
|
96
112
|
- lib/glossarist/non_verb_rep.rb
|
97
113
|
- lib/glossarist/related_concept.rb
|
98
114
|
- lib/glossarist/utilities.rb
|
99
|
-
- lib/glossarist/utilities/boolean_attributes.rb
|
100
115
|
- lib/glossarist/utilities/common_functions.rb
|
101
|
-
- lib/glossarist/utilities/enum.rb
|
102
|
-
- lib/glossarist/utilities/enum/class_methods.rb
|
103
|
-
- lib/glossarist/utilities/enum/enum_collection.rb
|
104
|
-
- lib/glossarist/utilities/enum/instance_methods.rb
|
105
116
|
- lib/glossarist/utilities/uuid.rb
|
106
|
-
- lib/glossarist/v1_reader.rb
|
107
117
|
- lib/glossarist/version.rb
|
108
118
|
homepage: https://github.com/glossarist/glossarist-ruby
|
109
119
|
licenses:
|
@@ -112,7 +122,7 @@ metadata:
|
|
112
122
|
homepage_uri: https://github.com/glossarist/glossarist-ruby
|
113
123
|
source_code_uri: https://github.com/glossarist/glossarist-ruby
|
114
124
|
bug_tracker_uri: https://github.com/glossarist/glossarist-ruby/issues
|
115
|
-
post_install_message:
|
125
|
+
post_install_message:
|
116
126
|
rdoc_options: []
|
117
127
|
require_paths:
|
118
128
|
- lib
|
@@ -128,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
138
|
version: '0'
|
129
139
|
requirements: []
|
130
140
|
rubygems_version: 3.3.27
|
131
|
-
signing_key:
|
141
|
+
signing_key:
|
132
142
|
specification_version: 4
|
133
143
|
summary: Concept models for terminology glossaries conforming ISO 10241-1.
|
134
144
|
test_files: []
|
data/lib/glossarist/model.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# (c) Copyright 2021 Ribose Inc.
|
4
|
-
#
|
5
|
-
|
6
|
-
module Glossarist
|
7
|
-
class Model
|
8
|
-
def self.new(params = {})
|
9
|
-
return params if params.is_a?(self)
|
10
|
-
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize(attributes = {})
|
15
|
-
attributes.each_pair { |k, v| set_attribute(k, v) }
|
16
|
-
end
|
17
|
-
|
18
|
-
def set_attribute(name, value)
|
19
|
-
public_send("#{name}=", value)
|
20
|
-
rescue NoMethodError
|
21
|
-
if Config.extension_attributes.include?(name)
|
22
|
-
extension_attributes[name] = value
|
23
|
-
elsif name.match?(/[A-Z]/) # adding support for camel case
|
24
|
-
name = snake_case(name.to_s).to_sym
|
25
|
-
retry
|
26
|
-
else
|
27
|
-
raise ArgumentError, "#{self.class.name} does not have " +
|
28
|
-
"attribute #{name} defined or the attribute is read only."
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.from_h(hash)
|
33
|
-
new(hash)
|
34
|
-
end
|
35
|
-
|
36
|
-
def snake_case(str)
|
37
|
-
str.gsub(/([A-Z])/) { "_#{$1.downcase}" }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Glossarist
|
4
|
-
module Utilities
|
5
|
-
module BooleanAttributes
|
6
|
-
def self.included(base)
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.extended(base)
|
11
|
-
base.extend(ClassMethods)
|
12
|
-
end
|
13
|
-
|
14
|
-
module ClassMethods
|
15
|
-
def register_boolean_attributes(attributes)
|
16
|
-
attributes.each do |attribute|
|
17
|
-
register_boolean_attribute(attribute)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def register_boolean_attribute(attribute)
|
22
|
-
attr_reader attribute
|
23
|
-
|
24
|
-
define_method("#{attribute}=") do |value|
|
25
|
-
instance_variable_set("@#{attribute}", !!value)
|
26
|
-
end
|
27
|
-
|
28
|
-
define_method("#{attribute}?") do
|
29
|
-
!!instance_variable_get("@#{attribute}")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "set"
|
4
|
-
|
5
|
-
module Glossarist
|
6
|
-
module Utilities
|
7
|
-
module Enum
|
8
|
-
module ClassMethods
|
9
|
-
def add_inheritable_attribute(attribute)
|
10
|
-
@inheritable_attributes ||= Set[:inheritable_attributes]
|
11
|
-
@inheritable_attributes << attribute
|
12
|
-
end
|
13
|
-
|
14
|
-
def inherited(subclass)
|
15
|
-
@inheritable_attributes.each do |inheritable_attribute|
|
16
|
-
instance_var = "@#{inheritable_attribute}"
|
17
|
-
subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def enums
|
22
|
-
@enums ||= EnumCollection.new
|
23
|
-
end
|
24
|
-
|
25
|
-
def register_enum(name, values, options = {})
|
26
|
-
values = standardize_values(values)
|
27
|
-
|
28
|
-
enums.add(name, values, options)
|
29
|
-
|
30
|
-
add_inheritable_attribute(:enums)
|
31
|
-
register_type_accessor(name)
|
32
|
-
|
33
|
-
values.each do |value|
|
34
|
-
register_check_method(name, value)
|
35
|
-
register_set_method(name, value)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def registered_enums
|
40
|
-
enums.registered_enums
|
41
|
-
end
|
42
|
-
|
43
|
-
def valid_types(name)
|
44
|
-
enums.valid_types(name)
|
45
|
-
end
|
46
|
-
|
47
|
-
def type_options(name)
|
48
|
-
enums.type_options(name)
|
49
|
-
end
|
50
|
-
|
51
|
-
def register_type_reader(name)
|
52
|
-
define_method(name) do
|
53
|
-
if self.class.type_options(name)[:multiple]
|
54
|
-
selected_type[name].map(&:to_s)
|
55
|
-
else
|
56
|
-
selected_type[name].first&.to_s
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def register_type_writer(name)
|
62
|
-
define_method("#{name}=") do |type|
|
63
|
-
select_type(name, type)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# Adds a reader and writer for the type name given.
|
68
|
-
def register_type_accessor(name)
|
69
|
-
register_type_reader(name)
|
70
|
-
register_type_writer(name)
|
71
|
-
end
|
72
|
-
|
73
|
-
def register_check_method(name, value)
|
74
|
-
define_method("#{value}?") do
|
75
|
-
!!selected_type[name]&.include?(value.to_sym)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def register_set_method(name, value)
|
80
|
-
define_method("#{value}=") do |input|
|
81
|
-
if input
|
82
|
-
select_type(name, value)
|
83
|
-
else
|
84
|
-
deselect_type(name, value)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def standardize_values(values)
|
90
|
-
if values.is_a?(Array)
|
91
|
-
values.map(&:to_sym)
|
92
|
-
else
|
93
|
-
[values.to_sym]
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Glossarist
|
4
|
-
module Utilities
|
5
|
-
module Enum
|
6
|
-
class EnumCollection
|
7
|
-
include Enumerable
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@collection = {}
|
11
|
-
end
|
12
|
-
|
13
|
-
def add(name, values, options = {})
|
14
|
-
@collection[name] = { registered_values: values, options: options }
|
15
|
-
end
|
16
|
-
|
17
|
-
def each(&block)
|
18
|
-
if block_given?
|
19
|
-
@collection.each do |object|
|
20
|
-
block.call(object)
|
21
|
-
end
|
22
|
-
else
|
23
|
-
enum_for(:each)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def registered_enums
|
28
|
-
@collection&.keys || []
|
29
|
-
end
|
30
|
-
|
31
|
-
def valid_types(name)
|
32
|
-
@collection[name][:registered_values]
|
33
|
-
end
|
34
|
-
|
35
|
-
def type_options(name)
|
36
|
-
@collection[name][:options]
|
37
|
-
end
|
38
|
-
|
39
|
-
def [](name)
|
40
|
-
@collection[name]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Glossarist
|
4
|
-
module Utilities
|
5
|
-
module Enum
|
6
|
-
module InstanceMethods
|
7
|
-
def selected_type
|
8
|
-
initialize_selected_type if @selected_type.nil?
|
9
|
-
|
10
|
-
@selected_type
|
11
|
-
end
|
12
|
-
|
13
|
-
def select_type(type_name, values)
|
14
|
-
values = if values.is_a?(Array)
|
15
|
-
values
|
16
|
-
else
|
17
|
-
[values]
|
18
|
-
end
|
19
|
-
|
20
|
-
values.each do |value|
|
21
|
-
select_type_value(type_name, value)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def deselect_type(type_name, value)
|
26
|
-
selected_type[type_name].delete(value)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def select_type_value(type_name, value)
|
32
|
-
if !value
|
33
|
-
selected_type[type_name].clear
|
34
|
-
elsif self.class.valid_types(type_name).include?(value.to_sym)
|
35
|
-
selected_type[type_name].clear unless self.class.type_options(type_name)[:multiple]
|
36
|
-
selected_type[type_name] << value.to_sym
|
37
|
-
else
|
38
|
-
raise(
|
39
|
-
Glossarist::InvalidTypeError,
|
40
|
-
"`#{value}` is not a valid #{type_name}. Supported #{type_name} are #{self.class.enums[type_name][:registered_values].to_a.join(", ")}"
|
41
|
-
)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def initialize_selected_type
|
46
|
-
@selected_type = {}
|
47
|
-
|
48
|
-
self.class.registered_enums.each do |type|
|
49
|
-
@selected_type[type] = []
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "enum/enum_collection"
|
4
|
-
require_relative "enum/class_methods"
|
5
|
-
require_relative "enum/instance_methods"
|
6
|
-
|
7
|
-
module Glossarist
|
8
|
-
module Utilities
|
9
|
-
module Enum
|
10
|
-
def self.included(base)
|
11
|
-
base.include(InstanceMethods)
|
12
|
-
base.extend(ClassMethods)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.extended(base)
|
16
|
-
base.include(InstanceMethods)
|
17
|
-
base.extend(ClassMethods)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/glossarist/v1_reader.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Glossarist
|
4
|
-
# An adapter to read concepts in V1 format, converts them to v2 format and
|
5
|
-
# load into glossarist concept model.
|
6
|
-
class V1Reader
|
7
|
-
def self.load_concept_from_file(filename)
|
8
|
-
new.load_concept_from_file(filename)
|
9
|
-
end
|
10
|
-
|
11
|
-
def load_concept_from_file(filename)
|
12
|
-
concept_hash = Psych.safe_load(File.read(filename), permitted_classes: [Date, Time])
|
13
|
-
Config.class_for(:managed_concept).new(generate_v2_concept_hash(concept_hash))
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def generate_v2_concept_hash(concept_hash)
|
19
|
-
v2_concept = { "groups" => concept_hash["groups"] }
|
20
|
-
v2_concept["data"] = {
|
21
|
-
"identifier" => concept_hash["termid"],
|
22
|
-
"localized_concepts" => concept_hash.values.grep(Hash),
|
23
|
-
}
|
24
|
-
|
25
|
-
v2_concept
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|