iev 0.3.5 → 0.3.7

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: ade271f8d92cb9e91edef67cd761835b01475b71be9c8fd58fc6bdb31c06ce40
4
- data.tar.gz: 18d6111223f6555060d72360f4b636fba9f81a3341d4f80fd0fa8b4c4bbd3d69
3
+ metadata.gz: e35fa5a8cd6a260517986026015f363ac5114c548e44885a41a160d46e069a21
4
+ data.tar.gz: e412000b685994129c1fec6426e2e4795883d5dabccd6ffb67afc258b397ddd0
5
5
  SHA512:
6
- metadata.gz: 3e3c8ca862f48a4b8c206f976de1f53b33a146a2e7f1643e212134d2db421ea8331ff57134258df82f7546eb2c6e4fce99e5811850b3ffedfb3d7e0ba6f39120
7
- data.tar.gz: ea4678480997b220c9228cc364dd148779d35ac4c4582813e0b7aed1bcd9aa1700be63caf97f0254f83f40b0bbb7d10995c92cf7f3352a507d04f48d1b86150b
6
+ metadata.gz: 84f480fd9eaccfa0ee7e457f19b55af593680f9f858a838599a97c09de56d33b1b3afcf16b9a3a4359932beca6eca56eab0b69183bc95e75b5e3b8cff1efecab
7
+ data.tar.gz: 2345069a32ad7ab2b08d80d1508c9b6cead36dcc2a549e2744bc7f37ccec857a63e6d672d8d8d1c4fb019c406e05ff8abb1a3827455857553ffe2462654cc574
@@ -1,10 +1,14 @@
1
1
  name: rake
2
2
 
3
+ permissions:
4
+ contents: read
5
+
3
6
  on:
4
7
  push:
5
8
  branches: [ master, main ]
6
9
  tags: [ v* ]
7
10
  pull_request:
11
+ workflow_dispatch:
8
12
 
9
13
  jobs:
10
14
  rake:
@@ -1,5 +1,8 @@
1
1
  name: release
2
2
 
3
+ permissions:
4
+ contents: write
5
+
3
6
  on:
4
7
  workflow_dispatch:
5
8
  inputs:
@@ -19,4 +22,4 @@ jobs:
19
22
  next_version: ${{ github.event.inputs.next_version }}
20
23
  secrets:
21
24
  rubygems-api-key: ${{ secrets.GLOSSARIST_CI_RUBYGEMS_API_KEY }}
22
-
25
+ pat_token: ${{ secrets.GITHUB_TOKEN }}
data/.rubocop_todo.yml CHANGED
@@ -1,33 +1,18 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-01-06 12:27:40 UTC using RuboCop version 1.69.2.
3
+ # on 2025-11-14 11:14:05 UTC using RuboCop version 1.81.7.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
10
- # This cop supports safe autocorrection (--autocorrect).
11
- # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
12
- # SupportedStyles: case, end
13
- Layout/CaseIndentation:
14
- Exclude:
15
- - 'lib/iev/iso_639_code.rb'
16
-
17
- # Offense count: 1
18
- # This cop supports safe autocorrection (--autocorrect).
19
- # Configuration parameters: EnforcedStyleAlignWith, Severity.
20
- # SupportedStylesAlignWith: keyword, variable, start_of_line
21
- Layout/EndAlignment:
22
- Exclude:
23
- - 'lib/iev/iso_639_code.rb'
24
-
25
- # Offense count: 45
9
+ # Offense count: 43
26
10
  # This cop supports safe autocorrection (--autocorrect).
27
- # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
11
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
28
12
  # URISchemes: http, https
29
13
  Layout/LineLength:
30
14
  Exclude:
15
+ - 'iev.gemspec'
31
16
  - 'lib/iev/cli/command.rb'
32
17
  - 'lib/iev/cli/command_helper.rb'
33
18
  - 'lib/iev/db_cache.rb'
@@ -36,6 +21,13 @@ Layout/LineLength:
36
21
  - 'spec/acceptance/xlsx2yaml_spec.rb'
37
22
  - 'spec/iev_spec.rb'
38
23
 
