relaton-ietf 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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +1 -1
  4. data/CLAUDE.md +72 -0
  5. data/README.adoc +37 -41
  6. data/grammars/basicdoc.rng +1559 -671
  7. data/grammars/biblio-standoc.rng +107 -46
  8. data/grammars/biblio.rng +1010 -375
  9. data/grammars/relaton-ietf.rng +63 -65
  10. data/lib/relaton/ietf/bibdata.rb +7 -0
  11. data/lib/relaton/ietf/bibitem.rb +7 -0
  12. data/lib/relaton/ietf/bibliography.rb +35 -0
  13. data/lib/relaton/ietf/bibxml_parser.rb +241 -0
  14. data/lib/relaton/ietf/data_fetcher.rb +211 -0
  15. data/lib/relaton/ietf/doctype.rb +9 -0
  16. data/lib/relaton/ietf/ext.rb +55 -0
  17. data/lib/relaton/ietf/item.rb +11 -0
  18. data/lib/relaton/ietf/item_base.rb +9 -0
  19. data/lib/relaton/ietf/item_data.rb +6 -0
  20. data/lib/relaton/ietf/processing_instructions.rb +79 -0
  21. data/lib/relaton/ietf/processor.rb +68 -0
  22. data/lib/relaton/ietf/rfc/abstract.rb +17 -0
  23. data/lib/relaton/ietf/rfc/author.rb +19 -0
  24. data/lib/relaton/ietf/rfc/entry.rb +410 -0
  25. data/lib/relaton/ietf/rfc/entry_date.rb +19 -0
  26. data/lib/relaton/ietf/rfc/format.rb +17 -0
  27. data/lib/relaton/ietf/rfc/index.rb +47 -0
  28. data/lib/relaton/ietf/rfc/is_also.rb +19 -0
  29. data/lib/relaton/ietf/rfc/keywords.rb +17 -0
  30. data/lib/relaton/ietf/scraper.rb +68 -0
  31. data/lib/relaton/ietf/util.rb +8 -0
  32. data/lib/relaton/ietf/version.rb +5 -0
  33. data/lib/relaton/ietf/wg_name_resolver.rb +42 -0
  34. data/lib/relaton/ietf.rb +28 -0
  35. data/relaton_ietf.gemspec +7 -6
  36. metadata +48 -28
  37. data/lib/relaton/provider_ietf.rb +0 -15
  38. data/lib/relaton_ietf/bibxml_parser.rb +0 -169
  39. data/lib/relaton_ietf/committee.rb +0 -8
  40. data/lib/relaton_ietf/data_fetcher.rb +0 -235
  41. data/lib/relaton_ietf/document_type.rb +0 -16
  42. data/lib/relaton_ietf/hash_converter.rb +0 -40
  43. data/lib/relaton_ietf/ietf_bibliographic_item.rb +0 -86
  44. data/lib/relaton_ietf/ietf_bibliography.rb +0 -33
  45. data/lib/relaton_ietf/processor.rb +0 -61
  46. data/lib/relaton_ietf/renderer/bibxml.rb +0 -33
  47. data/lib/relaton_ietf/rfc_entry.rb +0 -275
  48. data/lib/relaton_ietf/rfc_index_entry.rb +0 -143
  49. data/lib/relaton_ietf/scrapper.rb +0 -69
  50. data/lib/relaton_ietf/util.rb +0 -6
  51. data/lib/relaton_ietf/version.rb +0 -3
  52. data/lib/relaton_ietf/xml_parser.rb +0 -41
  53. data/lib/relaton_ietf.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b14e8a50bb7cffacc0240b4c6dc5ecba37030f732865d55feebc6da373e62de
4
- data.tar.gz: fdd4c0909501f41468c107d4a878b0eb773387e15122cf7a50400de9c503e2be
3
+ metadata.gz: 8ef4c54fb9becdcf1b67361d4f61831c38828175aa67db7446e83de513a55ca1
4
+ data.tar.gz: 11f36dd307d779827b6091a89e5a2e8803b1e5075f52db6b621c777cb0f762e4
5
5
  SHA512:
6
- metadata.gz: 4002fdfb039cde01925f7b68fd3e12d4859c181140065d7478b49c41c8d4dce7dfee23b6969e9a87a3ac66f362352623f9f3fe389b85cad036f565070919eec3
7
- data.tar.gz: c3b027ee8e2c6101dde78d99173fd19c5838128ccdce2fb126721f86a42cb701bf8142c17e82a4306b3ce852d09b2d5438321cde72d67412386619bc3ec2e059
6
+ metadata.gz: cee5e1b632af9b8eb2107a8782f89f37e620ed86559b2e26c18fc31e67af3d8e1344828975e2586d321c04e3a4c0e7a6dccb785299403e5d9efe3d324bddc00f
7
+ data.tar.gz: be174b8c2475cb2ac450f9d8a56efdfa2c2481427fb8bd7142de6003bf144989600b5cb814032072874c923d0929d9df31baa5e09d807f13abddc31f947d7da3
data/.gitignore CHANGED
@@ -14,3 +14,4 @@
14
14
  .rspec_status
15
15
  .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
16
16
  Gemfile.lock
17
+ .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,72 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## What This Gem Does
6
+
7
+ `relaton-ietf` fetches and parses IETF bibliographic data (RFCs, Internet-Drafts, BCPs, FYIs, STDs) into the Relaton data model. Part of the [Relaton](https://github.com/relaton) ecosystem. Currently undergoing a major refactor on `lutaml-integration` branch: namespace changed from `RelatonIetf` to `Relaton::Ietf`, models migrated to `lutaml-model`.
8
+
9
+ ## Commands
10
+
11
+ ```bash
12
+ bundle exec rspec # run all tests
13
+ bundle exec rspec spec/relaton/ietf/bibxml_parser_spec.rb # run single file
14
+ bundle exec rspec spec/relaton/ietf/rfc/entry_spec.rb:19 # run single example
15
+ bundle exec rspec -e "creates primary docid" # run by description
16
+ bundle exec rubocop # lint
17
+ bundle exec rake build # build gem
18
+ ```
19
+
20
+ ## Architecture
21
+
22
+ ### Data Model (Lutaml::Model)
23
+
24
+ All models use `Lutaml::Model::Serializable` with `attribute` declarations and `xml do ... end` blocks for serialization. The IETF classes extend base `Relaton::Bib` classes:
25
+
26
+ - `Relaton::Ietf::ItemData < Bib::ItemData` — core bibliographic data
27
+ - `Relaton::Ietf::Item < Bib::Item` — adds `ext: Ext` attribute
28
+ - `Relaton::Ietf::Bibdata < Item` / `Bibitem < Item` — include shared serialization concerns
29
+ - `Relaton::Ietf::Ext` — IETF extensions: `doctype`, `flavor`, `stream`, `area`, `ipr`, `pi`
30
+ - `Relaton::Ietf::Doctype` — types: `"rfc"`, `"internet-draft"`
31
+
32
+ ### Namespace Resolution
33
+
34
+ Converter classes use `Bib::NamespaceHelper` which resolves `namespace` by taking the first two segments of the class name. For `Relaton::Ietf::BibXMLParser::FromRfcxml`, `namespace` returns `Relaton::Ietf`, so `namespace::ItemData` → `Relaton::Ietf::ItemData`, `namespace::Ext` → `Relaton::Ietf::Ext`, etc.
35
+
36
+ ### Key Flows
37
+
38
+ 1. **Single document lookup**: `Processor#get` → `Bibliography.get(code)` → `Scraper.scrape_page` → fetches YAML from GitHub data repos (`relaton-data-rfcs`, `relaton-data-ids`, `relaton-data-rfcsubseries`) via `relaton-index`
39
+
40
+ 2. **Bulk data fetching**: `DataFetcher` extends `Relaton::Core::DataFetcher` with three datasets:
41
+ - `ietf-rfcsubseries` / `ietf-rfc-entries`: parse `rfc-index.xml` via `Rfc::Index` / `Rfc::Entry#to_item`
42
+ - `ietf-internet-drafts`: parse local BibXML files via `BibXMLParser.parse`
43
+
44
+ 3. **BibXML parsing** (`BibXMLParser` module):
45
+ - `parse(xml)` — parses `<reference>` elements via `FromRfcxml` converter
46
+ - `parse_rfc(xml)` — parses `<rfc>` root documents via `FromRfc` converter
47
+ - Converters inherit from `Bib::Converter::BibXml::FromRfcxml` with IETF overrides for contributor/person/org handling
48
+
49
+ 4. **RFC Index parsing** (`Rfc::Entry#to_item`): converts RFC editor index entries (BCP/FYI/STD/RFC) into `ItemData`, handling subseries vs full RFC entries differently
50
+
51
+ ### Converter Inheritance Chain
52
+
53
+ ```
54
+ Bib::Converter::BibXml::FromRfcxml # base: handles <reference> generically
55
+ └── Ietf::BibXMLParser::FromRfcxml # IETF overrides: publisher, org recognition, person names
56
+ └── Ietf::BibXMLParser::FromRfc # <rfc> root: uses doc_name instead of anchor, no ref-level series_info
57
+ ```
58
+
59
+ `FromRfc` must override all methods that access `@reference.anchor`, `@reference.target`, `@reference.format`, or `@reference.series_info` since `Rfcxml::V3::Rfc` lacks these attributes (unlike `Rfcxml::V3::Reference`).
60
+
61
+ ## Testing Patterns
62
+
63
+ - **VCR cassettes** in `spec/vcr_cassettes/` record HTTP interactions; tests use `vcr: "cassette_name"` metadata
64
+ - **WebMock** disables net connections by default
65
+ - **Fixtures** in `spec/fixtures/` — XML/YAML expected outputs; many tests auto-generate fixtures on first run (`File.write file, xml unless File.exist? file`)
66
+ - **Schema validation** via `ruby-jing` against RNG grammars in `grammars/`
67
+ - **Shared examples** for org/person parsing in `bibxml_parser_spec.rb` (`parse_org`, `parse_person`)
68
+ - **`equivalent-xml`** gem used for XML comparison (`be_equivalent_to` matcher)
69
+
70
+ ## RuboCop
71
+
72
+ Inherits from `rubose/rubocop-rubose` (Ribose OSS config). Target Ruby 3.1. Rails cops disabled.
data/README.adoc CHANGED
@@ -1,4 +1,4 @@
1
- = RelatonIetf
1
+ = Relaton::Ietf
2
2
 
3
3
  image:https://img.shields.io/gem/v/relaton-ietf.svg["Gem Version", link="https://rubygems.org/gems/relaton-ietf"]
4
4
  image:https://github.com/relaton/relaton-ietf/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-ietf/actions?workflow=macos"]
@@ -10,7 +10,7 @@ image:https://img.shields.io/github/commits-since/relaton/relaton-ietf/latest.sv
10
10
 
11
11
  _Formerly known as_ `rfcbib`.
12
12
 
13
- RelatonIetf is a Ruby gem that searches and fetches standards from the https://www.ietf.org[Internet Engineering Task Force (IETF)], including RFCs.
13
+ Relaton::Ietf is a Ruby gem that searches and fetches standards from the https://www.ietf.org[Internet Engineering Task Force (IETF)], including RFCs.
14
14
 
15
15
  The standards scrape form https://www.rfc-editor.org/search/rfc_search.php
16
16
 
@@ -37,27 +37,27 @@ Or install it yourself as:
37
37
 
38
38
  [source,ruby]
39
39
  ----
40
- require 'relaton_ietf'
40
+ require 'relaton/ietf'
41
41
  => true
42
42
 
43
43
  # Fetch RFC document
44
- item = RelatonIetf::IetfBibliography.get 'IETF RFC 8341'
45
- [relaton-ietf] (IETF RFC 8341) Fetching from Relaton repository ...
46
- [relaton-ietf] (IETF RFC 8341) Found: `RFC 8341`
47
- => #<RelatonIetf::IetfBibliographicItem:0x007fd1875e7f58
44
+ item = Relaton::Ietf::Bibliography.get 'IETF RFC 8341'
45
+ relaton-ietf] INFO: (IETF RFC 8341) Fetching from Relaton repository ...
46
+ [relaton-ietf] INFO: (IETF RFC 8341) Found: `RFC 8341`
47
+ => #<Relaton::Ietf::ItemData:0x0000000125608cb0
48
48
  ...
49
49
 
50
50
  # Fetch Internet-Draft document
51
- RelatonIetf::IetfBibliography.get 'IETF I-D.draft-abarth-cake-01'
52
- [relaton-ietf] (IETF I-D.draft-abarth-cake-01) Fetching from Relaton repository ...
53
- [relaton-ietf] (IETF I-D.draft-abarth-cake-01) Found: `draft-abarth-cake-01`
54
- => #<RelatonIetf::IetfBibliographicItem:0x00007fdd129bbeb8
51
+ Relaton::Ietf::Bibliography.get 'IETF I-D.draft-abarth-cake-01'
52
+ [relaton-ietf] INFO: (IETF I-D.draft-abarth-cake-01) Fetching from Relaton repository ...
53
+ [relaton-ietf] INFO: (IETF I-D.draft-abarth-cake-01) Found: `draft-abarth-cake-01`
54
+ => #<Relaton::Ietf::ItemData:0x000000012141fdd0
55
55
  ...
56
56
 
57
57
  # Return nil if a document doesn't exist.
58
- RelatonIetf::IetfBibliography.get 'IETF 1111'
59
- [relaton-ietf] (IETF 1111) Fetching from Relaton repository ...
60
- [relaton-ietf] (IETF 1111) Not found.
58
+ Relaton::Ietf::Bibliography.get 'IETF 1111'
59
+ [relaton-ietf] INFO: (IETF 1111) Fetching from Relaton repository ...
60
+ [relaton-ietf] INFO: (IETF 1111) Not found.
61
61
  => nil
