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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.rubocop_todo.yml +65 -0
  4. data/README.adoc +2 -2
  5. data/config.yml +1 -1
  6. data/exe/glossarist +5 -3
  7. data/glossarist.gemspec +1 -0
  8. data/lib/glossarist/asset.rb +4 -9
  9. data/lib/glossarist/citation.rb +73 -41
  10. data/lib/glossarist/collection.rb +2 -11
  11. data/lib/glossarist/collections/asset_collection.rb +0 -3
  12. data/lib/glossarist/collections/bibliography_collection.rb +1 -1
  13. data/lib/glossarist/concept.rb +66 -206
  14. data/lib/glossarist/concept_data.rb +66 -0
  15. data/lib/glossarist/concept_date.rb +7 -11
  16. data/lib/glossarist/concept_manager.rb +19 -29
  17. data/lib/glossarist/concept_set.rb +6 -4
  18. data/lib/glossarist/concept_source.rb +15 -58
  19. data/lib/glossarist/config.rb +4 -4
  20. data/lib/glossarist/designation/abbreviation.rb +15 -16
  21. data/lib/glossarist/designation/base.rb +16 -15
  22. data/lib/glossarist/designation/expression.rb +18 -26
  23. data/lib/glossarist/designation/grammar_info.rb +27 -45
  24. data/lib/glossarist/designation/graphical_symbol.rb +12 -8
  25. data/lib/glossarist/designation/letter_symbol.rb +13 -11
  26. data/lib/glossarist/designation/symbol.rb +11 -13
  27. data/lib/glossarist/designation.rb +3 -3
  28. data/lib/glossarist/detailed_definition.rb +6 -24
  29. data/lib/glossarist/error.rb +4 -4
  30. data/lib/glossarist/glossary_definition.rb +6 -3
  31. data/lib/glossarist/localized_concept.rb +17 -62
  32. data/lib/glossarist/managed_concept.rb +73 -146
  33. data/lib/glossarist/managed_concept_collection.rb +15 -24
  34. data/lib/glossarist/managed_concept_data.rb +47 -0
  35. data/lib/glossarist/non_verb_rep.rb +10 -13
  36. data/lib/glossarist/related_concept.rb +14 -21
  37. data/lib/glossarist/utilities/uuid.rb +10 -5
  38. data/lib/glossarist/utilities.rb +0 -2
  39. data/lib/glossarist/version.rb +1 -1
  40. data/lib/glossarist.rb +10 -9
  41. metadata +23 -13
  42. data/lib/glossarist/model.rb +0 -40
  43. data/lib/glossarist/utilities/boolean_attributes.rb +0 -35
  44. data/lib/glossarist/utilities/enum/class_methods.rb +0 -99
  45. data/lib/glossarist/utilities/enum/enum_collection.rb +0 -45
  46. data/lib/glossarist/utilities/enum/instance_methods.rb +0 -55
  47. data/lib/glossarist/utilities/enum.rb +0 -21
  48. data/lib/glossarist/v1_reader.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe8b9555663cedc2258a960b19a10f9d6fc4575faf70006e1223c69f95678451
4
- data.tar.gz: fbdd27366d93b637882ad7dd3b77bfbaca9ae68c489403d7595fbe39af901e68
3
+ metadata.gz: 0667bd53eab8d4a86ef3376ddb095b7dafe5ce903b5df39683f279ef51c01a7e
4
+ data.tar.gz: 66a281d1f6132de430a6c24706eeb564c98c10f97cfac4751811c33dae2fdcc6
5
5
  SHA512:
6
- metadata.gz: 2e7030a8e328ee775641e8c4637b458c6746b872d597235bad00977c78a97d56f21ed48bbb9ef11ab0209ba74a93f7aeac19121bca32bd8c71aecdf67601223b
7
- data.tar.gz: 1a5ddbc5c71542eb7f258d17c601cd08b54041053ddfb1089a5f6e7eca28dfb360fe2b1c21da4bfa9d8474c333ce37376aeccbf75fc609dd2cea3e2e28c1acd2
6
+ metadata.gz: 2eb5758d7c7528f8cf8759924e9b2e6e5872ea58ef4c63b86365265f884f99ac4899caf62003bd01b2cb9ff8f32d914775df95820f21907c8f5cb80c306009a4
7
+ data.tar.gz: 43b9635c121ca5e910611a46109a3353c2290ef8e901bec2b1a55e37e03d707e28cfb927ed6a20c9e6e85df9bc708801552bab821d20f63dff71bce832055e14
data/.rubocop.yml CHANGED
@@ -2,6 +2,7 @@
2
2
  # See https://github.com/metanorma/cimas
