iev 0.3.6 → 0.3.8

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: 42bd017437d3f78d461046e2cf5252eddb3d4b45988f1b885abe3eb4ddcf6999
4
- data.tar.gz: 2c234ead4432ea4f469973997d7c7c0fa4ba90a03d9db9039477eec7cf77a84e
3
+ metadata.gz: 987335d7795e87ec798e7bba888b0e124a4695a341d180601de6c3035a408edc
4
+ data.tar.gz: 9948cb62807623d5413de5ba16d884d83585bf8bb96076edbe306c2a9dca06d0
5
5
  SHA512:
6
- metadata.gz: 828c3d9eb81d35e71ef7b90b5abe6f39d9cdf3828db452092a60313e46bee8d2b1e7d6a44a4d6affe03e76e1f1ab90a7788959db9c0ff3d70a33624f748aafc0
7
- data.tar.gz: 62a2f57172955b8375a3dba2f5e8a6d4ffe004498a6aa0ceb97c5ad5dffe8083ca9f791b2b25e3d9d15efa4094e4844652b05e335c4b8aaff674d948b6d0c239
6
+ metadata.gz: 3706dcd96d212daca67020bbb3be3f61ba6e05dceaaaac4dec5e5b1776c8f33e9e36ff7e25c36983e9504dab4049654e64ecd740464dee3ec27737e2e5972c07
7
+ data.tar.gz: 66eb1f2fe3025661478993451dce87541d1e3c0da1dbcc9c5656ccdc2e80059340b95b892a7557a498dbd02876e13c92ba076dd28030c17547c7d47266a8c99b
@@ -1,10 +1,16 @@
1
1
  name: rake
2
2
 
3
+ permissions:
4
+ contents: read
5
+ actions: write # Add this if you need to approve or trigger workflows
6
+
7
+
3
8
  on:
4
9
  push:
5
10
  branches: [ master, main ]
6
11
  tags: [ v* ]
7
12
  pull_request:
13
+ workflow_dispatch:
8
14
 
9
15
  jobs:
10
16
  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/README.adoc CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  image:https://img.shields.io/gem/v/iev.svg["Gem Version", link="https://rubygems.org/gems/iev"]
4
4
  image:https://github.com/glossarist/iev/workflows/rake/badge.svg["Build Status", link="https://github.com/glossarist/iev/actions?query=workflow%3Arake"]
5
- image:https://codeclimate.com/github/glossarist/iev/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/glossarist/iev"]
5
+ // image:https://codeclimate.com/github/glossarist/iev/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/glossarist/iev"]
6
6
  image:https://img.shields.io/github/issues-pr-raw/glossarist/iev.svg["Pull Requests", link="https://github.com/glossarist/iev/pulls"]
7
7
  image:https://img.shields.io/github/commits-since/glossarist/iev/latest.svg["Commits since latest",link="https://github.com/glossarist/iev/releases"]
8
8
 
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,14 @@ 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 "mechanize", "~> 2.10"
27
+ spec.add_dependency "nokogiri", "~> 1.17"
29
28
  spec.add_dependency "plurimath"
30
29
  spec.add_dependency "relaton", "~> 1.18"
31
30
  spec.add_dependency "sequel", "~> 5.40"
32
31
  spec.add_dependency "sqlite3", "~> 1.7.0"
33
32
  spec.add_dependency "thor", "~> 1.0"
34
33
  spec.add_dependency "unitsml"
35
- spec.add_dependency "zeitwerk", "~> 2.4"
36
34
  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"
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.6"
4
+ VERSION = "0.3.8"
5
5
  end
data/lib/iev.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "iev/version"
4
4
  require "iev/db"
5
- require "open-uri"
5
+ require "mechanize"
6
6
  require "nokogiri"
7
7
 
8
8
  require "benchmark"
@@ -15,26 +15,35 @@ require "relaton_bib"
15
15
  require "sequel"
16
16
  require "thor"
17
17
  require "yaml"
18
- require "zeitwerk"
19
-
20
- loader = Zeitwerk::Loader.for_gem
21
- loader.setup
22
18
 
23
19
  module Iev
20
+ autoload :Cli, "iev/cli"
21
+ autoload :Converter, "iev/converter"
22
+ autoload :DataConversions, "iev/data_conversions"
23
+ autoload :Db, "iev/db"
24
+ autoload :DbCache, "iev/db_cache"
25
+ autoload :DbWriter, "iev/db_writer"
26
+ autoload :Iso639Code, "iev/iso_639_code"
27
+ autoload :Profiler, "iev/profiler"
28
+ autoload :RelatonDb, "iev/relaton_db"
29
+ autoload :SourceParser, "iev/source_parser"
30
+ autoload :SupersessionParser, "iev/supersession_parser"
31
+ autoload :TermAttrsParser, "iev/term_attrs_parser"
32
+ autoload :TermBuilder, "iev/term_builder"
33
+ autoload :Utilities, "iev/utilities"
34
+
24
35
  #