62
62
  ----
63
63
 
@@ -66,9 +66,9 @@ RelatonIetf::IetfBibliography.get 'IETF 1111'
66
66
  [source,ruby]
67
67
  ----
68
68
  item.to_xml
69
- => "<bibitem id="RFC8341" type="standard" schema-version="v1.2.1">
70
- <fetched>2022-12-03</fetched>
71
- <title type="main" format="text/plain">Network Configuration Access Control Model</title>
69
+ => "<bibitem id="RFC8341" type="standard" schema-version="v1.4.1">
70
+ <fetched>2026-02-18</fetched>
71
+ <title type="main">Network Configuration Access Control Model</title>
72
72
  <uri type="src">https://www.rfc-editor.org/info/rfc8341</uri>
73
73
  <docidentifier type="IETF" primary="true">RFC 8341</docidentifier>
74
74
  ....
@@ -78,24 +78,23 @@ With `bibdata: true` option XML output is wrapped with `bibdata` element and `ex
78
78
  [source,ruby]
79
79
  ----
80
80
  item.to_xml bibdata: true
81
- => "<bibdata type="standard" schema-version="v1.2.1">
82
- <fetched>2022-12-03</fetched>
83
- <title type="main" format="text/plain">Network Configuration Access Control Model</title>
81
+ => "<bibdata type="standard" schema-version="v1.4.1">
82
+ <fetched>2026-02-18</fetched>
83
+ <title type="main">Network Configuration Access Control Model</title>
84
84
  <uri type="src">https://www.rfc-editor.org/info/rfc8341</uri>
85
85
  <docidentifier type="IETF" primary="true">RFC 8341</docidentifier>
86
- <docidentifier type="DOI">10.17487/RFC8341</docidentifier>
87
86
  ...
88
87
  <ext schema-version="v1.0.1">
89
- <editorialgroup>
90
- <committee>netconf</committee>
91
- </editorialgroup>
88
+ <doctype>rfc</doctype>
89
+ <flavor>ietf</flavor>
90
+ <stream>IETF</stream>
92
91
  </ext>
93
92
  </bibdata>"
94
93
  ----
95
94
 
96
- === Typed links
95
+ === Typed source links
97
96
 
98
- IETF documents may have `src`, `xml`, and `doi` link types.
97
+ IETF documents may have `src`, `xml`, and `doi` source link types.
99
98
 
100
99
  * `src` - web publication
101
100
  * `xml` - BibXML publication
@@ -103,29 +102,26 @@ IETF documents may have `src`, `xml`, and `doi` link types.
103
102
 
104
103
  [source,ruby]
105
104
  ----
106
- item.link
107
- => [#<RelatonBib::TypedUri:0x00007fe8b287a120 @content=#<Addressable::URI:0x7e4 URI:https://raw.githubusercontent.com/relaton/relaton-data-rfcs/main/data/reference.RFC.8341.xml>, @type="xml">,
108
- #<RelatonBib::TypedUri:0x00007fe8b2237ec0 @content=#<Addressable::URI:0x7f8 URI:https://www.rfc-editor.org/info/rfc8341>, @type="src">]
105
+ item.source.first.type
106
+ => "src"
107
+ item.source.first.content
108
+ => "https://www.rfc-editor.org/info/rfc8341"
109
109
  ----
110
110
 
111
111
  === Parse a file locally
112
112
 
113
113
  [source,ruby]
114
114
  ----
115
- item = Relaton::Provider::Ietf.from_rfcxml File.read("spec/examples/rfc.xml")
116
- => #<RelatonIetf::IetfBibliographicItem:0x007fa8cda79ab8
115
+ item = Relaton::Ietf::BibXMLParser.parse_rfc File.read("spec/fixtures/rfc.xml")
116
+ => #<Relaton::Ietf::ItemData:0x000000012913e4d8
117
117
  ...
118
118
  ----
119
119
 
120
120
  === Create bibliographic item from YAML
121
121
  [source,ruby]
122
122
  ----
123
- hash = YAML.load_file 'spec/examples/ietf_bib_item.yml'
124
- => {"id"=>"RFC 8341",
125
- ...
126
-
127
- RelatonIetf::IetfBibliographicItem.from_hash hash
128
- => #<RelatonIetf::IetfBibliographicItem:0x007f9a929dde40
123
+ Relaton::Ietf::Item.from_yaml File.read('spec/fixtures/item.yaml')
124
+ => #<Relaton::Ietf::ItemData:0x0000000127edf508
129
125
  ...
130
126
  ----
131
127
 
@@ -137,7 +133,7 @@ There are IETF datasets that can be converted into RelatonXML/BibXML/BibYAML for
137
133
  - `ietf-internet-drafts` - convert files from local directory `./bibxml-ids`. Use `rsync -avcizxL rsync.ietf.org::bibxml-ids ./bibxml-ids` command to fetch the files.
138
134
  - `ietf-rfc-entries` - https://www.rfc-editor.org/rfc-index.xml (`<rfc-entry>`)
139
135
 
140
- The method `RelatonIetf::DataFetcher.fetch(source, output: "data", format: "yaml")` converts all the documents from the dataset and saves them to the `./data` folder in YAML format.
136
+ The method `Relaton::Ietf::DataFetcher.fetch(source, output: "data", format: "yaml")` converts all the documents from the dataset and saves them to the `./data` folder in YAML format.
141
137
 
142
138
  Arguments:
143
139
 
@@ -147,16 +143,16 @@ Arguments:
147
143
 
148
144
  [source,ruby]
149
145
  ----
150
- RelatonIetf::DataFetcher.fetch "ietf-internet-drafts"
146
+ Relaton::Ietf::DataFetcher.fetch "ietf-internet-drafts"
151
147
  Started at: 2021-12-17 10:23:20 +0100
152
148
  Stopped at: 2021-12-17 10:29:19 +0100
153
- Done in: 360 sec.
149
+ Done in: 1360 sec.
154
150
  => nil
155
151
  ----
156
152
 
157
153
  === Logging
158
154
 
159
- RelatonIetf uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
155
+ Relaton::Ietf uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
160
156
 
161
157
  == Contributing
162
158