relaton-3gpp 1.20.0 → 2.0.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/.rubocop.yml +1 -1
- data/bin/console +1 -1
- data/grammars/basicdoc.rng +1517 -651
- data/grammars/biblio-standoc.rng +100 -20
- data/grammars/biblio.rng +959 -356
- data/grammars/relaton-3gpp.rng +3 -1
- data/lib/relaton/3gpp/bibdata.rb +8 -0
- data/lib/relaton/3gpp/bibitem.rb +8 -0
- data/lib/relaton/3gpp/bibliography.rb +51 -0
- data/lib/relaton/3gpp/data_fetcher.rb +225 -0
- data/lib/relaton/3gpp/doctype.rb +9 -0
- data/lib/relaton/3gpp/ext.rb +34 -0
- data/lib/relaton/3gpp/item.rb +12 -0
- data/lib/relaton/3gpp/item_data.rb +23 -0
- data/lib/relaton/3gpp/parser.rb +304 -0
- data/lib/relaton/3gpp/processor.rb +60 -0
- data/lib/relaton/3gpp/release.rb +33 -0
- data/lib/relaton/3gpp/util.rb +8 -0
- data/lib/relaton/3gpp/version.rb +7 -0
- data/lib/relaton/3gpp.rb +23 -0
- data/relaton_3gpp.gemspec +7 -6
- metadata +36 -20
- data/lib/relaton_3gpp/bibliographic_item.rb +0 -98
- data/lib/relaton_3gpp/bibliography.rb +0 -50
- data/lib/relaton_3gpp/data_fetcher.rb +0 -283
- data/lib/relaton_3gpp/document_type.rb +0 -18
- data/lib/relaton_3gpp/hash_converter.rb +0 -31
- data/lib/relaton_3gpp/parser.rb +0 -273
- data/lib/relaton_3gpp/processor.rb +0 -61
- data/lib/relaton_3gpp/release.rb +0 -70
- data/lib/relaton_3gpp/util.rb +0 -6
- data/lib/relaton_3gpp/version.rb +0 -5
- data/lib/relaton_3gpp/xml_parser.rb +0 -62
- data/lib/relaton_3gpp.rb +0 -28
@@ -0,0 +1,60 @@
|
|
1
|
+
module Relaton
|
2
|
+
module ThreeGpp
|
3
|
+
class Processor < Relaton::Core::Processor
|
4
|
+
attr_reader :idtype
|
5
|
+
|
6
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
7
|
+
@short = :relaton_3gpp
|
8
|
+
@prefix = "3GPP"
|
9
|
+
@defaultprefix = %r{^3GPP\s}
|
10
|
+
@idtype = "3GPP"
|
11
|
+
@datasets = %w[status-smg-3GPP status-smg-3GPP-force]
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param code [String]
|
15
|
+
# @param date [String, NilClass] year
|
16
|
+
# @param opts [Hash]
|
17
|
+
# @return [RelatonBib::BibliographicItem]
|
18
|
+
def get(code, date, opts)
|
19
|
+
Bibliography.get(code, date, opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Fetch all the documents from http://xml2rfc.tools.ietf.org/public/rfc/bibxml-3gpp-new/
|
24
|
+
#
|
25
|
+
# @param [String] source source name
|
26
|
+
# @param [Hash] opts
|
27
|
+
# @option opts [String] :output directory to output documents
|
28
|
+
# @option opts [String] :format
|
29
|
+
#
|
30
|
+
def fetch_data(source, opts)
|
31
|
+
DataFetcher.fetch(source, **opts)
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param xml [String]
|
35
|
+
# @return [RelatonBib::BibliographicItem]
|
36
|
+
def from_xml(xml)
|
37
|
+
Item.from_xml xml
|
38
|
+
end
|
39
|
+
|
40
|
+
# @param yaml [String]
|
41
|
+
# @return [Relaton::ThreeGpp::Item]
|
42
|
+
def from_yaml(yaml)
|
43
|
+
Item.from_yaml(yaml)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns hash of XML grammar
|
47
|
+
# @return [String]
|
48
|
+
def grammar_hash
|
49
|
+
@grammar_hash ||= ThreeGpp.grammar_hash
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Remove index file
|
54
|
+
#
|
55
|
+
def remove_index_file
|
56
|
+
Relaton::Index.find_or_create("3GPP", url: true, file: Bibliography::INDEX_FILE).remove_file
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Relaton
|
2
|
+
module ThreeGpp
|
3
|
+
class Release < Lutaml::Model::Serializable
|
4
|
+
attribute :version2g, :string
|
5
|
+
attribute :version3g, :string
|
6
|
+
attribute :defunct, :boolean
|
7
|
+
attribute :wpm_code_2g, :string
|
8
|
+
attribute :wpm_code_3g, :string
|
9
|
+
attribute :freeze_meeting, :string
|
10
|
+
attribute :freeze_stage1_meeting, :string
|
11
|
+
attribute :freeze_stage2_meeting, :string
|
12
|
+
attribute :freeze_stage3_meeting, :string
|
13
|
+
attribute :close_meeting, :string
|
14
|
+
attribute :project_start, :date
|
15
|
+
attribute :project_end, :date
|
16
|
+
|
17
|
+
xml do
|
18
|
+
map_element "version2G", to: :version2g
|
19
|
+
map_element "version3G", to: :version3g
|
20
|
+
map_element "defunct", to: :defunct
|
21
|
+
map_element "wpm-code-2G", to: :wpm_code_2g
|
22
|
+
map_element "wpm-code-3G", to: :wpm_code_3g
|
23
|
+
map_element "freeze-meeting", to: :freeze_meeting
|
24
|
+
map_element "freeze-stage1-meeting", to: :freeze_stage1_meeting
|
25
|
+
map_element "freeze-stage2-meeting", to: :freeze_stage2_meeting
|
26
|
+
map_element "freeze-stage3-meeting", to: :freeze_stage3_meeting
|
27
|
+
map_element "close-meeting", to: :close_meeting
|
28
|
+
map_element "project-start", to: :project_start
|
29
|
+
map_element "project-end", to: :project_end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/relaton/3gpp.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "relaton/index"
|
3
|
+
require "relaton/core"
|
4
|
+
require "relaton/bib"
|
5
|
+
require_relative "3gpp/version"
|
6
|
+
require_relative "3gpp/util"
|
7
|
+
require_relative "3gpp/item"
|
8
|
+
require_relative "3gpp/bibitem"
|
9
|
+
require_relative "3gpp/bibdata"
|
10
|
+
require_relative "3gpp/bibliography"
|
11
|
+
|
12
|
+
module Relaton
|
13
|
+
module ThreeGpp
|
14
|
+
# Returns hash of XML reammar
|
15
|
+
# @return [String]
|
16
|
+
def self.grammar_hash
|
17
|
+
# gem_path = File.expand_path "..", __dir__
|
18
|
+
# grammars_path = File.join gem_path, "grammars", "*"
|
19
|
+
# grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
20
|
+
Digest::MD5.hexdigest ThreeGpp::VERSION + Relaton::Bib::VERSION # grammars
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/relaton_3gpp.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "lib/
|
3
|
+
require_relative "lib/relaton/3gpp/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
6
6
|
spec.name = "relaton-3gpp"
|
7
|
-
spec.version =
|
7
|
+
spec.version = Relaton::ThreeGpp::VERSION
|
8
8
|
spec.authors = ["Ribose Inc."]
|
9
9
|
spec.email = ["open.source@ribose.com"]
|
10
10
|
|
11
|
-
spec.summary = "
|
12
|
-
spec.description = "
|
11
|
+
spec.summary = "Relaton::3gpp: Ruby XMLDOC impementation."
|
12
|
+
spec.description = "Relaton::3gpp: Ruby XMLDOC impementation."
|
13
13
|
spec.homepage = "https://github.com/relaton/relaton-3gpp"
|
14
14
|
spec.license = "BSD-2-Clause"
|
15
|
-
spec.required_ruby_version = ">=
|
15
|
+
spec.required_ruby_version = ">= 3.1.0"
|
16
16
|
|
17
17
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
|
18
18
|
|
@@ -38,6 +38,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
38
38
|
|
39
39
|
spec.add_dependency "csv"
|
40
40
|
spec.add_dependency "net-ftp", "~> 0.1.0"
|
41
|
-
spec.add_dependency "relaton-bib", "~>
|
41
|
+
spec.add_dependency "relaton-bib", "~> 2.0.0-alpha.2"
|
42
|
+
spec.add_dependency "relaton-core", "~> 0.0.6"
|
42
43
|
spec.add_dependency "relaton-index", "~> 0.2.0"
|
43
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-3gpp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.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:
|
11
|
+
date: 2025-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: csv
|
@@ -44,14 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.0.0.pre.alpha.2
|
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.0.0.pre.alpha.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: relaton-core
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.0.6
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.0.6
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: relaton-index
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +80,7 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 0.2.0
|
69
|
-
description: '
|
83
|
+
description: 'Relaton::3gpp: Ruby XMLDOC impementation.'
|
70
84
|
email:
|
71
85
|
- open.source@ribose.com
|
72
86
|
executables: []
|
@@ -90,18 +104,20 @@ files:
|
|
90
104
|
- grammars/biblio.rng
|
91
105
|
- grammars/relaton-3gpp-compile.rng
|
92
106
|
- grammars/relaton-3gpp.rng
|
93
|
-
- lib/
|
94
|
-
- lib/
|
95
|
-
- lib/
|
96
|
-
- lib/
|
97
|
-
- lib/
|
98
|
-
- lib/
|
99
|
-
- lib/
|
100
|
-
- lib/
|
101
|
-
- lib/
|
102
|
-
- lib/
|
103
|
-
- lib/
|
104
|
-
- lib/
|
107
|
+
- lib/relaton/3gpp.rb
|
108
|
+
- lib/relaton/3gpp/bibdata.rb
|
109
|
+
- lib/relaton/3gpp/bibitem.rb
|
110
|
+
- lib/relaton/3gpp/bibliography.rb
|
111
|
+
- lib/relaton/3gpp/data_fetcher.rb
|
112
|
+
- lib/relaton/3gpp/doctype.rb
|
113
|
+
- lib/relaton/3gpp/ext.rb
|
114
|
+
- lib/relaton/3gpp/item.rb
|
115
|
+
- lib/relaton/3gpp/item_data.rb
|
116
|
+
- lib/relaton/3gpp/parser.rb
|
117
|
+
- lib/relaton/3gpp/processor.rb
|
118
|
+
- lib/relaton/3gpp/release.rb
|
119
|
+
- lib/relaton/3gpp/util.rb
|
120
|
+
- lib/relaton/3gpp/version.rb
|
105
121
|
- relaton_3gpp.gemspec
|
106
122
|
homepage: https://github.com/relaton/relaton-3gpp
|
107
123
|
licenses:
|
@@ -116,15 +132,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
132
|
requirements:
|
117
133
|
- - ">="
|
118
134
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
135
|
+
version: 3.1.0
|
120
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
137
|
requirements:
|
122
138
|
- - ">="
|
123
139
|
- !ruby/object:Gem::Version
|
124
140
|
version: '0'
|
125
141
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.5.11
|
127
143
|
signing_key:
|
128
144
|
specification_version: 4
|
129
|
-
summary: '
|
145
|
+
summary: 'Relaton::3gpp: Ruby XMLDOC impementation.'
|
130
146
|
test_files: []
|
@@ -1,98 +0,0 @@
|
|
1
|
-
module Relaton3gpp
|
2
|
-
class BibliographicItem < RelatonBib::BibliographicItem
|
3
|
-
DOCSUBTYPES = %w[spec release].freeze
|
4
|
-
RADIOTECHNOLOGIES = %w[2G 3G LTE 5G].freeze
|
5
|
-
|
6
|
-
# @return [String, nil]
|
7
|
-
attr_reader :radiotechnology, :release
|
8
|
-
|
9
|
-
#
|
10
|
-
# Initialize bibliographic item.
|
11
|
-
#
|
12
|
-
# @param [String, nil] radiotechnology
|
13
|
-
# @param [Boolean] common_ims_spec
|
14
|
-
# @param [Relaton3gpp::Release, nil] release
|
15
|
-
#
|
16
|
-
def initialize(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
17
|
-
Util.warn "Doctype is missing" if args[:type].nil?
|
18
|
-
@radiotechnology = args.delete(:radiotechnology)
|
19
|
-
if @radiotechnology && !RADIOTECHNOLOGIES.include?(@radiotechnology)
|
20
|
-
Util.warn "Unknown radiotechnology type: `#{@radiotechnology}`"
|
21
|
-
Util.warn "Possible radiotechnology types: `#{RADIOTECHNOLOGIES.join '`, `'}`"
|
22
|
-
end
|
23
|
-
@common_ims_spec = args.delete(:common_ims_spec)
|
24
|
-
@release = args.delete(:release)
|
25
|
-
if args[:docsubtype] && !DOCSUBTYPES.include?(args[:docsubtype])
|
26
|
-
Util.warn "Unknown docsubtype: `#{args[:docsubtype]}`"
|
27
|
-
Util.warn "Possible docsubtypes: `#{DOCSUBTYPES.join '`, `'}`"
|
28
|
-
end
|
29
|
-
super(**args)
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# Fetch the flavor shcema version
|
34
|
-
#
|
35
|
-
# @return [String] schema version
|
36
|
-
#
|
37
|
-
def ext_schema
|
38
|
-
@ext_schema ||= schema_versions["relaton-model-3gpp"]
|
39
|
-
end
|
40
|
-
|
41
|
-
#
|
42
|
-
# @override RelatonBib::BibliographicItem#makeid
|
43
|
-
#
|
44
|
-
# @param [RelatonBib::DocumentIdentifier, nil] identifier <description>
|
45
|
-
# @param [Boolean, nil] attribute true if the ID attribute is needed
|
46
|
-
#
|
47
|
-
# @return [String, nil] id
|
48
|
-
#
|
49
|
-
def makeid(identifier, attribute)
|
50
|
-
super&.sub(/^3GPP/, "")
|
51
|
-
end
|
52
|
-
|
53
|
-
# @param opts [Hash]
|
54
|
-
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
55
|
-
# @option opts [Boolean] :bibdata
|
56
|
-
# @option opts [String] :lang language
|
57
|
-
# @return [String] XML
|
58
|
-
def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
59
|
-
super do |b|
|
60
|
-
if block_given? then yield b
|
61
|
-
elsif opts[:bibdata] && has_ext_attrs?
|
62
|
-
ext = b.ext do
|
63
|
-
doctype&.to_xml b
|
64
|
-
b.subdoctype subdoctype if subdoctype
|
65
|
-
editorialgroup&.to_xml b
|
66
|
-
ics.each { |i| i.to_xml b }
|
67
|
-
b.radiotechnology radiotechnology if radiotechnology
|
68
|
-
b.send :"common-ims-spec", @common_ims_spec if @common_ims_spec
|
69
|
-
release&.to_xml b
|
70
|
-
end
|
71
|
-
ext["schema-version"] = ext_schema unless opts[:embedded]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def has_ext_attrs? # rubocop:disable Metrics/CyclomaticComplexity
|
77
|
-
doctype || subdoctype || editorialgroup || ics.any? || radiotechnology ||
|
78
|
-
@common_ims_spec || release
|
79
|
-
end
|
80
|
-
|
81
|
-
#
|
82
|
-
# Convert to hash.
|
83
|
-
#
|
84
|
-
# @return [Hash
|
85
|
-
#
|
86
|
-
def to_hash(embedded: false)
|
87
|
-
hash = super
|
88
|
-
hash["ext"]["radiotechnology"] = radiotechnology if radiotechnology
|
89
|
-
hash["ext"]["common-ims-spec"] = @common_ims_spec if @common_ims_spec
|
90
|
-
hash["ext"]["release"] = release.to_hash if release
|
91
|
-
hash
|
92
|
-
end
|
93
|
-
|
94
|
-
def has_ext?
|
95
|
-
super || radiotechnology || @common_ims_spec || release
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Relaton3gpp
|
4
|
-
# Methods for search IANA standards.
|
5
|
-
module Bibliography
|
6
|
-
# SOURCE = "http://xml2rfc.tools.ietf.org/public/rfc/bibxml-3gpp-new/"
|
7
|
-
SOURCE = "https://raw.githubusercontent.com/relaton/relaton-data-3gpp/main/"
|
8
|
-
INDEX_FILE = "index-v1.yaml"
|
9
|
-
|
10
|
-
# @param text [String]
|
11
|
-
# @return [RelatonBib::BibliographicItem]
|
12
|
-
def search(text) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
13
|
-
index = Relaton::Index.find_or_create "3GPP", url: "#{SOURCE}index-v1.zip", file: INDEX_FILE
|
14
|
-
row = index.search(text.sub(/^3GPP\s/, "")).min_by { |r| r[:id] }
|
15
|
-
return unless row
|
16
|
-
|
17
|
-
# file = text.sub(/^3GPP\s/, "").gsub(/[\s,:\/]/, "_").squeeze("_").upcase
|
18
|
-
url = "#{SOURCE}#{row[:file]}"
|
19
|
-
resp = Net::HTTP.get_response URI(url)
|
20
|
-
return unless resp.code == "200"
|
21
|
-
|
22
|
-
hash = YAML.safe_load resp.body
|
23
|
-
bib_hash = Relaton3gpp::HashConverter.hash_to_bib(hash)
|
24
|
-
bib_hash[:fetched] = Date.today.to_s
|
25
|
-
Relaton3gpp::BibliographicItem.new(**bib_hash)
|
26
|
-
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
|
27
|
-
EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
28
|
-
Net::ProtocolError, Errno::ETIMEDOUT => e
|
29
|
-
raise RelatonBib::RequestError, e.message
|
30
|
-
end
|
31
|
-
|
32
|
-
# @param ref [String] the W3C standard Code to look up
|
33
|
-
# @param year [String, NilClass] not used
|
34
|
-
# @param opts [Hash] options
|
35
|
-
# @return [RelatonBib::BibliographicItem]
|
36
|
-
def get(ref, _year = nil, _opts = {})
|
37
|
-
Util.info "Fetching from Relaton repository ...", key: ref
|
38
|
-
result = search(ref)
|
39
|
-
unless result
|
40
|
-
Util.info "Not found.", key: ref
|
41
|
-
return
|
42
|
-
end
|
43
|
-
|
44
|
-
Util.info "Found: `#{result.docidentifier[0].id}`", key: ref
|
45
|
-
result
|
46
|
-
end
|
47
|
-
|
48
|
-
extend Bibliography
|
49
|
-
end
|
50
|
-
end
|