termium 0.3.5 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73a3c06b705e25be2bedd458d60bfd5ef7c5aedd81406f824cd091e0bd9fd35a
4
- data.tar.gz: 9d4e44fc204cad977895157c2f1cfe5965896ce2b0d60342966dfd19547639d4
3
+ metadata.gz: 8b3fe1c60b2aeb9208c7b090abacba70c8eb152964a583d48f85aaee34dcca35
4
+ data.tar.gz: ff073afb1ca7b6a82b838015342fde5c66944a64f5f6d253a273fac22826a362
5
5
  SHA512:
6
- metadata.gz: 249b057bf3abcd61bdb5c38f2789a0365f40a6ea0e91226fa0d19534c969a31795d0cf4a9c538d6a2fe01b0a48f1e4b6daf7bcb353de8bae665f51413f8f376c
7
- data.tar.gz: 9daa82e29b0fdee1a0b0a5500d77b3e3920c8ef3a86631cbda0fb2ca972c52ee2504b5a80ec13ea57b7a19699f409dc4c38bc08c7be047d1c82a147c901c44b2
6
+ metadata.gz: 8d674955f7dbe077c9ea7c8804e9c60cef8cf59a46091810c7dece5e74302e732345c4419e34afa58061420232ee4136e26309fdb3f6ed0e2239bee7b4216a65
7
+ data.tar.gz: 210e8872e94578af94f3b5a66d7c398ed4485a3d89002baf797abf4bf84d095502b56e2d9d5695dfef26ee53f689c1fa699c8c87499aa63e46c984875f999d30
@@ -2,6 +2,16 @@
2
2
  # See https://github.com/metanorma/cimas
3
3
  name: release
4
4
 
5
+ # packages: write matches the ceiling the called chain declares
6
+ # (relaton/support release.yml, metanorma/ci rubygems-release.yml);
7
+ # a reusable workflow cannot exceed the caller's grant, and a missing
8
+ # permission here startup-fails the run before any job starts.
9
+ permissions:
10
+ contents: write
11
+ id-token: write
12
+ pull-requests: write
13
+ packages: write
14
+
5
15
  on:
6
16
  workflow_dispatch:
7
17
  inputs:
@@ -14,7 +24,6 @@ on:
14
24
  repository_dispatch:
15
25
  types: [ do-release ]
16
26
 
17
-
18
27
  jobs:
19
28
  release:
20
29
  uses: relaton/support/.github/workflows/release.yml@main
