glossarist 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/glossarist.gemspec +1 -1
- data/lib/glossarist/concept_manager.rb +22 -7
- data/lib/glossarist/v1_reader.rb +28 -0
- data/lib/glossarist/version.rb +1 -1
- data/lib/glossarist.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0462402c995f5b7e9fb01a4ee0d8e1f9ee3c5633c18fa071d9db6aa9f21f99f
|
4
|
+
data.tar.gz: 444e2d92467c4101edc81bc1af65fb6aeecaa0e138f63a49076f2283802baf17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab7f0f87234df6fcd73286969c53e1186fcd247b4d8972a8d305b74cc995a4200785db43215a0d5aae719bc164123035f87a1756c104aa3d36b38775585f2019
|
7
|
+
data.tar.gz: d5f4a8834eb1d8bbb19d8352c13159e4626c8ff65233b5269658b77c4ee753bbcd8dcaf4502981b1ae2556a13e8af8deb45661e86f485cf7df25cf0f9d1cbb57
|
data/glossarist.gemspec
CHANGED
@@ -30,7 +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 "relaton", "~> 1.16
|
33
|
+
spec.add_dependency "relaton", "~> 1.16"
|
34
34
|
spec.add_dependency "thor"
|
35
35
|
|
36
36
|
spec.add_development_dependency "pry", "~> 0.14.0"
|
@@ -17,11 +17,11 @@ module Glossarist
|
|
17
17
|
collection ||= ManagedConceptCollection.new
|
18
18
|
|
19
19
|
Dir.glob(concepts_glob) do |filename|
|
20
|
-
concept =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
concept = if v1_collection?
|
21
|
+
Glossarist::V1Reader.load_concept_from_file(filename)
|
22
|
+
else
|
23
|
+
load_concept_from_file(filename)
|
24
|
+
end
|
25
25
|
|
26
26
|
collection.store(concept)
|
27
27
|
end
|
@@ -35,7 +35,14 @@ module Glossarist
|
|
35
35
|
def load_concept_from_file(filename)
|
36
36
|
concept_hash = Psych.safe_load(File.read(filename), permitted_classes: [Date])
|
37
37
|
concept_hash["uuid"] = concept_hash["id"] || File.basename(filename, ".*")
|
38
|
-
|
38
|
+
|
39
|
+
concept = ManagedConcept.new(concept_hash)
|
40
|
+
concept.localized_concepts.each do |_lang, id|
|
41
|
+
localized_concept = load_localized_concept(id)
|
42
|
+
concept.add_l10n(localized_concept)
|
43
|
+
end
|
44
|
+
|
45
|
+
concept
|
39
46
|
rescue Psych::SyntaxError => e
|
40
47
|
raise Glossarist::ParseError.new(filename: filename, line: e.line)
|
41
48
|
end
|
@@ -71,11 +78,19 @@ module Glossarist
|
|
71
78
|
private
|
72
79
|
|
73
80
|
def concepts_glob
|
74
|
-
|
81
|
+
if v1_collection?
|
82
|
+
File.join(path, "concept-*.{yaml,yml}")
|
83
|
+
else
|
84
|
+
File.join(path, "concept", "*.{yaml,yml}")
|
85
|
+
end
|
75
86
|
end
|
76
87
|
|
77
88
|
def localized_concept_path(id)
|
78
89
|
Dir.glob(File.join(path, "localized_concept", "#{id}.{yaml,yml}"))&.first
|
79
90
|
end
|
91
|
+
|
92
|
+
def v1_collection?
|
93
|
+
@v1_collection ||= !Dir.glob(File.join(path, "concept-*.{yaml,yml}")).empty?
|
94
|
+
end
|
80
95
|
end
|
81
96
|
end
|
@@ -0,0 +1,28 @@
|
|
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])
|
13
|
+
ManagedConcept.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
|
data/lib/glossarist/version.rb
CHANGED
data/lib/glossarist.rb
CHANGED
@@ -26,6 +26,7 @@ require_relative "glossarist/managed_concept_collection"
|
|
26
26
|
require_relative "glossarist/concept_manager"
|
27
27
|
require_relative "glossarist/managed_concept"
|
28
28
|
require_relative "glossarist/non_verb_rep"
|
29
|
+
require_relative "glossarist/v1_reader"
|
29
30
|
|
30
31
|
require_relative "glossarist/collections"
|
31
32
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glossarist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: relaton
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.16
|
19
|
+
version: '1.16'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.16
|
26
|
+
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- lib/glossarist/utilities/enum/enum_collection.rb
|
146
146
|
- lib/glossarist/utilities/enum/instance_methods.rb
|
147
147
|
- lib/glossarist/utilities/uuid.rb
|
148
|
+
- lib/glossarist/v1_reader.rb
|
148
149
|
- lib/glossarist/version.rb
|
149
150
|
homepage: https://github.com/glossarist/glossarist-ruby
|
150
151
|
licenses:
|