25
36
  # Scrape Electropedia for term.
26
37
  #
27
38
  # @param [String] code for example "103-01-02"
28
- # @param [String] lang language code, for examle "en"
39
+ # @param [String] lang language code, for example "en"
29
40
  #
30
41
  # @return [String, nil] if found than term,
31
42
  # if code not found then empty string,
32
43
  # if language not found then nil.
33
44
  #
34
45
  def self.get(code, lang)
35
- url = "http://www.electropedia.org/iev/iev.nsf/"\
36
- "display?openform&ievref=#{code}"
37
- doc = Nokogiri::HTML OpenURI.open_uri(url), nil, "UTF-8"
46
+ doc = get_doc(code)
38
47
  xpath = "//table/tr/td/div/font[.=\"#{lang}\"]/../../"\
39
48
  "following-sibling::td[2]"
40
49
  a = doc&.at(xpath)&.children&.to_xml
@@ -42,6 +51,18 @@ module Iev
42
51
  &.sub(/, <.*$/, "")
43
52
  &.gsub(/<[^<>]*>/, "")&.strip
44
53
  end
54
+
55
+ def self.get_doc(code)
56
+ url = "https://www.electropedia.org/iev/iev.nsf/"\
57
+ "display?openform&ievref=#{code}"
58
+
59
+ # Use Mechanize with User-Agent to avoid 403 Forbidden errors from bot detection
60
+ agent = Mechanize.new
61
+ agent.user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
62
+
63
+ page = agent.get(url)
64
+ page.parser # Nokogiri document
65
+ end
45
66
  end
46
67
 
47
- require "iev/cli"
68
+ require_relative "iev/cli"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-05-12 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: creek
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '2.5'
18
+ version: '2.6'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '2.5'
25
+ version: '2.6'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: glossarist
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +37,34 @@ dependencies:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: 2.3.0
40
+ - !ruby/object:Gem::Dependency
41
+ name: mechanize
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.10'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.10'
41
54
  - !ruby/object:Gem::Dependency
42
55
  name: nokogiri
43
56
  requirement: !ruby/object:Gem::Requirement
44
57
  requirements:
45
- - - ">="
58
+ - - "~>"
46
59
  - !ruby/object:Gem::Version
47
- version: 1.16.5
60
+ version: '1.17'
48
61
  type: :runtime
49
62
  prerelease: false
50
63
  version_requirements: !ruby/object:Gem::Requirement
51
64
  requirements:
52
- - - ">="
65
+ - - "~>"
53
66
  - !ruby/object:Gem::Version
54
- version: 1.16.5
67
+ version: '1.17'
55
68
  - !ruby/object:Gem::Dependency
56
69
  name: plurimath
57
70
  requirement: !ruby/object:Gem::Requirement
@@ -136,21 +149,7 @@ dependencies:
136
149
  - - ">="
137
150
  - !ruby/object:Gem::Version
138
151
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: zeitwerk
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '2.4'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '2.4'
153
- description: 'Iev: Fetch and encode Iev term from Electropedia'
152
+ description: Glossarist toolkit for working with IEV terms from Electropedia
154
153
  email:
155
154
  - open.source@ribose.com
156
155
  executables:
@@ -161,7 +160,6 @@ files:
161
160
  - ".github/workflows/rake.yml"
162
161
  - ".github/workflows/release.yml"
163
162
  - ".gitignore"
164
- - ".hound.yml"
165
163
  - ".rspec"
166
164
  - ".rubocop.yml"
167
165
  - ".rubocop_todo.yml"
@@ -194,11 +192,10 @@ files:
194
192
  - lib/iev/term_builder.rb
195
193
  - lib/iev/utilities.rb
196
194
  - lib/iev/version.rb
197
- homepage: https://github.com/metanorma/iev
195
+ homepage: https://github.com/glossarist/iev
198
196
  licenses:
199
197
  - BSD-2-Clause
200
198
  metadata: {}
201
- post_install_message:
202
199
  rdoc_options: []
203
200
  require_paths:
204
201
  - lib
@@ -213,8 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
210
  - !ruby/object:Gem::Version
214
211
  version: '0'
215
212
  requirements: []
216
- rubygems_version: 3.5.22
217
- signing_key:
213
+ rubygems_version: 4.0.1
218
214
  specification_version: 4
219
- summary: 'Iev: Fetch and encode Iev term from Electropedia'
215
+ summary: Glossarist toolkit for working with IEV terms from Electropedia
220
216
  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