data/.gitignore CHANGED
@@ -6,6 +6,11 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /.vscode/
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
13
+
14
+ /spec/fixtures/ISO-IEC_2382
15
+ /spec/fixtures/Characters-Glossarist
16
+ /spec/fixtures/Figures
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ inherit_from:
4
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
5
+ - .rubocop_todo.yml
6
+
7
+ inherit_mode:
8
+ merge:
9
+ - Exclude
10
+
11
+ # local repo-specific modifications
12
+ # ...
13
+ plugins:
14
+ - rubocop-rspec
15
+ - rubocop-performance
16
+ - rubocop-rake
17
+
18
+ AllCops:
19
+ TargetRubyVersion: 3.0
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,189 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2026-03-24 03:26:08 UTC using RuboCop version 1.86.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
+ # This cop supports safe autocorrection (--autocorrect).
11
+ Gemspec/RequireMFA:
12
+ Exclude:
13
+ - 'termium.gemspec'
14
+
15
+ # Offense count: 1
16
+ Gemspec/RequiredRubyVersion:
17
+ Exclude:
18
+ - 'termium.gemspec'
19
+
20
+ # Offense count: 1
21
+ # This cop supports safe autocorrection (--autocorrect).
22
+ # Configuration parameters: IndentationWidth.
23
+ Layout/AssignmentIndentation:
24
+ Exclude:
25
+ - 'lib/termium/cli.rb'
26
+
27
+ # Offense count: 1
28
+ # This cop supports safe autocorrection (--autocorrect).
29
+ # Configuration parameters: EnforcedStyle.
30
+ # SupportedStyles: empty_lines, no_empty_lines
31
+ Layout/EmptyLinesAroundBlockBody:
32
+ Exclude:
33
+ - 'spec/termium_spec.rb'
34
+
35
+ # Offense count: 1
36
+ # This cop supports safe autocorrection (--autocorrect).
37
+ # Configuration parameters: EnforcedStyle.
38
+ # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
39
+ Layout/EmptyLinesAroundModuleBody:
40
+ Exclude:
41
+ - 'lib/termium.rb'
42
+
43
+ # Offense count: 1
44
+ # This cop supports safe autocorrection (--autocorrect).
45
+ # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
46
+ # SupportedHashRocketStyles: key, separator, table
47
+ # SupportedColonStyles: key, separator, table
48
+ # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
49
+ Layout/HashAlignment:
50
+ Exclude:
51
+ - 'lib/termium/cli.rb'
52
+
53
+ # Offense count: 1
54
+ # This cop supports safe autocorrection (--autocorrect).
55
+ # Configuration parameters: EnforcedStyle.
56
+ # SupportedStyles: normal, indented_internal_methods
57
+ Layout/IndentationConsistency:
58
+ Exclude:
59
+ - 'termium.gemspec'
60
+
61
+ # Offense count: 1
62
+ # This cop supports safe autocorrection (--autocorrect).
63
+ # Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment, AllowRBSInlineAnnotation, AllowSteepAnnotation.
64
+ Layout/LeadingCommentSpace:
65
+ Exclude:
66
+ - 'Rakefile'
67
+
68
+ # Offense count: 15
69
+ # This cop supports safe autocorrection (--autocorrect).
70
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
71
+ # URISchemes: http, https
72
+ Layout/LineLength:
73
+ Exclude:
74
+ - 'lib/termium/cli.rb'
75
+ - 'lib/termium/core.rb'
76
+ - 'lib/termium/language_module.rb'
77
+ - 'lib/termium/subject.rb'
78
+ - 'lib/termium/textual_support.rb'
79
+ - 'spec/termium_spec.rb'
80
+ - 'termium.gemspec'
81
+
82
+ # Offense count: 1
83
+ # This cop supports safe autocorrection (--autocorrect).
84
+ # Configuration parameters: EnforcedStyle.
85
+ # SupportedStyles: final_newline, final_blank_line
86
+ Layout/TrailingEmptyLines:
87
+ Exclude:
88
+ - 'lib/termium.rb'
89
+
90
+ # Offense count: 2
91
+ # This cop supports safe autocorrection (--autocorrect).
92
+ # Configuration parameters: AllowInHeredoc.
93
+ Layout/TrailingWhitespace:
94
+ Exclude:
95
+ - 'lib/termium/cli.rb'
96
+
97
+ # Offense count: 3
98
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
99
+ Metrics/AbcSize:
100
+ Exclude:
101
+ - 'lib/termium/cli.rb'
102
+ - 'lib/termium/core.rb'
103
+ - 'lib/termium/entry_term.rb'
104
+
105
+ # Offense count: 4
106
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
107
+ Metrics/MethodLength:
108
+ Max: 23
109
+
110
+ # Offense count: 2
111
+ # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
112
+ # AllowedMethods: call
113
+ # WaywardPredicates: infinite?, nonzero?
114
+ Naming/PredicateMethod:
115
+ Exclude:
116
+ - 'lib/termium/abbreviation.rb'
117
+ - 'lib/termium/entry_term.rb'
118
+
119
+ # Offense count: 4
120
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
121
+ # NamePrefix: is_, has_, have_, does_
122
+ # ForbiddenPrefixes: is_, has_, have_, does_
123
+ # AllowedMethods: is_a?
124
+ # MethodDefinitionMacros: define_method, define_singleton_method
125
+ Naming/PredicatePrefix:
126
+ Exclude:
127
+ - 'lib/termium/textual_support.rb'
128
+
129
+ # Offense count: 4
130
+ # This cop supports safe autocorrection (--autocorrect).
131
+ RSpec/EmptyLineAfterFinalLet:
132
+ Exclude:
133
+ - 'spec/termium/extract_spec.rb'
134
+ - 'spec/termium_spec.rb'
135
+
136
+ # Offense count: 1
137
+ # Configuration parameters: CountAsOne.
138
+ RSpec/ExampleLength:
139
+ Max: 8
140
+
141
+ # Offense count: 1
142
+ # Configuration parameters: AllowedPatterns.
143
+ # AllowedPatterns: ^expect_, ^assert_
144
+ RSpec/NoExpectationExample:
145
+ Exclude:
146
+ - 'spec/termium_spec.rb'
147
+
148
+ # Offense count: 2
149
+ # This cop supports unsafe autocorrection (--autocorrect-all).
150
+ Security/IoMethods:
151
+ Exclude:
152
+ - 'lib/termium/cli.rb'
153
+ - 'spec/termium_spec.rb'
154
+
155
+ # Offense count: 1
156
+ Style/ItAssignment:
157
+ Exclude:
158
+ - 'spec/spec_helper.rb'
159
+
160
+ # Offense count: 4
161
+ # This cop supports safe autocorrection (--autocorrect).
162
+ Style/RedundantFreeze:
163
+ Exclude:
164
+ - 'lib/termium/source.rb'
165
+ - 'lib/termium/textual_support.rb'
166
+
167
+ # Offense count: 2
168
+ # This cop supports safe autocorrection (--autocorrect).
169
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
170
+ # SupportedStyles: single_quotes, double_quotes
171
+ Style/StringLiterals:
172
+ Exclude:
173
+ - 'termium.gemspec'
174
+
175
+ # Offense count: 1
176
+ # This cop supports safe autocorrection (--autocorrect).
177
+ # Configuration parameters: EnforcedStyleForMultiline.
178
+ # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
179
+ Style/TrailingCommaInArguments:
180
+ Exclude:
181
+ - 'spec/support/shared_examples.rb'
182
+
183
+ # Offense count: 2
184
+ # This cop supports safe autocorrection (--autocorrect).
185
+ # Configuration parameters: EnforcedStyleForMultiline.
186
+ # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
187
+ Style/TrailingCommaInHashLiteral:
188
+ Exclude:
189
+ - 'lib/termium/designation_operations.rb'
data/Gemfile CHANGED
@@ -4,10 +4,11 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- gem "equivalent-xml"
8
- gem "pry"
7
+ gem "canon"
8
+ gem "lutaml-model", github: "lutaml/lutaml-model", ref: "main"
9
9
  gem "rake", "~> 13.0"