3
3
  inherit_from:
4
4
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
5
+ - .rubocop_todo.yml
5
6
 
6
7
  # local repo-specific modifications
7
8
  # ...
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.000Z",
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.000Z"
224
+ concept_date.date = "2010-11-01T00:00:00+00:00"
225
225
  ----
226
226
 
227
227
  [[id,detailed-definition]]
data/config.yml CHANGED
@@ -52,12 +52,12 @@ abbreviation:
52
52
 
53
53
  grammar_info:
54
54
  boolean_attribute:
55
- - preposition
56
55
  - participle
57
56
  - adj
58
57
  - verb
59
58
  - adverb
60
59
  - noun
60
+ - preposition
61
61
  gender:
62
62
  - m
63
63
  - f
data/exe/glossarist CHANGED
@@ -21,12 +21,14 @@ class GlossaristCommand < Thor
21
21
 
22
22
  concept_set = Glossarist::ConceptSet.new(options[:concepts_path], assets)
23
23
  latex_str = concept_set.to_latex(latex_concepts_file)
24
+ output_latex(latex_str)
25
+ end
24
26
 
27
+ def output_latex(latex_str)
25
28
  output_file_path = options[:output_file]
29
+
26
30
  if output_file_path
27
- File.open(output_file_path, "w") do |file|
28
- file.puts latex_str
29
- end
31
+ File.open(output_file_path, "w") { |file| file.puts latex_str }
30
32
  else
31
33
  puts latex_str
32
34
  end
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.6"
33
34
  spec.add_dependency "relaton", "~> 1.19"
34
35
  spec.add_dependency "thor"
35
36
  end
@@ -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
- attr_accessor :path
2
+ class Asset < Lutaml::Model::Serializable
3
+ attribute :path, :string
9
4
 
10
- def initialize(path)
11
- @path = path
5
+ yaml do
6
+ map :path, to: :path
12
7
  end
13
8
 
14
9
  def eql?(asset)
@@ -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
- attr_accessor :text
5
+ attribute :text, :string
11
6
 
12
7
  # Source in structured reference.
13
8
  # @return [String]
14
- attr_accessor :source
9
+ attribute :source, :string
15
10
 
16
11
  # Document ID in structured reference.
17
12
  # @return [String]
18
- attr_accessor :id
13
+ attribute :id, :string
19
14
 
20
15
  # Document version in structured reference.
21
16
  # @return [String]
22
- attr_accessor :version
17
+ attribute :version, :string
23
18
 
24
19
  # @return [String]
25
20
  # Referred clause of the document.
26
- attr_accessor :clause
21
+ attribute :clause, :string
27
22
 
28
23
  # Link to document.
29
24
  # @return [String]
30
- attr_accessor :link
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
- attr_accessor :original
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
- # Whether it is a plain text ref.
39
- # @return [Boolean]
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
- # Whether it is a structured ref.
45
- # @return [Boolean]
46
- def structured?
47
- !plain?
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 to_h
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 self.from_h(hash)
60
- hash = hash.dup
65
+ def id_to_yaml(_model, _doc)
66
+ # skip, will be handled in ref
67
+ end
61
68
 
62
- ref_val = hash.delete("ref")
63
- hash.merge!(Hash === ref_val ? ref_val : {"text" => ref_val})
64
- hash.compact!
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
- super(hash)
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
- private
111
+ def plain?
112
+ (source && id && version).nil?
113
+ end
80
114
 
81
- def ref_to_h
82
- if structured?
83
- { "source" => source, "id" => id, "version" => version }.compact
84
- else
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.new(id: id))
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.from_h(Psych.safe_load(File.read(filename)))
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
@@ -3,9 +3,6 @@
3
3
  module Glossarist
4
4
  module Collections
5
5
  class AssetCollection < Set
6
- def initialize(assets)
7
- super
8
- end
9
6
  end
10
7
  end
11
8
  end
@@ -5,7 +5,7 @@ require "relaton"
5
5
  module Glossarist
6
6
  module Collections
7
7
  class BibliographyCollection < Relaton::Db
8
- def initialize(concepts, global_cache, local_cache)
8
+ def initialize(_concepts, global_cache, local_cache)
9
9
  super(global_cache, local_cache)
10
10
  end
11
11