24
+ # Offense count: 7
25
+ # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
26
+ Lint/DuplicateBranch:
27
+ Exclude:
28
+ - 'lib/iev/source_parser.rb'
29
+ - 'lib/iev/term_builder.rb'
30
+
39
31
  # Offense count: 1
40
32
  Lint/MixedRegexpCaptureTypes:
41
33
  Exclude:
@@ -59,7 +51,7 @@ Metrics/CyclomaticComplexity:
59
51
  - 'lib/iev/source_parser.rb'
60
52
  - 'lib/iev/term_builder.rb'
61
53
 
62
- # Offense count: 21
54
+ # Offense count: 20
63
55
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
64
56
  Metrics/MethodLength:
65
57
  Max: 74
@@ -71,11 +63,3 @@ Metrics/PerceivedComplexity:
71
63
  - 'lib/iev.rb'
72
64
  - 'lib/iev/converter/mathml_to_asciimath.rb'
73
65
  - 'lib/iev/term_builder.rb'
74
-
75
- # Offense count: 1
76
- # This cop supports unsafe autocorrection (--autocorrect-all).
77
- # Configuration parameters: EnforcedStyle.
78
- # SupportedStyles: literals, strict
79
- Style/MutableConstant:
80
- Exclude:
81
- - 'lib/iev/iso_639_code.rb'
data/Gemfile CHANGED
@@ -2,13 +2,14 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- # Specify your gem's dependencies in lutaml-model.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
- gem "rspec", "~> 3.0"
10
- gem "rubocop", "~> 1.21"
11
- gem "rubocop-performance", require: false
12
- gem "rubocop-rake", require: false
13
- gem "rubocop-rspec", require: false
5
+ gem "canon"
6
+ gem "openssl"
7
+ gem "rake"
8
+ gem "rspec"
9
+ gem "rubocop"
10
+ gem "rubocop-performance"
11
+ gem "rubocop-rake"
12
+ gem "rubocop-rspec"
14
13
  gem "simplecov"