10
- gem "rspec", "~> 3.11"
11
- gem "rubocop", "~> 1.58"
12
- gem "rubocop-performance", "~> 1.21", ">= 1.21.1"
13
- gem "xml-c14n"
10
+ gem "rspec"
11
+ gem "rubocop"
12
+ gem "rubocop-performance"
13
+ gem "rubocop-rake"
14
+ gem "rubocop-rspec"
data/README.adoc CHANGED
@@ -58,11 +58,11 @@ The resulting dataset will look like this:
58
58
  ----
59
59
  {OUTPUT_PATH}/
60
60
  ├── concepts/
61
- │   ├── {CONCEPT_ID}.yaml
62
- │   ├── ...
61
+ │ ├── {CONCEPT_ID}.yaml
62
+ │ ├── ...
63
63
  ├── localized_concepts/
64
-    ├── {LOCALIZED_CONCEPT_ID}.yaml
65
-    ├── ...
64
+ ├── {LOCALIZED_CONCEPT_ID}.yaml
65
+ ├── ...
66
66
  ----
67
67
 
68
68
  ==== Usage
data/Rakefile CHANGED
@@ -8,4 +8,4 @@ RSpec::Core::RakeTask.new(:spec)
8
8
  # require "rubocop/rake_task"
9
9
  # RuboCop::RakeTask.new
10
10
 
11
- task default: %i[spec] #rubocop
11
+ task default: %i[spec] # rubocop
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "source_ref"
4
- require_relative "parameter"
5
- require_relative "designation_operations"
6
-
7
3
  module Termium
