moxml 0.5.46 → 0.5.47

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: 3b15f3ffeac134fbaa674a8e2970ae5606dd1e08985f288d01c48323ffeca4f1
4
- data.tar.gz: 43f616e34f485d21bbc431cd42da7347e404647a71e0e84af697e205e24067a1
3
+ metadata.gz: 83f4ac58d2c22de225ec143ff3e78eb95e3460863b8fb1d67e8230a872bfad2a
4
+ data.tar.gz: c7401f4154a32e534a1c6a53f067a25406b16056de651eec8e768ac04c602dcc
5
5
  SHA512:
6
- metadata.gz: 7007190eea32272f8be0de72b5a11f9b4d66cc0108cff530986443012a46814a886b34f925649593139c3d0cd7d4bf13d91d4088ae19be71ad150cc8464436de
7
- data.tar.gz: f967159613aa7c650d3d58c05b1dc7cb5376d975c01496e69aabc6f3c8d5631fcd9bb8dcb3c05320b3e345cf44fdd5cce922da0ca38079c4d7c322e39fb9dd72
6
+ metadata.gz: d0ad7a04cbac82f8195be3be4318ee7d381974a812c7c2fce45110778875abfcb0be7ebb0c8e19339ddf2c2d8d9f4bd575254062b492a9cf4ad35072d8fe67fd
7
+ data.tar.gz: 301188cc44df6af9339502db3694651cc2a69238e3c222f6c0cda92393e72b80d5353cca335671be6b6560d5d64da4c32ad3bc4484f91d12239ddebf677e6aec
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gemspec
9
9
  gem "benchmark"
10
10
  gem "benchmark-ips"
11
11
  gem "get_process_mem"
12
- gem "leptris", "~> 1.9.174"
12
+ gem "leptris", "~> 1.9.174.1"
13
13
  gem "libxml-ruby", "~> 5.0"
14
14
  gem "nokogiri", "~> 1.18"
15
15
  gem "openssl", "~> 3.0"
data/lib/moxml/element.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moxml
4
- class Element < Node
4
+ # Instance behavior for Moxml::Element, extracted so the leptris
5
+ # adapter can extend natives with it in place (issue #230); the
6
+ # class remains the consumer-facing contract.
7
+ module ElementBehavior
5
8
  def name
6
9
  # The adapter read is an FFI call plus (on several adapters) a
7
10
  # defensive string copy; names only change through name= and
@@ -359,4 +362,8 @@ module Moxml
359
362
  context.bump_namespace_scope_generation
360
363
  end
361
364
  end
365
+
366
+ class Element < Node
367
+ include ElementBehavior
368
+ end
362
369
  end
data/lib/moxml/node.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moxml
4
- class Node
4
+ # Instance behavior for Moxml::Node, extracted so the leptris
5
+ # adapter can extend natives with it in place (issue #230); the
6
+ # class remains the consumer-facing contract and the wrap factory.
7
+ module NodeBehavior
5
8
  include XmlUtils
6
9
  include Enumerable
7
10
 
@@ -441,37 +444,6 @@ module Moxml
441
444
  nil
442
445
  end
443
446
 
444
- # Registry mapping node type symbols to wrapper classes.
445
- # Built lazily to avoid load-order issues with subclasses.
446
- def self.node_type_map
447
- @node_type_map ||= {
448
- element: Element,
449
- text: Text,
450
- cdata: Cdata,
451
- comment: Comment,
452
- processing_instruction: ProcessingInstruction,
453
- document: Document,
454
- declaration: Declaration,
455
- doctype: Doctype,
456
- attribute: Attribute,
457
- entity_reference: EntityReference,
458
- }.freeze
459
- end
460
-
461
- def self.wrap(node, context)
462
- return nil if node.nil?
463
-
464
- cached = context.wrapper_for(node)
465
- return cached if cached
466
-
467
- adapter = adapter(context)
468
- type = adapter.node_type(node)
469
- klass = node_type_map[type] || self
470
-
471
- klass.new(node, context, adapter, type)
472
- .tap { |wrapper| context.register_wrapper(node, wrapper) }
473
- end
474
-
475
447
  # Internal: Set the parent node for cache invalidation tracking.
476
448
  # Called by NodeSet, Document, Element when establishing parent-child
477
449
  # relationships. Public to allow cross-class usage within Moxml internals.
@@ -485,12 +457,6 @@ module Moxml
485
457
 
486
458
  protected
487
459
 
488
- def self.adapter(context)
489
- context.config.adapter
490
- end
491
-
492
- # Invalidate cached children. Called by mutation methods
493
- # and by Element attribute/namespace caches.
494
460
  def invalidate_children_cache!
495
461
  @children = nil
496
462
  end
@@ -545,4 +511,44 @@ module Moxml
545
511
  xml.gsub(/\r?\n/, line_ending)
546
512
  end
547
513
  end
514
+
515
+ class Node
516
+ include NodeBehavior
517
+
518
+ def self.node_type_map
519
+ @node_type_map ||= {
520
+ element: Element,
521
+ text: Text,
522
+ cdata: Cdata,
523
+ comment: Comment,
524
+ processing_instruction: ProcessingInstruction,
525
+ document: Document,
526
+ declaration: Declaration,
527
+ doctype: Doctype,
528
+ attribute: Attribute,
529
+ entity_reference: EntityReference,
530
+ }.freeze
531
+ end
532
+
533
+ def self.wrap(node, context)
534
+ return nil if node.nil?
535
+
536
+ cached = context.wrapper_for(node)
537
+ return cached if cached
538
+
539
+ adapter = adapter(context)
540
+ type = adapter.node_type(node)
541
+ klass = node_type_map[type] || self
542
+
543
+ klass.new(node, context, adapter, type)
544
+ .tap { |wrapper| context.register_wrapper(node, wrapper) }
545
+ end
546
+
547
+ def self.adapter(context)
548
+ context.config.adapter
549
+ end
550
+
551
+ # Invalidate cached children. Called by mutation methods
552
+ # and by Element attribute/namespace caches.
553
+ end
548
554
  end
data/lib/moxml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moxml
4
- VERSION = "0.5.46"
4
+ VERSION = "0.5.47"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.46
4
+ version: 0.5.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.