14
+
15
+ gemspec
data/bin/console CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "bundler/setup"
5
- require "iev"
5
+ require_relative "../lib/iev"
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
data/iev.gemspec CHANGED
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path("lib", __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "iev/version"
3
+ require_relative "lib/iev/version"
6
4
 
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = "iev"
@@ -10,9 +8,9 @@ Gem::Specification.new do |spec|
10
8
  spec.authors = ["Ribose Inc."]
11
9
  spec.email = ["open.source@ribose.com"]
12
10
 
13
- spec.summary = "Iev: Fetch and encode Iev term from Electropedia"
14
- spec.description = "Iev: Fetch and encode Iev term from Electropedia"
15
- spec.homepage = "https://github.com/metanorma/iev"
11
+ spec.summary = "Glossarist toolkit for working with IEV terms from Electropedia"
12
+ spec.description = "Glossarist toolkit for working with IEV terms from Electropedia"
13
+ spec.homepage = "https://github.com/glossarist/iev"
16
14
  spec.license = "BSD-2-Clause"
17
15
 
18
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -23,14 +21,13 @@ Gem::Specification.new do |spec|
23
21
  spec.require_paths = ["lib"]
24
22
  spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
25
23
 
26
- spec.add_dependency "creek", "~> 2.5"
24
+ spec.add_dependency "creek", "~> 2.6"
27
25
  spec.add_dependency "glossarist", ">= 2.3.0"
28
- spec.add_dependency "nokogiri", ">= 1.16.5"
26
+ spec.add_dependency "nokogiri", "~> 1.17"
29
27
  spec.add_dependency "plurimath"
30
28
  spec.add_dependency "relaton", "~> 1.18"
31
29
  spec.add_dependency "sequel", "~> 5.40"
32
30
  spec.add_dependency "sqlite3", "~> 1.7.0"
33
31
  spec.add_dependency "thor", "~> 1.0"
34
32
  spec.add_dependency "unitsml"
35
- spec.add_dependency "zeitwerk", "~> 2.4"
36
33
  end
@@ -72,10 +72,10 @@ module Iev
72
72
  Glossarist::ManagedConceptCollection.new.tap do |concept_collection|
73
73
  dataset.each do |row|
74
74
  term = TermBuilder.build_from(row)
75
- if term
76
- concept = concept_collection.fetch_or_initialize(term.id)
77
- concept.add_l10n(term)
78
- end
75
+ next unless term
76
+
77
+ concept = concept_collection.fetch_or_initialize(term.id)
78
+ concept.add_l10n(term)
79
79
  end
80
80
  end
81
81
  end
data/lib/iev/cli/ui.rb CHANGED
@@ -62,7 +62,7 @@ module Iev
62
62
  end
63
63
 
64
64
  def should_out?(level, topic)
65
- topic.nil? || level == :warn || $IEV_DEBUG[topic]
65
+ topic.nil? || level == :warn || ($IEV_DEBUG && $IEV_DEBUG[topic])
66
66
  end
67
67
  end
68
68
  end
data/lib/iev/cli.rb CHANGED
@@ -5,6 +5,10 @@
5
5
 
6
6
  module Iev
7
7
  module Cli
8
+ autoload :Command, "iev/cli/command"
9
+ autoload :CommandHelper, "iev/cli/command_helper"
10
+ autoload :Ui, "iev/cli/ui"
11
+
8
12
  def self.start(arguments)
9
13
  Signal.trap("INT") do
10
14
  Ui.info "Signal SIGINT received, quitting!"
data/lib/iev/converter.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Iev
4
4
  module Converter
5
+ autoload :MathmlToAsciimath, "iev/converter/mathml_to_asciimath"
6
+
5
7
  def self.mathml_to_asciimath(input)
6
8
  Iev::Converter::MathmlToAsciimath.convert(input)
7
9
  end
@@ -3,6 +3,8 @@
3
3
  # (c) Copyright 2020 Ribose Inc.
4
4
  #
5
5
 
6
+ require "htmlentities"
7
+
6
8
  module Iev
7
9
  module DataConversions
8
10
  refine String do
@@ -7,16 +7,18 @@ module Iev
7
7
  # @todo This needs to be rewritten.
8
8
  class Iso639Code
9
9
  COUNTRY_CODES = YAML.load(IO.read(File.join(__dir__, "iso_639_2.yaml")))
10
- THREE_CHAR_MEMO = {}
10
+ # rubocop:disable Style/MutableConstant
11
+ THREE_CHAR_MEMO = {} # Memoization cache, must be mutable
12
+ # rubocop:enable Style/MutableConstant
11
13
 
12
14
  def initialize(two_char_code)
13
15
  @code = case two_char_code.length
14
- when 2
15
- two_char_code
16
- else
17
- # This is to handle code "nl BE" in the Iev sheet
18
- two_char_code.split(" ").first
19
- end
16
+ when 2
17
+ two_char_code
18
+ else
19
+ # This is to handle code "nl BE" in the Iev sheet
20
+ two_char_code.split.first
21
+ end
20
22
  end
21
23
 
22
24
  def find(code_type)
@@ -5,7 +5,6 @@
5
5
 
6
6
  # rubocop:todo Style/RedundantRegexpEscape
7
7
 
8
- require "English"
9
8
  module Iev
10
9
  # Parses information from the spreadsheet's SOURCE column.
11
10
  #
@@ -65,14 +65,22 @@ module Iev
65
65
  end
66
66
 
67
67
  def extract_gender(str)
68
- gender_rx = /\b[mfn]\b/
69
-
70
- @gender = remove_from_string(str, gender_rx)
68
+ # Match gender either:
69
+ # 1. Inside brackets/parentheses: (m), [f], (n)
70
+ # 2. As standalone word with boundaries: m, f, n
71
+ gender_rx = /(?:\(|\[)[mfn](?:\)|\])|\b[mfn]\b/
72
+
73
+ match = remove_from_string(str, gender_rx)
74
+ # Extract just the letter from the match (remove brackets if present)
75
+ @gender = match&.gsub(/[\[\]()]/, "")
71
76
  end
72
77
 
73
78
  # Must happen after #extract_gender
74
79
  def extract_plurality(str)
75
- plural_rx = /\bpl\b/
80
+ # Match plurality either:
81
+ # 1. Inside brackets/parentheses: (pl), [pl]
82
+ # 2. As standalone word with boundaries: pl
83
+ plural_rx = /(?:\(|\[)pl(?:\)|\])|\bpl\b/
76
84
 
77
85
  if remove_from_string(str, plural_rx)
78
86
  @plurality = "plural"
@@ -44,7 +44,7 @@ module Iev
44
44
 
45
45
  split_definition
46
46
 
47
- Glossarist::LocalizedConcept.new(term_hash)
47
+ Glossarist::LocalizedConcept.from_hash(term_hash)
48
48
  end
49
49
 
50
50
  def term_hash
@@ -65,19 +65,22 @@ module Iev
65
65
 
66
66
  {
67
67
  id: term_id,
68
- entry_status: extract_entry_status,
69
68
  classification: extract_classification,
70
- dates: dates,
71
- review_date: flesh_date(find_value_for("PUBLICATIONDATE")),
72
- review_decision_date: flesh_date(find_value_for("PUBLICATIONDATE")),
73
- review_decision_event: "published",
74
- terms: extract_terms,
75
- notes: extract_notes,
76
- examples: extract_examples,
77
- definition: [{ "content" => extract_definition_value }],
78
- sources: extract_authoritative_source,
79
- language_code: term_language,
80
- related: extract_superseded_concepts,
69
+ entry_status: extract_entry_status,
70
+ data: {
71
+ id: term_id,
72
+ dates: dates,
73
+ definition: [{ "content" => extract_definition_value }],
74
+ examples: extract_examples,
75
+ notes: extract_notes,
76
+ terms: extract_terms,
77
+ review_date: flesh_date(find_value_for("PUBLICATIONDATE")),
78
+ review_decision_date: flesh_date(find_value_for("PUBLICATIONDATE")),
79
+ review_decision_event: "published",
80
+ language_code: term_language,
81
+ sources: extract_authoritative_source,
82
+ related: extract_superseded_concepts,
83
+ }.compact,
81
84
  }.compact
82
85
  end
83
86
 
@@ -215,17 +218,21 @@ module Iev
215
218
 
216
219
  def extract_examples
217
220
  @examples.map do |str|
218
- Iev::Converter.mathml_to_asciimath(
219
- replace_newlines(parse_anchor_tag(str, term_domain)),
220
- ).strip
221
+ {
222
+ content: Iev::Converter.mathml_to_asciimath(
223
+ replace_newlines(parse_anchor_tag(str, term_domain)),
224
+ ).strip,
225
+ }
221
226
  end
222
227
  end
223
228
 
224
229
  def extract_notes
225
230
  @notes.map do |str|
226
- Iev::Converter.mathml_to_asciimath(
227
- replace_newlines(parse_anchor_tag(str, term_domain)),
228
- ).strip
231
+ {
232
+ content: Iev::Converter.mathml_to_asciimath(
233
+ replace_newlines(parse_anchor_tag(str, term_domain)),
234
+ ).strip,
235
+ }
229
236
  end
230
237
  end
231
238
 
data/lib/iev/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Iev
4
- VERSION = "0.3.5"
4
+ VERSION = "0.3.7"
5
5
  end
data/lib/iev.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "iev/version"
4
- require "iev/db"
3
+ require_relative "iev/version"
5
4
  require "open-uri"
6
5
  require "nokogiri"
7
6
 
@@ -15,17 +14,28 @@ require "relaton_bib"
15
14
  require "sequel"
16
15
  require "thor"
17
16
  require "yaml"
18
- require "zeitwerk"
19
-
20
- loader = Zeitwerk::Loader.for_gem
21
- loader.setup
22
17
 
23
18
  module Iev
19
+ autoload :Cli, "iev/cli"
20
+ autoload :Converter, "iev/converter"
21
+ autoload :DataConversions, "iev/data_conversions"
22
+ autoload :Db, "iev/db"
23
+ autoload :DbCache, "iev/db_cache"
24
+ autoload :DbWriter, "iev/db_writer"
25
+ autoload :Iso639Code, "iev/iso_639_code"
26
+ autoload :Profiler, "iev/profiler"
27
+ autoload :RelatonDb, "iev/relaton_db"
28
+ autoload :SourceParser, "iev/source_parser"
29
+ autoload :SupersessionParser, "iev/supersession_parser"
30
+ autoload :TermAttrsParser, "iev/term_attrs_parser"
31
+ autoload :TermBuilder, "iev/term_builder"
32
+ autoload :Utilities, "iev/utilities"
33
+
24
34
  #
25
35
  # Scrape Electropedia for term.
26
36
  #
27
37
  # @param [String] code for example "103-01-02"
28
- # @param [String] lang language code, for examle "en"
38
+ # @param [String] lang language code, for example "en"
29
39
  #
30
40
  # @return [String, nil] if found than term,
31
41
  # if code not found then empty string,
@@ -44,4 +54,4 @@ module Iev
44
54
  end
45
55
  end
46
56
 
47
- require "iev/cli"
57
+ require_relative "iev/cli"
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 2025-01-06 00:00:00.000000000 Z
11
+ date: 2025-11-14 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: creek
@@ -15,14 +16,14 @@ dependencies:
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
- version: '2.5'
19
+ version: '2.6'
19
20
  type: :runtime
20
21
  prerelease: false
21
22
  version_requirements: !ruby/object:Gem::Requirement
22
23
  requirements:
23
24
  - - "~>"
24
25
  - !ruby/object:Gem::Version
25
- version: '2.5'
26
+ version: '2.6'
26
27
  - !ruby/object:Gem::Dependency
27
28
  name: glossarist
28
29
  requirement: !ruby/object:Gem::Requirement
@@ -41,16 +42,16 @@ dependencies:
41
42
  name: nokogiri
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
- - - ">="
45
+ - - "~>"
45
46
  - !ruby/object:Gem::Version
46
- version: 1.16.5
47
+ version: '1.17'
47
48
  type: :runtime
48
49
  prerelease: false
49
50
  version_requirements: !ruby/object:Gem::Requirement
50
51
  requirements:
51
- - - ">="
52
+ - - "~>"
52
53
  - !ruby/object:Gem::Version
53
- version: 1.16.5
54
+ version: '1.17'
54
55
  - !ruby/object:Gem::Dependency
55
56
  name: plurimath
56
57
  requirement: !ruby/object:Gem::Requirement
@@ -135,21 +136,7 @@ dependencies:
135
136
  - - ">="
136
137
  - !ruby/object:Gem::Version
137
138
  version: '0'
138
- - !ruby/object:Gem::Dependency
139
- name: zeitwerk
140
- requirement: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - "~>"
143
- - !ruby/object:Gem::Version
144
- version: '2.4'
145
- type: :runtime
146
- prerelease: false
147
- version_requirements: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - "~>"
150
- - !ruby/object:Gem::Version
151
- version: '2.4'
152
- description: 'Iev: Fetch and encode Iev term from Electropedia'
139
+ description: Glossarist toolkit for working with IEV terms from Electropedia
153
140
  email:
154
141
  - open.source@ribose.com
155
142
  executables:
@@ -160,7 +147,6 @@ files:
160
147
  - ".github/workflows/rake.yml"
161
148
  - ".github/workflows/release.yml"
162
149
  - ".gitignore"
163
- - ".hound.yml"
164
150
  - ".rspec"
165
151
  - ".rubocop.yml"
166
152
  - ".rubocop_todo.yml"
@@ -193,10 +179,11 @@ files:
193
179
  - lib/iev/term_builder.rb
194
180
  - lib/iev/utilities.rb
195
181
  - lib/iev/version.rb
196
- homepage: https://github.com/metanorma/iev
182
+ homepage: https://github.com/glossarist/iev
197
183
  licenses:
198
184
  - BSD-2-Clause
199
185
  metadata: {}
186
+ post_install_message:
200
187
  rdoc_options: []
201
188
  require_paths:
202
189
  - lib
@@ -211,7 +198,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
198
  - !ruby/object:Gem::Version
212
199
  version: '0'
213
200
  requirements: []
214
- rubygems_version: 3.6.2
201
+ rubygems_version: 3.5.22
202
+ signing_key:
215
203
  specification_version: 4
216
- summary: 'Iev: Fetch and encode Iev term from Electropedia'
204
+ summary: Glossarist toolkit for working with IEV terms from Electropedia
217
205
  test_files: []
data/.hound.yml DELETED
@@ -1,5 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- ruby:
4
- enabled: true
5
- config_file: .rubocop.yml