8
4
  # For <abbreviation>
9
5
  class Abbreviation < Lutaml::Model::Serializable
@@ -20,7 +16,7 @@ module Termium
20
16
  # <parameter abbreviation="NORM" />
21
17
 
22
18
  xml do
23
- root "abbreviation"
19
+ element "abbreviation"
24
20
  map_attribute "order", to: :order
25
21
  map_attribute "value", to: :value
26
22
  map_element "sourceRef", to: :source_ref
data/lib/termium/cli.rb CHANGED
@@ -7,7 +7,8 @@ module Termium
7
7
  class Cli < Thor
8
8
  desc "convert", "Convert TERMIUM entries into a Glossarist dataset"
9
9
 
10
- option :input_file, aliases: :i, required: true, desc: "Path to TERMIUM Plus XML extract"
10
+ option :input_file, aliases: :i, required: true,
11
+ desc: "Path to TERMIUM Plus XML extract"
11
12
  option :output_file, aliases: :o, desc: "Output file path"
12
13
  option :date_accepted, desc: "Date of acceptance for the dataset"
13
14
 
@@ -46,14 +47,15 @@ module Termium
46
47
  input_path = input_file_as_path(options[:input_file])
47
48
 
48
49
  puts "Reading TERMIUM export file: #{input_path.relative_path_from(Dir.pwd)}"
49
- termium_extract = Termium::Extract.from_xml(IO.read(input_path.expand_path))
50
+ termium_extract = Termium::Extract.from_xml(File.read(input_path.expand_path))
50
51
 
51
52
  puts "Size of TERMIUM dataset: #{termium_extract.core.size}"
52
53
 
53
54
  puts "Converting to Glossarist..."
54
55
  convert_options = {}
55
56
  if options[:date_accepted]
56
- convert_options[:date_accepted] = Date.parse(options[:date_accepted]).iso8601
57
+ convert_options[:date_accepted] =
58
+ Date.parse(options[:date_accepted]).iso8601
57
59
  end
58
60
  glossarist_col = termium_extract.to_concept(convert_options)
59
61
  # pp glossarist_col.first
data/lib/termium/core.rb CHANGED
@@ -1,10 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "uuidtools"
4
- require_relative "language_module"
5
- require_relative "subject"
6
- require_relative "universal_entry"
7
- require_relative "source"
8
4
 
9
5
  module Termium
10
6
  # For <core>
@@ -18,7 +14,9 @@ module Termium
18
14
  attribute :source, Source, collection: true
19
15
 
20
16
  xml do
21
- root "core"
17
+ element "core"
18
+ ordered
19
+
22
20
  map_attribute "disseminationLevel", to: :dissemination_level
23
21
  map_attribute "identificationNumber", to: :identification_number
24
22
  map_element "languageModule", to: :language_module
@@ -47,8 +45,12 @@ module Termium
47
45
  # details="Compartment - ISO/IEC JTC 1 Information Technology Vocabulary" />
48
46
  def to_concept(options = {})
49
47
  Glossarist::ManagedConcept.new.tap do |concept|
50
- # The way to set the universal concept's identifier: data.identifier
51
- concept.id = identification_number
48
+ # `data` must be assigned, not mutated: lutaml-model skips serializing
49
+ # attributes still flagged as using their default, so mutating the
50
+ # default `ManagedConceptData` in place drops the whole `data` block.
51
+ concept.data = Glossarist::ManagedConceptData.new(
52
+ id: identification_number,
53
+ )
52
54
 
53
55
  concept.uuid = uuid
54
56
 
@@ -57,24 +59,33 @@ module Termium
57
59
  concept.status = "valid"
58
60
 
59
61
  if options[:date_accepted]
60
- concept.date_accepted = options[:date_accepted]
62
+ concept.date_accepted = Glossarist::ConceptDate.new(
63
+ date: options[:date_accepted],
64
+ type: "accepted",
65
+ )
61
66
  end
62
67
 
