rxerces 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a1129744191c92a7a15cb783fc74cbccfd2dbeedfbcf5741e295686c38b8108
4
- data.tar.gz: 0b03758412cff12acccf3232f0f135ec69e0eaabcb6aa015091a44ed75e53081
3
+ metadata.gz: 957f224ac2dc4d0d487906c04554c8d956db8bb0dd3e3ad0c19b2b265b6d1e82
4
+ data.tar.gz: 5ca62e02d42580a8223497115b62468af9ce322947588c8530bafd66b942eedf
5
5
  SHA512:
6
- metadata.gz: e2ba8796e66c0163d1f3bd9ae91d2fde804b462b39fd750e8f600b073e1ad02e36a2978cd533ea7256a9ad7b7d906c4462927bc609b1f59ac7c33f39b5423b83
7
- data.tar.gz: 9b7b522fc2c5f203a2de65ba2d112ef644cf84fb18128503432ab37240f4b31cdc7acde58c83d00e5b17e006433e595aa19f46f2a5a11345c1778c55a76c1820
6
+ metadata.gz: c66c5fe4f359ab15e900c917d304c4c69a217239bc97883eefad8424777a5e804c963e9e25eb289fc1a2278d8ed931a058af1274efdaef8d6b7854a9fc4b731e
7
+ data.tar.gz: af997049f398faca77f2976c3931fbe82a9ee1c9d90795f0d65435613032f0a0e76913cc1667e75bb4ff95e260a9a79e1dd22838fd912f8e1e9a46976780a41b
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.6.1 - 20-Dec-2025
2
+ * Added more Nokogiri compatibility methods: children, first_element_child,
3
+ last_element_child, elements, at_xpath.
4
+
1
5
  ## 0.6.0 - 17-Dec-2025
2
6
  * Some internal refactoring, better initialization, some better string
3
7
  handling, that sort of stuff.
@@ -608,6 +608,97 @@ static VALUE document_create_element(VALUE self, VALUE name) {
608
608
  return Qnil;
609
609
  }
610
610
 
611
+ // document.children - returns all children (elements, text, comments, etc.)
612
+ static VALUE document_children(VALUE self) {
613
+ DocumentWrapper* wrapper;
614
+ TypedData_Get_Struct(self, DocumentWrapper, &document_type, wrapper);
615
+
616
+ VALUE children = rb_ary_new();
617
+
618
+ if (!wrapper->doc) {
619
+ return children;
620
+ }
621
+
622
+ DOMNodeList* child_nodes = wrapper->doc->getChildNodes();
623
+ XMLSize_t count = child_nodes->getLength();
624
+
625
+ for (XMLSize_t i = 0; i < count; i++) {
626
+ DOMNode* child = child_nodes->item(i);
627
+ rb_ary_push(children, wrap_node(child, self));
628
+ }
629
+
630
+ return children;
631
+ }
632
+
633
+ // document.element_children - returns only element children (no text nodes, comments, etc.)
634
+ static VALUE document_element_children(VALUE self) {
635
+ DocumentWrapper* wrapper;
636
+ TypedData_Get_Struct(self, DocumentWrapper, &document_type, wrapper);
637
+
638
+ VALUE children = rb_ary_new();
639
+
640
+ if (!wrapper->doc) {
641
+ return children;
642
+ }
643
+
644
+ DOMNodeList* child_nodes = wrapper->doc->getChildNodes();
645
+ XMLSize_t count = child_nodes->getLength();
646
+
647
+ for (XMLSize_t i = 0; i < count; i++) {
648
+ DOMNode* child = child_nodes->item(i);
649
+ if (child->getNodeType() == DOMNode::ELEMENT_NODE) {
650
+ rb_ary_push(children, wrap_node(child, self));
651
+ }
652
+ }
653
+
654
+ return children;
655
+ }
656
+
657
+ // document.first_element_child - returns first element child
658
+ static VALUE document_first_element_child(VALUE self) {
659
+ DocumentWrapper* wrapper;
660
+ TypedData_Get_Struct(self, DocumentWrapper, &document_type, wrapper);
661
+
662
+ if (!wrapper->doc) {
663
+ return Qnil;
664
+ }
665
+
666
+ DOMNodeList* child_nodes = wrapper->doc->getChildNodes();
667
+ XMLSize_t count = child_nodes->getLength();
668
+
669
+ for (XMLSize_t i = 0; i < count; i++) {
670
+ DOMNode* child = child_nodes->item(i);
671
+ if (child->getNodeType() == DOMNode::ELEMENT_NODE) {
672
+ return wrap_node(child, self);
673
+ }
674
+ }
675
+
676
+ return Qnil;
677
+ }
678
+
679
+ // document.last_element_child - returns last element child
680
+ static VALUE document_last_element_child(VALUE self) {
681
+ DocumentWrapper* wrapper;
682
+ TypedData_Get_Struct(self, DocumentWrapper, &document_type, wrapper);
683
+
684
+ if (!wrapper->doc) {
685
+ return Qnil;
686
+ }
687
+
688
+ DOMNodeList* child_nodes = wrapper->doc->getChildNodes();
689
+ XMLSize_t count = child_nodes->getLength();
690
+
691
+ // Search backwards for last element
692
+ for (XMLSize_t i = count; i > 0; i--) {
693
+ DOMNode* child = child_nodes->item(i - 1);
694
+ if (child->getNodeType() == DOMNode::ELEMENT_NODE) {
695
+ return wrap_node(child, self);
696
+ }
697
+ }
698
+
699
+ return Qnil;
700
+ }
701
+
611
702
  #ifdef HAVE_XALAN
