relaton-etsi 2.1.3 → 2.2.0.pre.alpha.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 +4 -4
- data/CLAUDE.md +1 -1
- data/README.adoc +0 -18
- data/lib/relaton/etsi/bibliography.rb +1 -64
- data/lib/relaton/etsi/version.rb +1 -1
- data/relaton-etsi.gemspec +4 -4
- metadata +9 -10
- data/.rubocop.yml +0 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff1636c1bb3156d61f72e353407b35129e7c086d89b9395075ece25fdba34b0a
|
|
4
|
+
data.tar.gz: def81a646a2fdd82b80f817630923beee69ca5abeeee372abea6344056529c02
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3090daadd4f1d5664bf971d08bb9bf4ba22c05f0a70f5e2b4164a531cea6f54c36a2dbe4c93aaed50de43d7f308e5ed2cd689f2aa97251d5fd6c784f961f35d2
|
|
7
|
+
data.tar.gz: f3d8ca8cbf88bff6d2d2f0048f0669f27df21dee31aed03e023978715641ed28927298c8b2eb9c94b310b0f22516588bfd862fe5dbaf2e868607b9bbac0e90f3
|
data/CLAUDE.md
CHANGED
|
@@ -60,7 +60,7 @@ Uses Lutaml for serialization:
|
|
|
60
60
|
|
|
61
61
|
### Data Flow
|
|
62
62
|
|
|
63
|
-
1. `Bibliography.get(ref)` searches the relaton-data-etsi index
|
|
63
|
+
1. `Bibliography.get(ref)` searches the relaton-data-etsi index
|
|
64
64
|
2. Fetches YAML from GitHub, converts to `Item` using `from_yaml`
|
|
65
65
|
3. `DataFetcher.fetch` pulls CSV from etsi.org, parses with `DataParser`, saves to output folder
|
|
66
66
|
|
data/README.adoc
CHANGED
|
@@ -37,24 +37,6 @@ item = Relaton::Etsi::Bibliography.get("ETSI GS ZSM 012 V1.1.1")
|
|
|
37
37
|
...
|
|
38
38
|
----
|
|
39
39
|
|
|
40
|
-
=== Reference matching
|
|
41
|
-
|
|
42
|
-
A reference matches a whole ETSI document number. Neither `ETSI TS 103 1` nor
|
|
43
|
-
`ETSI TS 103` matches `ETSI TS 103 104`. A reference without a part number
|
|
44
|
-
matches every part of the document. The `ETSI` prefix is optional.
|
|
45
|
-
|
|
46
|
-
A reference without a version returns the newest edition of the document. A
|
|
47
|
-
reference with a version and a date returns that edition.
|
|
48
|
-
|
|
49
|
-
[source,ruby]
|
|
50
|
-
----
|
|
51
|
-
Relaton::Etsi::Bibliography.get("ETSI EN 319 401")
|
|
52
|
-
[relaton-etsi] INFO: (ETSI EN 319 401) Found: `ETSI EN 319 401 V3.2.1 (2026-01)`
|
|
53
|
-
|
|
54
|
-
Relaton::Etsi::Bibliography.get("ETSI EN 319 401 V2.3.1 (2021-05)")
|
|
55
|
-
[relaton-etsi] INFO: (ETSI EN 319 401 V2.3.1 (2021-05)) Found: `ETSI EN 319 401 V2.3.1 (2021-05)`
|
|
56
|
-
----
|
|
57
|
-
|
|
58
40
|
=== XML serialization
|
|
59
41
|
|
|
60
42
|
[source,ruby]
|
|
@@ -6,16 +6,11 @@ module Relaton
|
|
|
6
6
|
module Bibliography
|
|
7
7
|
SOURCE = "https://raw.githubusercontent.com/relaton/relaton-data-etsi/refs/heads/v2/"
|
|
8
8
|
|
|
9
|
-
# What follows the document number in an index id: the part numbers, then
|
|
10
|
-
# the version. A reference matches a whole number only, so a part number
|
|
11
|
-
# is optional but a group of digits of the number is not.
|
|
12
|
-
SUFFIX = /\A(?:-\d+)*\s(?:V\d|ed\.\d)/
|
|
13
|
-
|
|
14
9
|
# @param text [String]
|
|
15
10
|
# @return [Relaton::Etsi::ItemData, nil]
|
|
16
11
|
def search(text) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
17
12
|
index = Relaton::Index.find_or_create :etsi, url: "#{SOURCE}index-v1.zip", file: INDEX_FILE
|
|
18
|
-
row =
|
|
13
|
+
row = index.search(text).min_by { |r| r[:id] }
|
|
19
14
|
return unless row
|
|
20
15
|
|
|
21
16
|
url = "#{SOURCE}#{row[:file]}"
|
|
@@ -45,64 +40,6 @@ module Relaton
|
|
|
45
40
|
result
|
|
46
41
|
end
|
|
47
42
|
|
|
48
|
-
# Match the reference against the index and return the newest edition.
|
|
49
|
-
#
|
|
50
|
-
# An index id renders as `ETSI <type> <number> <V1.2.3|ed.4> (<yyyy-mm>)`.
|
|
51
|
-
# The index matches a String query with `include?`, so a bare reference
|
|
52
|
-
# matches every edition of the document, but also longer numbers. The
|
|
53
|
-
# `matches?` filter drops the longer numbers, then `edition_key` picks the
|
|
54
|
-
# highest version, and among equal versions the latest date.
|
|
55
|
-
#
|
|
56
|
-
# @param index [Relaton::Index::Type]
|
|
57
|
-
# @param text [String] the reference
|
|
58
|
-
# @return [Hash, nil] the winning index row (`{ id:, file: }`)
|
|
59
|
-
def best_match(index, text)
|
|
60
|
-
ref = normalize(text)
|
|
61
|
-
index.search(ref)
|
|
62
|
-
.select { |row| matches? ref, row[:id] }
|
|
63
|
-
.max_by { |row| edition_key row[:id] }
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
private
|
|
67
|
-
|
|
68
|
-
# Every index id has the `ETSI` prefix. A reference can omit it.
|
|
69
|
-
#
|
|
70
|
-
# @param text [String] the reference
|
|
71
|
-
# @return [String]
|
|
72
|
-
def normalize(text)
|
|
73
|
-
ref = text.strip.squeeze(" ").sub(/\AETSI\s+/i, "")
|
|
74
|
-
"ETSI #{ref}"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# `ETSI EN 319 142` matches every part of the document. Neither
|
|
78
|
-
# `ETSI EN 319 14` nor `ETSI EN 319` matches anything: the first stops
|
|
79
|
-
# inside a group of digits, the second stops before the last group.
|
|
80
|
-
#
|
|
81
|
-
# @param ref [String] the normalized reference
|
|
82
|
-
# @param id [String] the index id
|
|
83
|
-
# @return [Boolean]
|
|
84
|
-
def matches?(ref, id)
|
|
85
|
-
return true if id == ref
|
|
86
|
-
|
|
87
|
-
rest = id[ref.length..]
|
|
88
|
-
!rest.nil? && rest.match?(SUFFIX)
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
# Sort key of one edition. The numbers keep `V19.0.0` above `V9.0.0` and
|
|
92
|
-
# `ed.11` above `ed.9`, which a comparison of the strings does not. The id
|
|
93
|
-
# is the last element to make the order of equal editions stable.
|
|
94
|
-
#
|
|
95
|
-
# A `V` version and an `ed.` edition give keys of a different length. No
|
|
96
|
-
# ETSI document has the two forms together, and `matches?` keeps the rows
|
|
97
|
-
# of one document number only, so the two forms do not meet here.
|
|
98
|
-
#
|
|
99
|
-
# @param id [String] the index id
|
|
100
|
-
# @return [Array]
|
|
101
|
-
def edition_key(id)
|
|
102
|
-
version = id[/\sV(\d+(?:\.\d+)*)/, 1] || id[/\sed\.(\d+)/, 1] || ""
|
|
103
|
-
[version.split(".").map(&:to_i), id[/\((\d{4}-\d{2})\)/, 1].to_s, id]
|
|
104
|
-
end
|
|
105
|
-
|
|
106
43
|
extend Bibliography
|
|
107
44
|
end
|
|
108
45
|
end
|
data/lib/relaton/etsi/version.rb
CHANGED
data/relaton-etsi.gemspec
CHANGED
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
|
14
14
|
"using the BibliographicItem model"
|
|
15
15
|
spec.homepage = "https://github.com/relaton/relaton-etsi"
|
|
16
16
|
spec.license = "BSD-2-Clause"
|
|
17
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 3.
|
|
17
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.3.0")
|
|
18
18
|
|
|
19
19
|
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
|
20
20
|
|
|
@@ -35,9 +35,9 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
|
35
35
|
spec.require_paths = ["lib"]
|
|
36
36
|
|
|
37
37
|
spec.add_dependency "mechanize", "~> 2.8"
|
|
38
|
-
spec.add_dependency "relaton-bib", "~> 2.
|
|
39
|
-
spec.add_dependency "relaton-core", "~>
|
|
40
|
-
spec.add_dependency "relaton-index", "~>
|
|
38
|
+
spec.add_dependency "relaton-bib", "~> 2.2.0.pre.alpha.1"
|
|
39
|
+
spec.add_dependency "relaton-core", "~> 2.2.0.pre.alpha.1"
|
|
40
|
+
spec.add_dependency "relaton-index", "~> 2.2.0.pre.alpha.1"
|
|
41
41
|
|
|
42
42
|
# For more information and examples about making a new gem, check out our
|
|
43
43
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton-etsi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1
|
|
4
|
+
version: 2.2.0.pre.alpha.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-06-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mechanize
|
|
@@ -30,42 +30,42 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 2.
|
|
33
|
+
version: 2.2.0.pre.alpha.1
|
|
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: 2.
|
|
40
|
+
version: 2.2.0.pre.alpha.1
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: relaton-core
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 2.2.0.pre.alpha.1
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: 2.2.0.pre.alpha.1
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: relaton-index
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: 2.2.0.pre.alpha.1
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
68
|
+
version: 2.2.0.pre.alpha.1
|
|
69
69
|
description: 'Relaton::Etsi: retrieve ETSI Standards for bibliographic using the BibliographicItem
|
|
70
70
|
model'
|
|
71
71
|
email:
|
|
@@ -75,7 +75,6 @@ extensions: []
|
|
|
75
75
|
extra_rdoc_files: []
|
|
76
76
|
files:
|
|
77
77
|
- ".rspec"
|
|
78
|
-
- ".rubocop.yml"
|
|
79
78
|
- CLAUDE.md
|
|
80
79
|
- LICENSE.txt
|
|
81
80
|
- README.adoc
|
|
@@ -110,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
110
109
|
requirements:
|
|
111
110
|
- - ">="
|
|
112
111
|
- !ruby/object:Gem::Version
|
|
113
|
-
version: 3.
|
|
112
|
+
version: 3.3.0
|
|
114
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
114
|
requirements:
|
|
116
115
|
- - ">="
|
data/.rubocop.yml
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# This project follows the Ribose OSS style guide.
|
|
2
|
-
# https://github.com/riboseinc/oss-guides
|
|
3
|
-
# All project-specific additions and overrides should be specified in this file.
|
|
4
|
-
|
|
5
|
-
require: rubocop-rails
|
|
6
|
-
|
|
7
|
-
inherit_from:
|
|
8
|
-
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
|
9
|
-
AllCops:
|
|
10
|
-
TargetRubyVersion: 3.2
|
|
11
|
-
Rails:
|
|
12
|
-
Enabled: false
|