63
- language_module.map do |lang_mod|
64
- localized_concept = lang_mod.to_concept(options)
68
+ add_localizations(concept, options)
69
+ end
70
+ end
71
+
72
+ private
73
+
74
+ def add_localizations(concept, options)
75
+ language_module.each do |lang_mod|
76
+ localized_concept = lang_mod.to_concept(options)
65
77
 
66
- # TODO: This is needed to skip the empty french entries of 10031781 and 10031778
67
- next if localized_concept.nil?
78
+ # TODO: This is needed to skip the empty french entries of 10031781 and 10031778
79
+ next if localized_concept.nil?
68
80
 
69
- localized_concept.id = identification_number
70
- localized_concept.uuid = uuid("#{identification_number}-#{lang_mod.language}")
81
+ localized_concept.id = identification_number
82
+ localized_concept.uuid = uuid("#{identification_number}-#{lang_mod.language}")
71
83
 
72
- universal_entry.each do |entry|
73
- localized_concept.notes << Glossarist::DetailedDefinition.new(content: entry.value)
74
- end
75
- localized_concept.sources = concept_sources
76
- concept.add_localization(localized_concept)
84
+ universal_entry.each do |entry|
85
+ localized_concept.notes << Glossarist::DetailedDefinition.new(content: entry.value)
77
86
  end
87
+ localized_concept.sources = concept_sources
88
+ concept.add_localization(localized_concept)
78
89
  end
79
90
  end
80
91
  end
@@ -6,7 +6,7 @@ module Termium
6
6
  PART_OF_SPEECH_CODE_MAPPING = {
7
7
  "ADJ" => "adj",
8
8
  "N" => "noun",
9
- "V" => "verb"
9
+ "V" => "verb",
10
10
  }.freeze
11
11
  def part_of_speech
12
12
  value = parameter.detect do |x|
@@ -19,7 +19,7 @@ module Termium
19
19
  GENDER_CODE_MAPPING = {
20
20
  "F" => "f",
21
21
  "M" => "m",
22
- "EPI" => "c" # this means "Epicine"
22
+ "EPI" => "c", # this means "Epicine"
23
23
  }.freeze
24
24
  def gender
25
25
  value = parameter.detect do |x|
@@ -1,10 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "source_ref"
4
- require_relative "abbreviation"
5
- require_relative "parameter"
6
- require_relative "designation_operations"
7
-
8
3
  module Termium
9
4
  # For <entryTerm>
10
5
  class EntryTerm < Lutaml::Model::Serializable
@@ -16,7 +11,7 @@ module Termium
16
11
  include DesignationOperations
17
12
 
18
13
  xml do
19
- root "entryTerm"
14
+ element "entryTerm"
20
15
  map_attribute "order", to: :order
21
16
  map_attribute "value", to: :value, value_map: { to: { empty: :empty } }
22
17
  map_element "sourceRef", to: :source_ref
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "extract_language"
4
- require_relative "core"
5
-
6
3
  module Termium
7
4
  # For <extract>
8
5
  class Extract < Lutaml::Model::Serializable
@@ -11,23 +8,15 @@ module Termium
11
8
  attribute :core, Core, collection: true
12
9
 
13
10
  xml do
14
- root "termium_extract"
15
- # namespace "http://termium.tpsgc-pwgsc.gc.ca/schemas/2012/06/Termium", "ns2"
11
+ element "termium_extract"
12
+ ordered
13
+ namespace Namespace
16
14
 
17
15
  map_attribute "language", to: :language
18
16
  map_element "extractLanguage", to: :extract_language
19
17
  map_element "core", to: :core
20
18
  end
21
19
 
22
- # xml do
23
- # root "termium_extract"
24
- # namespace "http://termium.tpsgc-pwgsc.gc.ca/schemas/2012/06/Termium", "ns2"
25
-
26
- # map_attribute "language", to: :language, namespace: nil
27
- # map_element "extractLanguage", to: :extract_language, namespace: nil
28
- # map_element "core", to: :core, namespace: nil
29
- # end
30
-
31
20
  def to_concept(options = {})
32
21
  coll = Glossarist::ManagedConceptCollection.new
33
22
  coll.managed_concepts = core.map do |managed_concept|
