relaton-itu 1.20.4 → 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/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/CLAUDE.md +71 -0
- data/Gemfile +0 -4
- data/README.adoc +69 -48
- data/grammars/basicdoc.rng +1559 -671
- data/grammars/biblio-standoc.rng +107 -46
- data/grammars/biblio.rng +1010 -375
- data/grammars/relaton-itu.rng +76 -92
- data/lib/relaton/itu/bibliography.rb +90 -0
- data/lib/relaton/itu/data_fetcher.rb +99 -0
- data/lib/relaton/itu/data_parser_r.rb +115 -0
- data/lib/relaton/itu/hit.rb +22 -0
- data/lib/relaton/itu/hit_collection.rb +127 -0
- data/lib/relaton/itu/item_data.rb +6 -0
- data/lib/relaton/itu/model/approval_stage.rb +13 -0
- data/lib/relaton/itu/model/bibdata.rb +7 -0
- data/lib/relaton/itu/model/bibitem.rb +7 -0
- data/lib/relaton/itu/model/docidentifier.rb +9 -0
- data/lib/relaton/itu/model/doctype.rb +13 -0
- data/lib/relaton/itu/model/ext.rb +39 -0
- data/lib/relaton/itu/model/item.rb +13 -0
- data/lib/relaton/itu/model/meeting.rb +13 -0
- data/lib/relaton/itu/model/meeting_date.rb +15 -0
- data/lib/relaton/itu/model/question.rb +13 -0
- data/lib/relaton/itu/model/recommendation_status.rb +11 -0
- data/lib/relaton/itu/model/structured_identifier.rb +19 -0
- data/lib/relaton/itu/processor.rb +66 -0
- data/lib/relaton/itu/pubid.rb +177 -0
- data/lib/relaton/itu/radio_regulations_parser.rb +70 -0
- data/lib/relaton/itu/recommendation_parser.rb +161 -0
- data/lib/relaton/itu/scraper.rb +192 -0
- data/lib/relaton/itu/util.rb +8 -0
- data/lib/relaton/itu/version.rb +5 -0
- data/lib/relaton/itu.rb +33 -0
- data/relaton_itu.gemspec +7 -7
- metadata +38 -34
- data/lib/relaton_itu/data_fetcher.rb +0 -146
- data/lib/relaton_itu/data_parser_r.rb +0 -98
- data/lib/relaton_itu/document_type.rb +0 -20
- data/lib/relaton_itu/editorial_group.rb +0 -64
- data/lib/relaton_itu/hash_converter.rb +0 -36
- data/lib/relaton_itu/hit.rb +0 -14
- data/lib/relaton_itu/hit_collection.rb +0 -144
- data/lib/relaton_itu/itu_bibliographic_item.rb +0 -24
- data/lib/relaton_itu/itu_bibliography.rb +0 -153
- data/lib/relaton_itu/itu_group.rb +0 -97
- data/lib/relaton_itu/processor.rb +0 -58
- data/lib/relaton_itu/pubid.rb +0 -186
- data/lib/relaton_itu/radio_regulations_parser.rb +0 -66
- data/lib/relaton_itu/recommendation_parser.rb +0 -191
- data/lib/relaton_itu/scrapper.rb +0 -169
- data/lib/relaton_itu/structured_identifier.rb +0 -51
- data/lib/relaton_itu/util.rb +0 -6
- data/lib/relaton_itu/version.rb +0 -3
- data/lib/relaton_itu/xml_parser.rb +0 -66
- data/lib/relaton_itu.rb +0 -26
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 281fcd0cfd1922d8bcbf8d2e84e32a5b45e4ec4ddcc4f93bfda1fde6e151c393
|
|
4
|
+
data.tar.gz: '09bb649d587a3ac19bb098a8c1138394d18396f104a3f039c7ed5d853ca1679c'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f9d834006f7a08e030eaed9590e59ba5fa8ed45702d50b4f0efb8b9f14e22a95e9c9a74a8089b6d5397c8a122619e228810afebfcb887691ce8016f4dd407c0
|
|
7
|
+
data.tar.gz: cacdae556200bc7fc62ef32e7db27c95a6eab8ee44e16d9e1a927e199c16adb1216942781206485ba4775ddcb7374e228a7dddf8fc19f127d730baad77842b58
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
relaton-itu is a Ruby gem for retrieving ITU (International Telecommunication Union) standards metadata. Part of the Relaton family of gems maintained by Ribose Inc.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bundle exec rake spec # Run full test suite
|
|
13
|
+
bundle exec rspec spec/relaton/itu/ # Run new-namespace tests only
|
|
14
|
+
bundle exec rspec spec/relaton/itu/item_spec.rb # Run a single spec file
|
|
15
|
+
bundle exec rspec spec/relaton/itu/item_spec.rb:15 # Run a specific test by line
|
|
16
|
+
bin/console # Interactive Ruby console with gem loaded
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
No separate lint command is configured; RuboCop can be run via `bundle exec rubocop`.
|
|
20
|
+
|
|
21
|
+
## Architecture
|
|
22
|
+
|
|
23
|
+
### Namespace Migration (In Progress)
|
|
24
|
+
|
|
25
|
+
The codebase is migrating from flat `RelatonItu` namespace (`lib/relaton_itu/`) to nested `Relaton::Itu` (`lib/relaton/itu/`). Both namespaces coexist:
|
|
26
|
+
|
|
27
|
+
- **`lib/relaton/itu/`** — New namespace. Model classes, DataFetcher, DataParserR, Processor, Util, Version are here.
|
|
28
|
+
- **`lib/relaton_itu/`** — Old namespace. ItuBibliography, XMLParser, ItuBibliographicItem, HitCollection, and others still live here.
|
|
29
|
+
|
|
30
|
+
The `Processor` class (`Relaton::Itu::Processor`) bridges both: it lives in the new namespace but calls old-namespace classes (`::RelatonItu::ItuBibliography`, `::RelatonItu::XMLParser`, etc.) for functionality not yet migrated.
|
|
31
|
+
|
|
32
|
+
### Model Layer (Lutaml::Model)
|
|
33
|
+
|
|
34
|
+
All model classes use `Lutaml::Model::Serializable` for XML/YAML serialization:
|
|
35
|
+
|
|
36
|
+
- **`Item`** → extends `Bib::Item` (main bibliographic item)
|
|
37
|
+
- **`ItemData`** → extends `Bib::ItemData` (used by DataParserR for parsed documents)
|
|
38
|
+
- **`Bibitem`** / **`Bibdata`** → extend `Item`, mix in shared behavior from `Bib`
|
|
39
|
+
- **`Ext`** → extends `Bib::Ext` with ITU-specific fields (doctype, structuredidentifier, question, recommendationstatus, ip_notice_received, meeting, meeting_place, meeting_date, intended_type, source)
|
|
40
|
+
- **`Doctype`**, **`StructuredIdentifier`**, **`EditorialGroup`**, **`Bureau`**, **`Group`**, **`ApprovalStage`**, **`RecommendationStatus`**, **`Question`**, **`Meeting`**, **`MeetingDate`** — ITU-specific metadata types
|
|
41
|
+
|
|
42
|
+
### Data Fetching
|
|
43
|
+
|
|
44
|
+
- **`DataFetcher`** extends `Core::DataFetcher` — orchestrates fetching ITU-R documents from `extranet.itu.int`
|
|
45
|
+
- **`DataParserR`** — module that parses ITU-R JSON search API results into `ItemData` instances (sets `flavor: "itu"` on all parsed documents)
|
|
46
|
+
- Sources: recommendations (JSON index), questions, reports, handbooks, resolutions (HTML indices)
|
|
47
|
+
|
|
48
|
+
### Processor
|
|
49
|
+
|
|
50
|
+
`Relaton::Itu::Processor` extends `Relaton::Core::Processor` and is the entry point for the Relaton plugin system. Provides `get`, `fetch_data`, `from_xml`, `hash_to_bib`, `grammar_hash`, and `remove_index_file`.
|
|
51
|
+
|
|
52
|
+
## Testing
|
|
53
|
+
|
|
54
|
+
- **Framework:** RSpec with VCR cassettes for HTTP mocking and WebMock
|
|
55
|
+
- **Fixtures:** `spec/fixtures/` contains sample YAML/XML documents for round-trip tests
|
|
56
|
+
- **VCR cassettes:** `spec/vcr_cassettes/` — 22 cassettes recording real HTTP responses
|
|
57
|
+
- **Coverage:** SimpleCov, target near 100%
|
|
58
|
+
|
|
59
|
+
Round-trip tests (serialize → deserialize → compare) are the primary pattern for model classes.
|
|
60
|
+
|
|
61
|
+
## Key Dependencies
|
|
62
|
+
|
|
63
|
+
- `relaton-bib` — base bibliographic model classes (`Bib::Item`, `Bib::Ext`, etc.)
|
|
64
|
+
- `relaton-core` — `Core::Processor`, `Core::DataFetcher` base classes
|
|
65
|
+
- `lutaml-model` — serialization framework (XML/YAML mapping via `Lutaml::Model::Serializable`)
|
|
66
|
+
- `mechanize` — web scraping for data fetching
|
|
67
|
+
- `relaton-index` — document indexing
|
|
68
|
+
|
|
69
|
+
## Ruby Version
|
|
70
|
+
|
|
71
|
+
Requires Ruby >= 3.1.0.
|
data/Gemfile
CHANGED
data/README.adoc
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
=
|
|
1
|
+
= Relaton::Itu: retrieve ITU Standards for bibliographic use using the BibliographicItem model
|
|
2
2
|
|
|
3
3
|
image:https://img.shields.io/gem/v/relaton-itu.svg["Gem Version", link="https://rubygems.org/gems/relaton-itu"]
|
|
4
4
|
image:https://github.com/relaton/relaton-itu/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-itu/actions?workflow=macos"]
|
|
@@ -16,7 +16,7 @@ Add this line to your application's Gemfile:
|
|
|
16
16
|
|
|
17
17
|
[source,ruby]
|
|
18
18
|
----
|
|
19
|
-
gem 'relaton-
|
|
19
|
+
gem 'relaton-itu'
|
|
20
20
|
----
|
|
21
21
|
|
|
22
22
|
And then execute:
|
|
@@ -25,7 +25,7 @@ And then execute:
|
|
|
25
25
|
|
|
26
26
|
Or install it yourself as:
|
|
27
27
|
|
|
28
|
-
$ gem install relaton-
|
|
28
|
+
$ gem install relaton-itu
|
|
29
29
|
|
|
30
30
|
== Usage
|
|
31
31
|
|
|
@@ -33,38 +33,51 @@ Or install it yourself as:
|
|
|
33
33
|
|
|
34
34
|
[source,ruby]
|
|
35
35
|
----
|
|
36
|
-
require '
|
|
36
|
+
require 'relaton/itu'
|
|
37
37
|
=> true
|
|
38
38
|
|
|
39
|
-
hit_collection =
|
|
40
|
-
=> <
|
|
39
|
+
hit_collection = Relaton::Itu::Bibliography.search("ITU-T L.163")
|
|
40
|
+
=> <Relaton::Itu::HitCollection:0x00000000001700 @ref=ITU-T L.163 @fetched=false>
|
|
41
41
|
|
|
42
|
-
item = hit_collection[1].
|
|
43
|
-
=> #<
|
|
42
|
+
item = hit_collection[1].item
|
|
43
|
+
=> #<Relaton::Itu::ItemData:0x000000012541b8f8
|
|
44
44
|
...
|
|
45
45
|
----
|
|
46
46
|
|
|
47
47
|
=== XML serialization
|
|
48
|
+
|
|
48
49
|
[source,ruby]
|
|
49
50
|
----
|
|
50
51
|
item.to_xml
|
|
51
|
-
=> "<bibitem id="
|
|
52
|
-
<fetched>
|
|
53
|
-
<title
|
|
52
|
+
=> "<bibitem id="ITUTLSuppl39092020" type="standard" schema-version="v1.4.1">
|
|
53
|
+
<fetched>2026-02-24</fetched>
|
|
54
|
+
<title language="en" script="Latn" type="title-intro">ITU-T L.1470</title>
|
|
55
|
+
<title language="en" script="Latn" type="title-main">Optical fibre cable Recommendations and standardization guideline</title>
|
|
56
|
+
<title language="en" script="Latn" type="main">ITU-T L.1470 - Optical fibre cable Recommendations and standardization guideline</title>
|
|
57
|
+
<uri type="src">https://handle.itu.int/11.1002/1000/14547</uri>
|
|
58
|
+
<uri type="pdf">https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-L.Sup39-202009-I!!PDF-E&type=items</uri>
|
|
59
|
+
<docidentifier type="ITU" primary="true">ITU-T L Suppl. 39 (09/2020)</docidentifier>
|
|
54
60
|
...
|
|
55
61
|
</bibitem>"
|
|
56
62
|
----
|
|
63
|
+
|
|
57
64
|
With `bibdata: true` option XML output is wrapped with `bibdata` element and `ext` element added.
|
|
65
|
+
|
|
58
66
|
[source,ruby]
|
|
59
67
|
----
|
|
60
68
|
item.to_xml bibdata: true
|
|
61
|
-
=> "<bibdata type="standard" schema-version="v1.
|
|
62
|
-
<fetched>
|
|
63
|
-
<title
|
|
69
|
+
=> "<bibdata type="standard" schema-version="v1.4.1">
|
|
70
|
+
<fetched>2026-02-24</fetched>
|
|
71
|
+
<title language="en" script="Latn" type="title-intro">ITU-T L.1470</title>
|
|
72
|
+
<title language="en" script="Latn" type="title-main">Optical fibre cable Recommendations and standardization guideline</title>
|
|
73
|
+
<title language="en" script="Latn" type="main">ITU-T L.1470 - Optical fibre cable Recommendations and standardization guideline</title>
|
|
74
|
+
<uri type="src">https://handle.itu.int/11.1002/1000/14547</uri>
|
|
75
|
+
<uri type="pdf">https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-L.Sup39-202009-I!!PDF-E&type=items</uri>
|
|
76
|
+
<docidentifier type="ITU" primary="true">ITU-T L Suppl. 39 (09/2020)</docidentifier>
|
|
64
77
|
...
|
|
65
|
-
<ext schema-version="v1.0.
|
|
78
|
+
<ext schema-version="v1.0.2">
|
|
66
79
|
<doctype>recommendation</doctype>
|
|
67
|
-
|
|
80
|
+
<flavor>itu</flavor>
|
|
68
81
|
</ext>
|
|
69
82
|
</bibdata>"
|
|
70
83
|
----
|
|
@@ -72,20 +85,20 @@ item.to_xml bibdata: true
|
|
|
72
85
|
=== Get document by code and year
|
|
73
86
|
[source,ruby]
|
|
74
87
|
----
|
|
75
|
-
|
|
76
|
-
[relaton-itu] (ITU-T L.163) Fetching from www.itu.int ...
|
|
77
|
-
[relaton-itu] (ITU-T L.163) Found: `ITU-T L.163`
|
|
78
|
-
=> #<
|
|
88
|
+
Relaton::Itu::Bibliography.get("ITU-T L.163", "2018", {})
|
|
89
|
+
[relaton-itu] INFO: (ITU-T L.163 (2018)) Fetching from www.itu.int ...
|
|
90
|
+
[relaton-itu] INFO: (ITU-T L.163 (2018)) Found: `ITU-T L.163 (11/2018)`
|
|
91
|
+
=> #<Relaton::Itu::ItemData:0x000000010f92a288
|
|
79
92
|
...
|
|
80
93
|
----
|
|
81
94
|
|
|
82
95
|
=== Get amendment
|
|
83
96
|
[source,ruby]
|
|
84
97
|
----
|
|
85
|
-
|
|
86
|
-
[relaton-itu] (ITU-T G.989.2
|
|
87
|
-
[relaton-itu] (ITU-T G.989.2
|
|
88
|
-
=> #<
|
|
98
|
+
Relaton::Itu::Bibliography.get "ITU-T G.989.2 (2019)/Amd 1"
|
|
99
|
+
[relaton-itu] INFO: (ITU-T G.989.2 (2019)) Fetching from www.itu.int ...
|
|
100
|
+
[relaton-itu] INFO: (ITU-T G.989.2 (2019)) Found: `ITU-T G.989.2 (02/2019)`
|
|
101
|
+
=> #<Relaton::Itu::ItemData:0x000000010fa4f3c0
|
|
89
102
|
...
|
|
90
103
|
----
|
|
91
104
|
|
|
@@ -93,10 +106,10 @@ RelatonItu::ItuBibliography.get "ITU-T G.989.2/Amd 1"
|
|
|
93
106
|
|
|
94
107
|
[source,ruby]
|
|
95
108
|
----
|
|
96
|
-
|
|
97
|
-
[relaton-itu] (ITU-R BO.600-1) Fetching from
|
|
98
|
-
[relaton-itu] (ITU-R BO.600-1) Found: `ITU-R BO.600-1`
|
|
99
|
-
=> #<
|
|
109
|
+
Relaton::Itu::Bibliography.get "ITU-R BO.600-1"
|
|
110
|
+
[relaton-itu] INFO: (ITU-R BO.600-1) Fetching from Relaton repository ...
|
|
111
|
+
[relaton-itu] INFO: (ITU-R BO.600-1) Found: `ITU-R BO.600-1`
|
|
112
|
+
=> #<Relaton::Itu::ItemData:0x000000010fa4a3c0
|
|
100
113
|
...
|
|
101
114
|
----
|
|
102
115
|
|
|
@@ -104,50 +117,58 @@ RelatonItu::ItuBibliography.get "ITU-R BO.600-1"
|
|
|
104
117
|
|
|
105
118
|
[source,ruby]
|
|
106
119
|
----
|
|
107
|
-
|
|
108
|
-
[relaton-itu] (ITU-R RR) Fetching from www.itu.int ...
|
|
109
|
-
[relaton-itu]
|
|
110
|
-
|
|
111
|
-
=> #<RelatonItu::ItuBibliographicItem:0x007fb4b55eb660
|
|
120
|
+
Relaton::Itu::Bibliography.get 'ITU-R RR (2020)'
|
|
121
|
+
[relaton-itu] INFO: (ITU-R RR (2020)) Fetching from www.itu.int ...
|
|
122
|
+
[relaton-itu] INFO: (ITU-R RR (2020)) Found: `ITU-R RR (2020)`
|
|
123
|
+
=> #<Relaton::Itu::ItemData:0x000000010fa41e00
|
|
112
124
|
...
|
|
113
125
|
----
|
|
114
126
|
|
|
115
|
-
=== Typed links
|
|
127
|
+
=== Typed source links
|
|
116
128
|
|
|
117
|
-
Each ITU document has `src` type link and optional `obp` and `word`
|
|
129
|
+
Each ITU document has `src` type link and optional `obp` and `word` link types.
|
|
118
130
|
|
|
119
131
|
[source,ruby]
|
|
120
132
|
----
|
|
121
|
-
item.
|
|
122
|
-
=>
|
|
123
|
-
|
|
133
|
+
item.source[0].type
|
|
134
|
+
=> "src"
|
|
135
|
+
|
|
136
|
+
item.source[0].content
|
|
137
|
+
=> "https://handle.itu.int/11.1002/1000/14547"
|
|
124
138
|
----
|
|
125
139
|
|
|
126
|
-
=== Create a bibliographic item from
|
|
140
|
+
=== Create a bibliographic item from XML
|
|
141
|
+
|
|
127
142
|
[source,ruby]
|
|
128
143
|
----
|
|
129
|
-
|
|
130
|
-
=>
|
|
144
|
+
item = Relaton::Itu::Item.from_xml File.read("spec/fixtures/bibdata.xml")
|
|
145
|
+
=> #<Relaton::Itu::ItemData:0x000000010fa28ea0
|
|
131
146
|
...
|
|
147
|
+
----
|
|
148
|
+
|
|
149
|
+
=== Create a bibliographic item from YAML
|
|
132
150
|
|
|
133
|
-
|
|
134
|
-
|
|
151
|
+
[source,ruby]
|
|
152
|
+
----
|
|
153
|
+
item = Relaton::Itu::Item.from_yaml File.read("spec/fixtures/item.yaml")
|
|
154
|
+
=> #<Relaton::Itu::ItemData:0x000000010f9848a0
|
|
135
155
|
...
|
|
136
156
|
----
|
|
137
157
|
|
|
138
158
|
=== Fetch data
|
|
139
159
|
|
|
140
|
-
This gem uses the
|
|
160
|
+
This gem uses the https://extranet.itu.int/brdocsearch dataset as a data source.
|
|
141
161
|
|
|
142
|
-
The method `
|
|
162
|
+
The method `Relaton::Itu::DataFetcher.fetch("itu-r", output: "data", format: "yaml")` fetches all the documents from the dataset and saves them to the `./data` folder in YAML format.
|
|
143
163
|
Arguments:
|
|
144
164
|
|
|
145
|
-
- `
|
|
165
|
+
- `source` - source name (`itu-r`).
|
|
166
|
+
- `output` - folder to save documents (default `data`).
|
|
146
167
|
- `format` - the format in which the documents are saved. Possible formats are: `yaml`, `xml`, `bibxxml` (default `yaml`).
|
|
147
168
|
|
|
148
169
|
[source,ruby]
|
|
149
170
|
----
|
|
150
|
-
|
|
171
|
+
Relaton::Itu::DataFetcher.fetch "itu-r", output: "dir", format: "xml"
|
|
151
172
|
Started at: 2023-05-27 09:21:16 -0400
|
|
152
173
|
Stopped at: 2023-05-27 09:27:45 -0400
|
|
153
174
|
Done in: 390 sec.
|
|
@@ -166,7 +187,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
166
187
|
|
|
167
188
|
== Contributing
|
|
168
189
|
|
|
169
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
190
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/relaton/relaton-itu.
|
|
170
191
|
|
|
171
192
|
== License
|
|
172
193
|
|