612
703
  // Helper function to execute XPath using Xalan for full XPath 1.0 support
613
704
  static VALUE execute_xpath_with_xalan(DOMNode* context_node, const char* xpath_str, VALUE doc_ref) {
@@ -782,6 +873,19 @@ static VALUE document_xpath(VALUE self, VALUE path) {
782
873
  #endif
783
874
  }
784
875
 
876
+ // document.at_xpath(path) - returns first matching node or nil
877
+ static VALUE document_at_xpath(VALUE self, VALUE path) {
878
+ VALUE nodeset = document_xpath(self, path);
879
+ NodeSetWrapper* wrapper;
880
+ TypedData_Get_Struct(nodeset, NodeSetWrapper, &nodeset_type, wrapper);
881
+
882
+ if (RARRAY_LEN(wrapper->nodes_array) == 0) {
883
+ return Qnil;
884
+ }
885
+
886
+ return rb_ary_entry(wrapper->nodes_array, 0);
887
+ }
888
+
785
889
  // document.css(selector) - Convert CSS to XPath and execute
786
890
  static VALUE document_css(VALUE self, VALUE selector) {
787
891
  Check_Type(selector, T_STRING);
@@ -1104,6 +1208,65 @@ static VALUE node_element_children(VALUE self) {
1104
1208
  return children;
1105
1209
  }
1106
1210
 
1211
+ // node.first_element_child - returns first element child
1212
+ static VALUE node_first_element_child(VALUE self) {
1213
+ NodeWrapper* wrapper;
1214
+ TypedData_Get_Struct(self, NodeWrapper, &node_type, wrapper);
1215
+
1216
+ if (!wrapper->node) {
1217
+ return Qnil;
1218
+ }
1219
+
1220
+ VALUE doc_ref = wrapper->doc_ref;
1221
+ DOMNodeList* child_nodes = wrapper->node->getChildNodes();
1222
+ XMLSize_t count = child_nodes->getLength();
1223
+
1224
+ for (XMLSize_t i = 0; i < count; i++) {
1225
+ DOMNode* child = child_nodes->item(i);
1226
+ if (child->getNodeType() == DOMNode::ELEMENT_NODE) {
1227
+ return wrap_node(child, doc_ref);
1228
+ }
1229
+ }
1230
+
1231
+ return Qnil;
1232
+ }
1233
+
1234
+ // node.last_element_child - returns last element child
1235
+ static VALUE node_last_element_child(VALUE self) {
1236
+ NodeWrapper* wrapper;
1237
+ TypedData_Get_Struct(self, NodeWrapper, &node_type, wrapper);
1238
+
1239
+ if (!wrapper->node) {
1240
+ return Qnil;
1241
+ }
1242
+
1243
+ VALUE doc_ref = wrapper->doc_ref;
1244
+ DOMNodeList* child_nodes = wrapper->node->getChildNodes();
1245
+ XMLSize_t count = child_nodes->getLength();
1246
+
1247
+ // Search backwards for last element
1248
+ for (XMLSize_t i = count; i > 0; i--) {
1249
+ DOMNode* child = child_nodes->item(i - 1);
1250
+ if (child->getNodeType() == DOMNode::ELEMENT_NODE) {
1251
+ return wrap_node(child, doc_ref);
1252
+ }
1253
+ }
1254
+
1255
+ return Qnil;
1256
+ }
1257
+
1258
+ // node.document - returns the document that owns this node
1259
+ static VALUE node_document(VALUE self) {
1260
+ NodeWrapper* wrapper;
1261
+ TypedData_Get_Struct(self, NodeWrapper, &node_type, wrapper);
1262
+
1263
+ if (!wrapper->node) {
1264
+ return Qnil;
1265
+ }
1266
+
1267
+ return wrapper->doc_ref;
1268
+ }
1269
+
1107
1270
  // node.parent
1108
1271
  static VALUE node_parent(VALUE self) {
1109
1272
  NodeWrapper* wrapper;
@@ -2264,12 +2427,19 @@ static VALUE document_validate(VALUE self, VALUE rb_schema) {
2264
2427
  rb_define_alias(rb_cDocument, "to_xml", "to_s");
2265
2428
  rb_define_method(rb_cDocument, "inspect", RUBY_METHOD_FUNC(document_inspect), 0);
2266
2429
  rb_define_method(rb_cDocument, "xpath", RUBY_METHOD_FUNC(document_xpath), 1);
2430
+ rb_define_method(rb_cDocument, "at_xpath", RUBY_METHOD_FUNC(document_at_xpath), 1);
2431
+ rb_define_alias(rb_cDocument, "at", "at_xpath");
2267
2432
  rb_define_method(rb_cDocument, "css", RUBY_METHOD_FUNC(document_css), 1);
2268
2433
  rb_define_method(rb_cDocument, "at_css", RUBY_METHOD_FUNC(document_at_css), 1);
2269
2434
  rb_define_method(rb_cDocument, "encoding", RUBY_METHOD_FUNC(document_encoding), 0);
2270
2435
  rb_define_method(rb_cDocument, "text", RUBY_METHOD_FUNC(document_text), 0);
2271
2436
  rb_define_alias(rb_cDocument, "content", "text");
2272
2437
  rb_define_method(rb_cDocument, "create_element", RUBY_METHOD_FUNC(document_create_element), 1);
2438
+ rb_define_method(rb_cDocument, "children", RUBY_METHOD_FUNC(document_children), 0);
2439
+ rb_define_method(rb_cDocument, "element_children", RUBY_METHOD_FUNC(document_element_children), 0);
2440
+ rb_define_alias(rb_cDocument, "elements", "element_children");
2441
+ rb_define_method(rb_cDocument, "first_element_child", RUBY_METHOD_FUNC(document_first_element_child), 0);
2442
+ rb_define_method(rb_cDocument, "last_element_child", RUBY_METHOD_FUNC(document_last_element_child), 0);
2273
2443
 
2274
2444
  rb_cNode = rb_define_class_under(rb_mXML, "Node", rb_cObject);
2275
2445
  rb_undef_alloc_func(rb_cNode);
@@ -2288,6 +2458,9 @@ static VALUE document_validate(VALUE self, VALUE rb_schema) {
2288
2458
  rb_define_method(rb_cNode, "children", RUBY_METHOD_FUNC(node_children), 0);
2289
2459
  rb_define_method(rb_cNode, "element_children", RUBY_METHOD_FUNC(node_element_children), 0);
2290
2460
  rb_define_alias(rb_cNode, "elements", "element_children");
2461
+ rb_define_method(rb_cNode, "first_element_child", RUBY_METHOD_FUNC(node_first_element_child), 0);
2462
+ rb_define_method(rb_cNode, "last_element_child", RUBY_METHOD_FUNC(node_last_element_child), 0);
2463
+ rb_define_method(rb_cNode, "document", RUBY_METHOD_FUNC(node_document), 0);
2291
2464
  rb_define_method(rb_cNode, "parent", RUBY_METHOD_FUNC(node_parent), 0);
2292
2465
  rb_define_method(rb_cNode, "ancestors", RUBY_METHOD_FUNC(node_ancestors), -1);
2293
2466
  rb_define_method(rb_cNode, "attributes", RUBY_METHOD_FUNC(node_attributes), 0);
@@ -1,3 +1,3 @@
1
1
  module RXerces
2
- VERSION = "0.6.0".freeze
2
+ VERSION = "0.6.1".freeze
3
3
  end
data/rxerces.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "rxerces"
3
- spec.version = "0.6.0"
3
+ spec.version = "0.6.1"
4
4
  spec.author = "Daniel J. Berger"
5
5
  spec.email = "djberg96@gmail.com"
6
6
  spec.cert_chain = ["certs/djberg96_pub.pem"]
@@ -4,7 +4,7 @@ require 'rxerces'
4
4
 
5
5
  RSpec.shared_examples RXerces do
6
6
  example 'version number is set to the expected value' do
7
- expect(RXerces::VERSION).to eq('0.6.0')
7
+ expect(RXerces::VERSION).to eq('0.6.1')
8
8
  expect(RXerces::VERSION).to be_frozen
9
9
  end
10
10
  end
@@ -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>
@@ -0,0 +1,5 @@
1
+ ---
2
+ triple: 'arm64-apple-darwin'
3
+ binary-path: rxerces.bundle
4
+ relocations: []
5
+ ...
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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -121,6 +121,8 @@ files:
121
121
  - spec/schema_spec.rb
122
122
  - spec/spec_helper.rb
123
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
124
126
  homepage: http://github.com/djberg96/rxerces
125
127
  licenses:
126
128
  - MIT
@@ -148,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
150
  - !ruby/object:Gem::Version
149
151
  version: '0'
150
152
  requirements: []
151
- rubygems_version: 3.6.9
153
+ rubygems_version: 3.7.2
152
154
  specification_version: 4
153
155
  summary: Nokogiri-compatible XML library using Xerces-C
154
156
  test_files:
metadata.gz.sig CHANGED
Binary file