@@ -6,7 +6,7 @@ module Termium
6
6
  attribute :language, :string
7
7
  attribute :order, :integer
8
8
  xml do
9
- root "extractLanguage"
9
+ element "extractLanguage"
10
10
  map_attribute "language", to: :language
11
11
  map_attribute "order", to: :order
12
12
  end
@@ -1,16 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "entry_term"
4
- require_relative "textual_support"
5
-
6
3
  module Termium
7
4
  # For <languageModule>
8
5
  class LanguageModule < Lutaml::Model::Serializable
9
6
  attribute :language, :string
10
7
  attribute :entry_term, EntryTerm, collection: true
11
8
  attribute :textual_support, TextualSupport, collection: true
9
+
12
10
  xml do
13
- root "languageModule"
11
+ element "languageModule"
14
12
  map_attribute "language", to: :language
15
13
  map_element "entryTerm", to: :entry_term
16
14
  map_element "textualSupport", to: :textual_support
@@ -52,14 +50,15 @@ module Termium
52
50
 
53
51
  def to_h
54
52
  # TODO: This is needed to skip the empty french entries of 10031781 and 10031778
55
- return nil unless definition
53
+ value = definition
54
+ return nil unless value
56
55
 
57
56
  src = {
58
57
  "language_code" => LANGUAGE_CODE_MAPPING[language.downcase],
59
58
  "terms" => designations.map(&:to_h),
60
- "definition" => [{ content: definition }],
61
- "notes" => notes,
62
- "examples" => examples,
59
+ "definition" => detailed_definitions([value]),
60
+ "notes" => detailed_definitions(notes),
61
+ "examples" => detailed_definitions(examples),
63
62
  "entry_status" => "valid",
64
63
  }
65
64
 
@@ -72,15 +71,28 @@ module Termium
72
71
  x = to_h
73
72
  return nil unless x
74
73
 
75
- Glossarist::LocalizedConcept.new(x).tap do |concept|
74
+ # The flat hash belongs under "data": LocalizedConcept is data-backed, and
75
+ # `.new` would silently discard every key that is not one of its own
76
+ # attributes. `of_yaml` also routes "terms" through ConceptData.
77
+ Glossarist::LocalizedConcept.of_yaml({ "data" => x }).tap do |concept|
76
78
  # Fill in register parameters
77
79
  if options[:date_accepted]
78
- puts options[:date_accepted].inspect
79
- concept.date_accepted = options[:date_accepted]
80
+ # `date_accepted` is a read-only derived accessor on Concept; the
81
+ # accepted date is set by way of `data.dates`.
82
+ concept.data.dates = [
83
+ Glossarist::ConceptDate.new(
84
+ date: options[:date_accepted],
85
+ type: "accepted",
86
+ ),
87
+ ]
80
88
  end
81
-
82
- puts concept.inspect
83
89
  end
84
90
  end
91
+
92
+ private
93
+
94
+ def detailed_definitions(values)
95
+ values.map { |value| { "content" => value } }
96
+ end
85
97
  end
86
98
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Termium
4
+ class Namespace < Lutaml::Xml::Namespace
5
+ uri "http://termium.tpsgc-pwgsc.gc.ca/schemas/2012/06/Termium"
6
+ prefix_default "ns2"
7
+ element_form_default :unqualified
8
+ attribute_form_default :unqualified
9
+ end
10
+ end
@@ -6,7 +6,7 @@ module Termium
6
6
  # <parameter abbreviation="NORM"/>
7
7
  attribute :abbreviation, :string
8
8
  xml do
9
- root "parameter"
9
+ element "parameter"
10
10
  map_attribute "abbreviation", to: :abbreviation
11
11
  end
12
12
  end
@@ -3,13 +3,13 @@
3
3
  module Termium
4
4
  # For <source>
5
5
  class Source < Lutaml::Model::Serializable
