rfcxml 0.4.2 → 0.4.3
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/.github/workflows/roundtrip.yml +2 -11
- data/.gitignore +1 -0
- data/.rubocop_todo.yml +68 -5
- data/CLAUDE.md +84 -0
- data/lib/rfcxml/v3/cref.rb +4 -4
- data/lib/rfcxml/v3/rfc.rb +3 -0
- data/lib/rfcxml/v3/td.rb +4 -18
- data/lib/rfcxml/version.rb +1 -1
- data/scripts/roundtrip_test.rb +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: afc99ca4a6eb6ccc3fb1a220ac8a1945df6e823b15b86fd5003761c694e9e7be
|
|
4
|
+
data.tar.gz: 853d640f0e92ae96797e4bc79b0960f715e3a1d4bc4cc53c2e0763f62ce70c04
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 15e6b2ba34f404d084620f9c8991733ad794c023773d566508c263d2941fd358b579b4011011d8ef22827398a8e46acf832e0717e8013dc670a1a7ec0269b589
|
|
7
|
+
data.tar.gz: '0021048cb9d05a37f21261f8c054cbf9bfc8a234e04fc39b47970efe4c13314126aaf27fa6695aeea3318da19a5a18985a3e58323172da729987705cad1d0328'
|
|
@@ -59,21 +59,12 @@ jobs:
|
|
|
59
59
|
run: |
|
|
60
60
|
echo "Testing all RFC XML files..."
|
|
61
61
|
ruby scripts/roundtrip_test.rb "$XML_DIR"
|
|
62
|
-
continue-on-error: true
|
|
63
|
-
id: roundtrip
|
|
64
62
|
|
|
65
63
|
- name: Upload test results
|
|
66
64
|
if: always()
|
|
67
65
|
uses: actions/upload-artifact@v4
|
|
68
66
|
with:
|
|
69
67
|
name: roundtrip-results
|
|
70
|
-
path:
|
|
71
|
-
*.log
|
|
68
|
+
path: tmp/roundtrip-results-*/
|
|
72
69
|
retention-days: 30
|
|
73
|
-
if-no-files-found:
|
|
74
|
-
|
|
75
|
-
- name: Check results
|
|
76
|
-
if: steps.roundtrip.outcome == 'failure'
|
|
77
|
-
run: |
|
|
78
|
-
echo "::error::Some RFC XML files failed round-trip testing"
|
|
79
|
-
exit 1
|
|
70
|
+
if-no-files-found: warn
|
data/.gitignore
CHANGED
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2026-
|
|
3
|
+
# on 2026-05-01 09:55:57 UTC using RuboCop version 1.86.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
@@ -11,7 +11,40 @@ Gemspec/RequiredRubyVersion:
|
|
|
11
11
|
Exclude:
|
|
12
12
|
- 'rfcxml.gemspec'
|
|
13
13
|
|
|
14
|
-
# Offense count:
|
|
14
|
+
# Offense count: 1
|
|
15
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
16
|
+
# Configuration parameters: EnforcedStyleAlignWith.
|
|
17
|
+
# SupportedStylesAlignWith: either, start_of_block, start_of_line
|
|
18
|
+
Layout/BlockAlignment:
|
|
19
|
+
Exclude:
|
|
20
|
+
- 'spec/v3/cref_spec.rb'
|
|
21
|
+
|
|
22
|
+
# Offense count: 1
|
|
23
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
24
|
+
Layout/BlockEndNewline:
|
|
25
|
+
Exclude:
|
|
26
|
+
- 'spec/v3/cref_spec.rb'
|
|
27
|
+
|
|
28
|
+
# Offense count: 4
|
|
29
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
30
|
+
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
|
31
|
+
# SupportedHashRocketStyles: key, separator, table
|
|
32
|
+
# SupportedColonStyles: key, separator, table
|
|
33
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
|
34
|
+
Layout/HashAlignment:
|
|
35
|
+
Exclude:
|
|
36
|
+
- 'lib/rfcxml/v3/td.rb'
|
|
37
|
+
- 'spec/v3/rfc_pi_spec.rb'
|
|
38
|
+
|
|
39
|
+
# Offense count: 2
|
|
40
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
41
|
+
# Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
|
|
42
|
+
# SupportedStylesAlignWith: start_of_line, relative_to_receiver
|
|
43
|
+
Layout/IndentationWidth:
|
|
44
|
+
Exclude:
|
|
45
|
+
- 'spec/v3/cref_spec.rb'
|
|
46
|
+
|
|
47
|
+
# Offense count: 28
|
|
15
48
|
# This cop supports safe autocorrection (--autocorrect).
|
|
16
49
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
17
50
|
# URISchemes: http, https
|
|
@@ -20,7 +53,17 @@ Layout/LineLength:
|
|
|
20
53
|
- 'lib/rfcxml/v3/li.rb'
|
|
21
54
|
- 'lib/rfcxml/v3/rfc.rb'
|
|
22
55
|
- 'scripts/roundtrip_test.rb'
|
|
56
|
+
- 'spec/v3/cref_spec.rb'
|
|
23
57
|
- 'spec/v3/document_creation_spec.rb'
|
|
58
|
+
- 'spec/v3/rfc_pi_spec.rb'
|
|
59
|
+
- 'spec/v3/td_spec.rb'
|
|
60
|
+
|
|
61
|
+
# Offense count: 2
|
|
62
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
63
|
+
# Configuration parameters: AllowInHeredoc.
|
|
64
|
+
Layout/TrailingWhitespace:
|
|
65
|
+
Exclude:
|
|
66
|
+
- 'spec/v3/rfc_pi_spec.rb'
|
|
24
67
|
|
|
25
68
|
# Offense count: 4
|
|
26
69
|
Lint/NoReturnInBeginEndBlocks:
|
|
@@ -59,31 +102,51 @@ Metrics/PerceivedComplexity:
|
|
|
59
102
|
- 'lib/rfcxml/v3/rfc.rb'
|
|
60
103
|
- 'scripts/roundtrip_test.rb'
|
|
61
104
|
|
|
105
|
+
# Offense count: 1
|
|
106
|
+
# Configuration parameters: MinSize.
|
|
107
|
+
Performance/CollectionLiteralInLoop:
|
|
108
|
+
Exclude:
|
|
109
|
+
- 'scripts/roundtrip_test.rb'
|
|
110
|
+
|
|
62
111
|
# Offense count: 1
|
|
63
112
|
# Configuration parameters: IgnoredMetadata.
|
|
64
113
|
RSpec/DescribeClass:
|
|
65
114
|
Exclude:
|
|
66
115
|
- 'spec/v3/document_creation_spec.rb'
|
|
67
116
|
|
|
68
|
-
# Offense count:
|
|
117
|
+
# Offense count: 20
|
|
69
118
|
# Configuration parameters: CountAsOne.
|
|
70
119
|
RSpec/ExampleLength:
|
|
71
120
|
Max: 29
|
|
72
121
|
|
|
73
|
-
# Offense count:
|
|
122
|
+
# Offense count: 25
|
|
74
123
|
RSpec/MultipleExpectations:
|
|
75
124
|
Max: 9
|
|
76
125
|
|
|
77
|
-
# Offense count:
|
|
126
|
+
# Offense count: 6
|
|
78
127
|
# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
|
|
79
128
|
# SupportedInflectors: default, active_support
|
|
80
129
|
RSpec/SpecFilePathFormat:
|
|
81
130
|
Exclude:
|
|
82
131
|
- 'spec/v3/author_spec.rb'
|
|
132
|
+
- 'spec/v3/cref_spec.rb'
|
|
133
|
+
- 'spec/v3/rfc_pi_spec.rb'
|
|
83
134
|
- 'spec/v3/rfc_spec.rb'
|
|
84
135
|
- 'spec/v3/section_spec.rb'
|
|
136
|
+
- 'spec/v3/td_spec.rb'
|
|
85
137
|
|
|
86
138
|
# Offense count: 1
|
|
87
139
|
Security/Open:
|
|
88
140
|
Exclude:
|
|
89
141
|
- 'Rakefile'
|
|
142
|
+
|
|
143
|
+
# Offense count: 1
|
|
144
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
145
|
+
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
|
|
146
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
|
|
147
|
+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
|
148
|
+
# FunctionalMethods: let, let!, subject, watch
|
|
149
|
+
# AllowedMethods: lambda, proc, it
|
|
150
|
+
Style/BlockDelimiters:
|
|
151
|
+
Exclude:
|
|
152
|
+
- 'spec/v3/cref_spec.rb'
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
**rfcxml** is a Ruby gem for parsing and generating IETF RFC XML v3 documents. It is part of the Metanorma ecosystem and provides bidirectional XML serialization using the lutaml-model framework.
|
|
8
|
+
|
|
9
|
+
## Development Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Install dependencies
|
|
13
|
+
bundle install
|
|
14
|
+
|
|
15
|
+
# Run all checks (tests + linting)
|
|
16
|
+
bundle exec rake
|
|
17
|
+
|
|
18
|
+
# Run tests only
|
|
19
|
+
bundle exec rake spec
|
|
20
|
+
bundle exec rspec # Run specific test file
|
|
21
|
+
bundle exec rspec spec/v3/rfc_spec.rb
|
|
22
|
+
|
|
23
|
+
# Run linting only
|
|
24
|
+
bundle exec rake rubocop
|
|
25
|
+
bundle exec rubocop --autocorrect # Auto-fix violations
|
|
26
|
+
|
|
27
|
+
# Interactive development console
|
|
28
|
+
bin/console
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Architecture
|
|
32
|
+
|
|
33
|
+
### Core Framework: lutaml-model
|
|
34
|
+
|
|
35
|
+
All XML elements are modeled as classes inheriting from `Lutaml::Model::Serializable`. This provides ActiveRecord-like serialization for XML with a declarative DSL:
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
class SomeElement < Lutaml::Model::Serializable
|
|
39
|
+
attribute :name, :string
|
|
40
|
+
attribute :child, ChildClass, collection: true
|
|
41
|
+
|
|
42
|
+
xml do
|
|
43
|
+
element "element-name"
|
|
44
|
+
map_attribute "name", to: :name
|
|
45
|
+
map_element "child", to: :child
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Module Structure
|
|
51
|
+
|
|
52
|
+
- `Rfcxml::V3` namespace contains all RFC XML v3 element models
|
|
53
|
+
- Each XML element has its own file in `lib/rfcxml/v3/`
|
|
54
|
+
- Models require their dependencies directly (e.g., `Rfc` requires `Front`, `Middle`, `Back`)
|
|
55
|
+
|
|
56
|
+
### Document Hierarchy
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
Rfc (root)
|
|
60
|
+
├── Front (metadata: title, authors, date, abstract)
|
|
61
|
+
├── Middle (body: sections)
|
|
62
|
+
└── Back (references, appendices)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Mixed Content
|
|
66
|
+
|
|
67
|
+
Some elements like `Section` support mixed content (text interspersed with child elements). Use `mixed: true` in the root declaration:
|
|
68
|
+
|
|
69
|
+
```ruby
|
|
70
|
+
xml do
|
|
71
|
+
element "section"
|
|
72
|
+
mixed_content
|
|
73
|
+
end
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Reference Schema
|
|
77
|
+
|
|
78
|
+
The `reference-docs/` directory contains the official RFC XML v3 schema files:
|
|
79
|
+
- `v3.rnc` - RelaxNG compact syntax (authoritative)
|
|
80
|
+
- `v3.xsd` - XML Schema Definition
|
|
81
|
+
|
|
82
|
+
## Testing
|
|
83
|
+
|
|
84
|
+
Tests perform round-trip parsing: parse XML → serialize back → verify valid XML structure using the `canon` gem for semantic comparison.
|
data/lib/rfcxml/v3/cref.rb
CHANGED
|
@@ -13,10 +13,10 @@ module Rfcxml
|
|
|
13
13
|
attribute :em, Em, collection: true
|
|
14
14
|
attribute :eref, Eref, collection: true
|
|
15
15
|
attribute :relref, Relref, collection: true
|
|
16
|
-
attribute :strong, Strong, collection: true
|
|
17
|
-
attribute :sub, Sub, collection: true
|
|
18
|
-
attribute :sup, Sup, collection: true
|
|
19
|
-
attribute :tt, Tt, collection: true
|
|
16
|
+
attribute :strong, "Rfcxml::V3::Strong", collection: true
|
|
17
|
+
attribute :sub, "Rfcxml::V3::Sub", collection: true
|
|
18
|
+
attribute :sup, "Rfcxml::V3::Sup", collection: true
|
|
19
|
+
attribute :tt, "Rfcxml::V3::Tt", collection: true
|
|
20
20
|
attribute :xref, Xref, collection: true
|
|
21
21
|
|
|
22
22
|
xml do
|
data/lib/rfcxml/v3/rfc.rb
CHANGED
|
@@ -48,6 +48,7 @@ module Rfcxml
|
|
|
48
48
|
attribute :front, Front
|
|
49
49
|
attribute :middle, Middle
|
|
50
50
|
attribute :back, Back
|
|
51
|
+
attribute :pi_settings, :hash
|
|
51
52
|
|
|
52
53
|
xml do
|
|
53
54
|
element "rfc"
|
|
@@ -80,6 +81,8 @@ module Rfcxml
|
|
|
80
81
|
%w[link front middle back].each do |element|
|
|
81
82
|
map_element element, to: element.to_sym
|
|
82
83
|
end
|
|
84
|
+
|
|
85
|
+
map_processing_instruction "rfc", to: :pi_settings
|
|
83
86
|
end
|
|
84
87
|
|
|
85
88
|
# Override to_xml to fix SVG elements
|
data/lib/rfcxml/v3/td.rb
CHANGED
|
@@ -12,22 +12,6 @@ module Rfcxml
|
|
|
12
12
|
attribute :align, :string,
|
|
13
13
|
values: %w[left center right]
|
|
14
14
|
|
|
15
|
-
# Normalize empty string colspan/rowspan to nil.
|
|
16
|
-
# Schema default for colspan/rowspan is "1", so empty string should not
|
|
17
|
-
# be serialized as an attribute. This ensures round-trip comparison
|
|
18
|
-
# treats rowspan="" (in source) as equivalent to absent rowspan.
|
|
19
|
-
module ColspanRowspanNormalizer
|
|
20
|
-
def colspan=(value)
|
|
21
|
-
super(value.to_s.empty? ? nil : value)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def rowspan=(value)
|
|
25
|
-
super(value.to_s.empty? ? nil : value)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
prepend ColspanRowspanNormalizer
|
|
30
|
-
|
|
31
15
|
attribute :artset, Artset, collection: true
|
|
32
16
|
attribute :artwork, Artwork, collection: true
|
|
33
17
|
attribute :dl, Dl, collection: true
|
|
@@ -56,8 +40,10 @@ module Rfcxml
|
|
|
56
40
|
|
|
57
41
|
map_content to: :content
|
|
58
42
|
map_attribute "anchor", to: :anchor
|
|
59
|
-
map_attribute "colspan", to: :colspan
|
|
60
|
-
|
|
43
|
+
map_attribute "colspan", to: :colspan,
|
|
44
|
+
value_map: { to: { empty: :empty } }
|
|
45
|
+
map_attribute "rowspan", to: :rowspan,
|
|
46
|
+
value_map: { to: { empty: :empty } }
|
|
61
47
|
map_attribute "align", to: :align
|
|
62
48
|
|
|
63
49
|
%w[artset artwork dl figure ol sourcecode t ul bcp14 br cref em eref
|
data/lib/rfcxml/version.rb
CHANGED
data/scripts/roundtrip_test.rb
CHANGED
|
@@ -38,6 +38,10 @@ class RoundTripTester
|
|
|
38
38
|
|
|
39
39
|
attr_reader :results_dir
|
|
40
40
|
|
|
41
|
+
def failed?
|
|
42
|
+
@results.any? { |r| %i[fail error].include?(r[:status]) }
|
|
43
|
+
end
|
|
44
|
+
|
|
41
45
|
def initialize(files:, threads: DEFAULT_THREADS, verbose: false)
|
|
42
46
|
@files = files
|
|
43
47
|
@threads = threads
|
|
@@ -358,4 +362,6 @@ if __FILE__ == $PROGRAM_NAME
|
|
|
358
362
|
|
|
359
363
|
tester = RoundTripTester.new(**options)
|
|
360
364
|
tester.run
|
|
365
|
+
|
|
366
|
+
exit 1 if tester.failed?
|
|
361
367
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rfcxml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.3
|
|
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-05-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|
|
@@ -52,6 +52,7 @@ files:
|
|
|
52
52
|
- ".rspec"
|
|
53
53
|
- ".rubocop.yml"
|
|
54
54
|
- ".rubocop_todo.yml"
|
|
55
|
+
- CLAUDE.md
|
|
55
56
|
- CODE_OF_CONDUCT.md
|
|
56
57
|
- Gemfile
|
|
57
58
|
- README.adoc
|