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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +1 -1
  4. data/CLAUDE.md +71 -0
  5. data/Gemfile +0 -4
  6. data/README.adoc +69 -48
  7. data/grammars/basicdoc.rng +1559 -671
  8. data/grammars/biblio-standoc.rng +107 -46
  9. data/grammars/biblio.rng +1010 -375
  10. data/grammars/relaton-itu.rng +76 -92
  11. data/lib/relaton/itu/bibliography.rb +90 -0
  12. data/lib/relaton/itu/data_fetcher.rb +99 -0
  13. data/lib/relaton/itu/data_parser_r.rb +115 -0
  14. data/lib/relaton/itu/hit.rb +22 -0
  15. data/lib/relaton/itu/hit_collection.rb +127 -0
  16. data/lib/relaton/itu/item_data.rb +6 -0
  17. data/lib/relaton/itu/model/approval_stage.rb +13 -0
  18. data/lib/relaton/itu/model/bibdata.rb +7 -0
  19. data/lib/relaton/itu/model/bibitem.rb +7 -0
  20. data/lib/relaton/itu/model/docidentifier.rb +9 -0
  21. data/lib/relaton/itu/model/doctype.rb +13 -0
  22. data/lib/relaton/itu/model/ext.rb +39 -0
  23. data/lib/relaton/itu/model/item.rb +13 -0
  24. data/lib/relaton/itu/model/meeting.rb +13 -0
  25. data/lib/relaton/itu/model/meeting_date.rb +15 -0
  26. data/lib/relaton/itu/model/question.rb +13 -0
  27. data/lib/relaton/itu/model/recommendation_status.rb +11 -0
  28. data/lib/relaton/itu/model/structured_identifier.rb +19 -0
  29. data/lib/relaton/itu/processor.rb +66 -0
  30. data/lib/relaton/itu/pubid.rb +177 -0
  31. data/lib/relaton/itu/radio_regulations_parser.rb +70 -0
  32. data/lib/relaton/itu/recommendation_parser.rb +161 -0
  33. data/lib/relaton/itu/scraper.rb +192 -0
  34. data/lib/relaton/itu/util.rb +8 -0
  35. data/lib/relaton/itu/version.rb +5 -0
  36. data/lib/relaton/itu.rb +33 -0
  37. data/relaton_itu.gemspec +7 -7
  38. metadata +38 -34
  39. data/lib/relaton_itu/data_fetcher.rb +0 -146
  40. data/lib/relaton_itu/data_parser_r.rb +0 -98
  41. data/lib/relaton_itu/document_type.rb +0 -20
  42. data/lib/relaton_itu/editorial_group.rb +0 -64
  43. data/lib/relaton_itu/hash_converter.rb +0 -36
  44. data/lib/relaton_itu/hit.rb +0 -14
  45. data/lib/relaton_itu/hit_collection.rb +0 -144
  46. data/lib/relaton_itu/itu_bibliographic_item.rb +0 -24
  47. data/lib/relaton_itu/itu_bibliography.rb +0 -153
  48. data/lib/relaton_itu/itu_group.rb +0 -97
  49. data/lib/relaton_itu/processor.rb +0 -58
  50. data/lib/relaton_itu/pubid.rb +0 -186
  51. data/lib/relaton_itu/radio_regulations_parser.rb +0 -66
  52. data/lib/relaton_itu/recommendation_parser.rb +0 -191
  53. data/lib/relaton_itu/scrapper.rb +0 -169
  54. data/lib/relaton_itu/structured_identifier.rb +0 -51
  55. data/lib/relaton_itu/util.rb +0 -6
  56. data/lib/relaton_itu/version.rb +0 -3
  57. data/lib/relaton_itu/xml_parser.rb +0 -66
  58. data/lib/relaton_itu.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26a349717fd77a47d4ef22a1433c727612f9acc79a76f1a0f266172eafae3e7b
4
- data.tar.gz: 99e8fdfe8bea792974f8f20d892d4654340b033b0c53feef9d617c2be0ee9a43
3
+ metadata.gz: 281fcd0cfd1922d8bcbf8d2e84e32a5b45e4ec4ddcc4f93bfda1fde6e151c393
4
+ data.tar.gz: '09bb649d587a3ac19bb098a8c1138394d18396f104a3f039c7ed5d853ca1679c'
5
5
  SHA512:
6
- metadata.gz: c798efa51830b7b0211f5e1a3ea33f1309a49062a453fd6948e552bb509b0009a0d30c7a6383148b1d1d37b70fdcf5cab0fd17a1a7ab3c02a57c061af1951b5e
7
- data.tar.gz: 6ec8d8158137a0b687bcaac13ecd8a647bbd7dbe307556e19a0f2ca0cd4700e806b3a9f2e568cf96b89d07f14fbc68381f1c1d362df7418239a4363dd896fef8
6
+ metadata.gz: 0f9d834006f7a08e030eaed9590e59ba5fa8ed45702d50b4f0efb8b9f14e22a95e9c9a74a8089b6d5397c8a122619e228810afebfcb887691ce8016f4dd407c0
7
+ data.tar.gz: cacdae556200bc7fc62ef32e7db27c95a6eab8ee44e16d9e1a927e199c16adb1216942781206485ba4775ddcb7374e228a7dddf8fc19f127d730baad77842b58
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  # rspec failure tracking
14
14
  .rspec_status