6
- ISO_BIB_REGEX = /\AISO-([\d-]+)\s+\*\s+(\d{4})\s+.*/.freeze
7
- ISOIEC_BIB_REGEX = /\AISO-IEC-([\d-]+)\s+\*\s+(\d{4})\s+.*/.freeze
6
+ ISO_BIB_REGEX = /\AISO-([\d-]+)\s+\*\s+(\d{4})\s+.*/
7
+ ISOIEC_BIB_REGEX = /\AISO-IEC-([\d-]+)\s+\*\s+(\d{4})\s+.*/
8
8
 
9
9
  attribute :order, :integer
10
10
  attribute :details, :string
11
11
  xml do
12
- root "source"
12
+ element "source"
13
13
  map_attribute "order", to: :order
14
14
  map_attribute "details", to: :details
15
15
  end
@@ -5,7 +5,7 @@ module Termium
5
5
  class SourceRef < Lutaml::Model::Serializable
6
6
  attribute :order, :integer
7
7
  xml do
8
- root "sourceRef"
8
+ element "sourceRef"
9
9
  map_attribute "order", to: :order
10
10
  end
11
11
  end
@@ -8,7 +8,7 @@ module Termium
8
8
 
9
9
  # <subject abbreviation="YBB" details="Compartment - ISO/IEC JTC 1 Information Technology Vocabulary"/>
10
10
  xml do
11
- root "subject"
11
+ element "subject"
12
12
  map_attribute "abbreviation", to: :abbreviation
13
13
  map_attribute "details", to: :details
14
14
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "source_ref"
4
-
5
3
  module Termium
6
4
  # For <textualSupport>
7
5
  class TextualSupport < Lutaml::Model::Serializable
@@ -10,7 +8,7 @@ module Termium
10
8
  attribute :value, :string
11
9
  attribute :source_ref, SourceRef
12
10
  xml do
13
- root "textualSupport"
11
+ element "textualSupport"
14
12
  map_attribute "order", to: :order
15
13
  map_attribute "type", to: :type
16
14
  map_element "value", to: :value
@@ -31,7 +29,7 @@ module Termium
31
29
  end
32
30
  end
33
31
 
34
- EXAMPLE_REGEX = /\AEx[ea]mples?\s*:\s*/.freeze
32
+ EXAMPLE_REGEX = /\AEx[ea]mples?\s*:\s*/
35
33
 
36
34
  def is_example?
37
35
  value_cleaned.match(EXAMPLE_REGEX)
@@ -53,7 +51,7 @@ module Termium
53
51
  value_cleaned.gsub(EXAMPLE_REGEX, "")
54
52
  end
55
53
 
56
- DEFINITION_REGEX = /\A<(.+?)>\s*/.freeze
54
+ DEFINITION_REGEX = /\A<(.+?)>\s*/
57
55
 
58
56
  def value_definition
59
57
  value_cleaned.gsub(DEFINITION_REGEX, "")
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "source_ref"
4
- require_relative "parameter"
5
-
6
3
  module Termium
7
4
  # For <universalEntry>
8
5
  class UniversalEntry < Lutaml::Model::Serializable
@@ -18,7 +15,7 @@ module Termium
18
15
  # </universalEntry>
19
16
 
20
17
  xml do
21
- root "universalEntry"
18
+ element "universalEntry"
22
19
  map_attribute "order", to: :order
23
20
  map_element "value", to: :value
24
21
  map_element "sourceRef", to: :source_ref
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Termium
4
- VERSION = "0.3.5"
4
+ VERSION = "0.4.1"
5
5
  end
data/lib/termium.rb CHANGED
@@ -1,29 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # glossarist's ManagedConceptCollection#save_to_files calls FileUtils without
4
+ # requiring it, so loading it here keeps `termium convert` from raising
5
+ # NameError.
6
+ require "fileutils"
3
7
  require "glossarist"
4
8
 
5
- require "lutaml/model"
6
- require "lutaml/model/xml_adapter/nokogiri_adapter"
7
-
8
- Lutaml::Model::Config.configure do |config|
9
- config.xml_adapter = Lutaml::Model::XmlAdapter::NokogiriAdapter
10
- end
11
-
12
9
  module Termium
13
10
  class Error < StandardError; end
14
- end
15
11
 
