rxerces 0.5.0 → 0.6.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
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +11 -0
- data/benchmarks/README.md +68 -0
- data/benchmarks/css_benchmark.rb +115 -0
- data/benchmarks/parse_benchmark.rb +103 -0
- data/benchmarks/run_all.rb +25 -0
- data/benchmarks/serialization_benchmark.rb +93 -0
- data/benchmarks/traversal_benchmark.rb +149 -0
- data/benchmarks/xpath_benchmark.rb +100 -0
- data/ext/rxerces/rxerces.cpp +385 -52
- data/lib/rxerces/version.rb +1 -1
- data/rxerces.gemspec +1 -1
- data/spec/document_spec.rb +58 -0
- data/spec/node_spec.rb +57 -0
- data/spec/rxerces_shared.rb +1 -1
- data/tmp/arm64-darwin24/rxerces/3.4.7/rxerces.bundle.dSYM/Contents/Info.plist +20 -0
- data/tmp/arm64-darwin24/rxerces/3.4.7/rxerces.bundle.dSYM/Contents/Resources/Relocations/aarch64/rxerces.bundle.yml +5 -0
- data.tar.gz.sig +0 -0
- metadata +11 -2
- metadata.gz.sig +0 -0
data/lib/rxerces/version.rb
CHANGED
data/rxerces.gemspec
CHANGED
data/spec/document_spec.rb
CHANGED
|
@@ -176,4 +176,62 @@ RSpec.describe RXerces::XML::Document do
|
|
|
176
176
|
expect(result.first.text).to eq('New content')
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
|
+
|
|
180
|
+
describe "#errors" do
|
|
181
|
+
it "returns empty array for valid XML" do
|
|
182
|
+
doc = RXerces::XML::Document.parse(simple_xml)
|
|
183
|
+
expect(doc.errors).to eq([])
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it "returns empty array for complex valid XML" do
|
|
187
|
+
doc = RXerces::XML::Document.parse(complex_xml)
|
|
188
|
+
expect(doc.errors).to eq([])
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
context "with malformed XML" do
|
|
192
|
+
it "raises error and provides line/column information for unclosed tags" do
|
|
193
|
+
expect {
|
|
194
|
+
RXerces::XML::Document.parse('<root><item>test</root>')
|
|
195
|
+
}.to raise_error(RuntimeError, /Fatal error at line \d+, column \d+/)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it "raises error with detailed message for multiple errors" do
|
|
199
|
+
expect {
|
|
200
|
+
RXerces::XML::Document.parse('<root><item>test</item><unclosed>')
|
|
201
|
+
}.to raise_error(RuntimeError, /Fatal error at line/)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it "raises error for completely invalid XML" do
|
|
205
|
+
expect {
|
|
206
|
+
RXerces::XML::Document.parse('not xml at all')
|
|
207
|
+
}.to raise_error(RuntimeError, /Fatal error at line/)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
it "raises error for mismatched tags" do
|
|
211
|
+
expect {
|
|
212
|
+
RXerces::XML::Document.parse('<root><item>test</other></root>')
|
|
213
|
+
}.to raise_error(RuntimeError, /Fatal error at line/)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
context "error message format" do
|
|
218
|
+
it "includes line number in error message" do
|
|
219
|
+
expect {
|
|
220
|
+
RXerces::XML::Document.parse('<root><bad>')
|
|
221
|
+
}.to raise_error(RuntimeError, /line \d+/)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
it "includes column number in error message" do
|
|
225
|
+
expect {
|
|
226
|
+
RXerces::XML::Document.parse('<root><bad>')
|
|
227
|
+
}.to raise_error(RuntimeError, /column \d+/)
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it "describes the error type" do
|
|
231
|
+
expect {
|
|
232
|
+
RXerces::XML::Document.parse('<root><item>test</root>')
|
|
233
|
+
}.to raise_error(RuntimeError, /expected end of tag/)
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
end
|
|
179
237
|
end
|
data/spec/node_spec.rb
CHANGED
|
@@ -552,6 +552,63 @@ RSpec.describe RXerces::XML::Node do
|
|
|
552
552
|
xml_output = simple_doc.to_s
|
|
553
553
|
expect(xml_output).to include("Content")
|
|
554
554
|
end
|
|
555
|
+
|
|
556
|
+
context "with nodes from different documents" do
|
|
557
|
+
it "raises error when adding node from different document" do
|
|
558
|
+
doc1 = RXerces::XML::Document.parse('<root><item>one</item></root>')
|
|
559
|
+
doc2 = RXerces::XML::Document.parse('<other><item>two</item></other>')
|
|
560
|
+
|
|
561
|
+
root1 = doc1.root
|
|
562
|
+
item2 = doc2.root.children.find { |n| n.is_a?(RXerces::XML::Element) }
|
|
563
|
+
|
|
564
|
+
expect {
|
|
565
|
+
root1.add_child(item2)
|
|
566
|
+
}.to raise_error(RuntimeError, /belongs to a different document/)
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
it "provides helpful error message mentioning importNode" do
|
|
570
|
+
doc1 = RXerces::XML::Document.parse('<root></root>')
|
|
571
|
+
doc2 = RXerces::XML::Document.parse('<other><child/></other>')
|
|
572
|
+
|
|
573
|
+
expect {
|
|
574
|
+
doc1.root.add_child(doc2.root.children.first)
|
|
575
|
+
}.to raise_error(RuntimeError, /importNode/)
|
|
576
|
+
end
|
|
577
|
+
end
|
|
578
|
+
|
|
579
|
+
context "when child already has a parent" do
|
|
580
|
+
it "moves node from one parent to another (detaches automatically)" do
|
|
581
|
+
doc = RXerces::XML::Document.parse('<root><parent1><child>text</child></parent1><parent2/></root>')
|
|
582
|
+
parent1 = doc.xpath('//parent1').first
|
|
583
|
+
parent2 = doc.xpath('//parent2').first
|
|
584
|
+
child = doc.xpath('//child').first
|
|
585
|
+
|
|
586
|
+
# Verify initial state
|
|
587
|
+
expect(parent1.children.select { |n| n.is_a?(RXerces::XML::Element) }.length).to eq(1)
|
|
588
|
+
expect(parent2.children.select { |n| n.is_a?(RXerces::XML::Element) }.length).to eq(0)
|
|
589
|
+
|
|
590
|
+
# Move child from parent1 to parent2
|
|
591
|
+
parent2.add_child(child)
|
|
592
|
+
|
|
593
|
+
# Child should now be under parent2, not parent1
|
|
594
|
+
expect(parent1.children.select { |n| n.is_a?(RXerces::XML::Element) }.length).to eq(0)
|
|
595
|
+
expect(parent2.children.select { |n| n.is_a?(RXerces::XML::Element) }.length).to eq(1)
|
|
596
|
+
expect(doc.xpath('//parent2/child').length).to eq(1)
|
|
597
|
+
expect(doc.xpath('//parent1/child').length).to eq(0)
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
it "preserves node content when moving" do
|
|
601
|
+
doc = RXerces::XML::Document.parse('<root><a><item>content</item></a><b/></root>')
|
|
602
|
+
a = doc.xpath('//a').first
|
|
603
|
+
b = doc.xpath('//b').first
|
|
604
|
+
item = doc.xpath('//item').first
|
|
605
|
+
|
|
606
|
+
b.add_child(item)
|
|
607
|
+
|
|
608
|
+
expect(item.text).to eq('content')
|
|
609
|
+
expect(doc.xpath('//b/item').first.text).to eq('content')
|
|
610
|
+
end
|
|
611
|
+
end
|
|
555
612
|
end
|
|
556
613
|
|
|
557
614
|
describe "#remove" do
|
data/spec/rxerces_shared.rb
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>English</string>
|
|
7
|
+
<key>CFBundleIdentifier</key>
|
|
8
|
+
<string>com.apple.xcode.dsym.rxerces.bundle</string>
|
|
9
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
10
|
+
<string>6.0</string>
|
|
11
|
+
<key>CFBundlePackageType</key>
|
|
12
|
+
<string>dSYM</string>
|
|
13
|
+
<key>CFBundleSignature</key>
|
|
14
|
+
<string>????</string>
|
|
15
|
+
<key>CFBundleShortVersionString</key>
|
|
16
|
+
<string>1.0</string>
|
|
17
|
+
<key>CFBundleVersion</key>
|
|
18
|
+
<string>1</string>
|
|
19
|
+
</dict>
|
|
20
|
+
</plist>
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rxerces
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel J. Berger
|
|
@@ -92,6 +92,13 @@ files:
|
|
|
92
92
|
- LICENSE
|
|
93
93
|
- README.md
|
|
94
94
|
- Rakefile
|
|
95
|
+
- benchmarks/README.md
|
|
96
|
+
- benchmarks/css_benchmark.rb
|
|
97
|
+
- benchmarks/parse_benchmark.rb
|
|
98
|
+
- benchmarks/run_all.rb
|
|
99
|
+
- benchmarks/serialization_benchmark.rb
|
|
100
|
+
- benchmarks/traversal_benchmark.rb
|
|
101
|
+
- benchmarks/xpath_benchmark.rb
|
|
95
102
|
- certs/djberg96_pub.pem
|
|
96
103
|
- examples/basic_usage.rb
|
|
97
104
|
- examples/schema_example.rb
|
|
@@ -114,6 +121,8 @@ files:
|
|
|
114
121
|
- spec/schema_spec.rb
|
|
115
122
|
- spec/spec_helper.rb
|
|
116
123
|
- spec/xpath_spec.rb
|
|
124
|
+
- tmp/arm64-darwin24/rxerces/3.4.7/rxerces.bundle.dSYM/Contents/Info.plist
|
|
125
|
+
- tmp/arm64-darwin24/rxerces/3.4.7/rxerces.bundle.dSYM/Contents/Resources/Relocations/aarch64/rxerces.bundle.yml
|
|
117
126
|
homepage: http://github.com/djberg96/rxerces
|
|
118
127
|
licenses:
|
|
119
128
|
- MIT
|
|
@@ -141,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
141
150
|
- !ruby/object:Gem::Version
|
|
142
151
|
version: '0'
|
|
143
152
|
requirements: []
|
|
144
|
-
rubygems_version: 3.
|
|
153
|
+
rubygems_version: 3.7.2
|
|
145
154
|
specification_version: 4
|
|
146
155
|
summary: Nokogiri-compatible XML library using Xerces-C
|
|
147
156
|
test_files:
|
metadata.gz.sig
CHANGED
|
Binary file
|