15
15
  Gemfile.lock
16
+ .claude/
data/.rubocop.yml CHANGED
@@ -7,6 +7,6 @@ require: rubocop-rails
7
7
  inherit_from:
8
8
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
9
9
  AllCops:
10
- TargetRubyVersion: 2.7
10
+ TargetRubyVersion: 3.2
11
11
  Rails:
12
12
  Enabled: false
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
@@ -13,7 +13,3 @@ gem "ruby-jing"
13
13
  gem "simplecov"
14
14
  gem "vcr"
15
15
  gem "webmock"
16
-
17
- group :development do
18
- gem 'pry'
19
- end
data/README.adoc CHANGED
@@ -1,4 +1,4 @@
1
- = RelatonItu: retrieve ITU Standards for bibliographic use using the BibliographicItem model
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-bib'
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-bib
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 'relaton_itu'
36
+ require 'relaton/itu'
37
37
  => true
38
38
 
39
- hit_collection = RelatonItu::ItuBibliography.search("ITU-T L.163")
40
- => <RelatonItu::HitCollection:0x007fbf5fb4ab60 @ref=ITU-T L.163 @fetched=false>
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].fetch
43
- => #<RelatonItu::ItuBibliographicItem:0x007fbf1fc89548
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="ITU-TLSuppl.39" type="standard" schema-version="v1.2.1">
52
- <fetched>2022-12-05</fetched>
53
- <title type="title-intro" format="text/plain" language="en" script="Latn">ITU-T L.1470</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&amp;id=T-REC-L.Sup39-202009-I!!PDF-E&amp;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.2.1">
62
- <fetched>2022-12-05</fetched>
63
- <title type="title-intro" format="text/plain" language="en" script="Latn">ITU-T L.1470</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&amp;id=T-REC-L.Sup39-202009-I!!PDF-E&amp;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.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
- RelatonItu::ItuBibliography.get("ITU-T L.163", "2018", {})
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
- => #<RelatonItu::ItuBibliographicItem:0x007fbf5f94b9b8
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
- RelatonItu::ItuBibliography.get "ITU-T G.989.2/Amd 1"
86
- [relaton-itu] (ITU-T G.989.2/Amd 1) Fetching from www.itu.int ...
87
- [relaton-itu] (ITU-T G.989.2/Amd 1) Found: `ITU-T G.989.2/Amd 1`
88
- => #<RelatonItu::ItuBibliographicItem:0x007fe5409e5840
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
- RelatonItu::ItuBibliography.get "ITU-R BO.600-1"
97
- [relaton-itu] (ITU-R BO.600-1) Fetching from www.itu.int ...
98
- [relaton-itu] (ITU-R BO.600-1) Found: `ITU-R BO.600-1`
99
- => #<RelatonItu::ItuBibliographicItem:0x00007fb0cf8a1308
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
- RelatonItu::ItuBibliography.get 'ITU-R RR (2020)'
108
- [relaton-itu] (ITU-R RR) Fetching from www.itu.int ...
109
- [relaton-itu] WARNING: Invalid doctype: `publication`
110
- [relaton-itu] (ITU-R RR) Found: ITU-R RR
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` link types.
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.link
122
- => [#<RelatonBib::TypedUri:0x00007f82d665f530 @content=#<Addressable::URI:0xc170 URI:https://www.itu.int/ITU-T/recommendations/rec.aspx?rec=13786&lang=en>, @type="src">,
123
- #<RelatonBib::TypedUri:0x00007f82d665f0f8 @content=#<Addressable::URI:0xc184 URI:https://www.itu.inthttp//handle.itu.int/11.1002/1000/13786-en?locatt=format:pdf&auth>, @type="obp">]
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 YAML
140
+ === Create a bibliographic item from XML
141
+
127
142
  [source,ruby]
128
143
  ----
129
- hash = YAML.load_file 'spec/examples/itu_bib_item.yml'
130
- => {"id"=>"ITU-T L.163 (11/2018)",
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
- RelatonItu::ItuBibliographicItem.from_hash hash
134
- => #<RelatonItu::ItuBibliographicItem:0x007fd88ac02aa0
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 (https://extranet.itu.int/brdocsearch) dataset as a data source. +
160
+ This gem uses the https://extranet.itu.int/brdocsearch dataset as a data source.
141
161
 
142
- The method `RelatonItu::DataFetcher.fetch(output: "data", format: "yaml")` fetches all the documents from the dataset and saves them to the `./data` folder in YAML format.
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
- - `output` - folder to save documents (default 'data').
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
- RelatonItu::DataFetcher.fetch output: "dir", format: "xml"
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/metanorma/relaton-bib.
190
+ Bug reports and pull requests are welcome on GitHub at https://github.com/relaton/relaton-itu.
170
191
 
171
192
  == License
172
193