16
- require_relative "termium/version"
17
- require_relative "termium/extract"
18
- require_relative "termium/extract_language"
19
- require_relative "termium/core"
20
- require_relative "termium/abbreviation"
21
- require_relative "termium/designation_operations"
22
- require_relative "termium/entry_term"
23
- require_relative "termium/language_module"
24
- require_relative "termium/parameter"
25
- require_relative "termium/source"
26
- require_relative "termium/source_ref"
27
- require_relative "termium/subject"
28
- require_relative "termium/textual_support"
29
- require_relative "termium/universal_entry"
12
+ autoload :Version, "termium/version"
13
+ autoload :Extract, "termium/extract"
14
+ autoload :ExtractLanguage, "termium/extract_language"
15
+ autoload :Core, "termium/core"
16
+ autoload :Abbreviation, "termium/abbreviation"
17
+ autoload :DesignationOperations, "termium/designation_operations"
18
+ autoload :EntryTerm, "termium/entry_term"
19
+ autoload :LanguageModule, "termium/language_module"
20
+ autoload :Parameter, "termium/parameter"
21
+ autoload :Namespace, "termium/namespace"
22
+ autoload :Source, "termium/source"
23
+ autoload :SourceRef, "termium/source_ref"
24
+ autoload :Subject, "termium/subject"
25
+ autoload :TextualSupport, "termium/textual_support"
26
+ autoload :UniversalEntry, "termium/universal_entry"
27
+ end
data/termium.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.metadata["homepage_uri"] = spec.homepage
22
22
  spec.metadata["source_code_uri"] = spec.homepage
23
23
  spec.metadata["bug_tracker_uri"] = "#{spec.homepage}/issues"
24
+ spec.metadata["rubygems_mfa_required"] = "true"
24
25
 
25
26
  # Specify which files should be added to the gem when it is released.
26
27
  spec.files = all_files_in_git
@@ -30,8 +31,11 @@ Gem::Specification.new do |spec|
30
31
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
32
  spec.require_paths = ["lib"]
32
33
 
33
- spec.add_dependency "glossarist", "~> 2.3.5"
34
- spec.add_dependency "lutaml-model", "~> 0.7.1"
34
+ # glossarist 2.14 relexes rubyzip (~> 3.7, matching lutaml-model) and
35
+ # tracks lutaml-model 0.8.5x — 2.11.x caps rubyzip < 3, which makes
36
+ # the whole bundle unresolvable against current lutaml-model.
37
+ spec.add_dependency "glossarist", "~> 2.14.0"
38
+ spec.add_dependency "lutaml-model", "~> 0.8.0"
35
39
  spec.add_dependency "thor"
36
40
  spec.add_dependency "uuidtools"
37
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: termium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-20 00:00:00.000000000 Z
11
+ date: 2026-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glossarist
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.5
19
+ version: 2.14.0
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: 2.3.5
26
+ version: 2.14.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: lutaml-model
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.7.1
33
+ version: 0.8.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.7.1
40
+ version: 0.8.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +78,8 @@ files:
78
78
  - ".github/workflows/release.yml"
79
79
  - ".gitignore"
80
80
  - ".rspec"
81
+ - ".rubocop.yml"
82
+ - ".rubocop_todo.yml"
81
83
  - CODE_OF_CONDUCT.md
82
84
  - Gemfile
83
85
  - README.adoc
@@ -92,6 +94,7 @@ files:
92
94
  - lib/termium/extract.rb
93
95
  - lib/termium/extract_language.rb
94
96
  - lib/termium/language_module.rb
97
+ - lib/termium/namespace.rb
95
98
  - lib/termium/parameter.rb
96
99
  - lib/termium/source.rb
97
100
  - lib/termium/source_ref.rb
@@ -108,6 +111,7 @@ metadata:
108
111
  homepage_uri: https://github.com/glossarist/termium
109
112
  source_code_uri: https://github.com/glossarist/termium
110
113
  bug_tracker_uri: https://github.com/glossarist/termium/issues
114
+ rubygems_mfa_required: 'true'
111
115
  post_install_message:
112
116
  rdoc_options: []
113
117
  require_paths: