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 +4 -4
- data/Gemfile +1 -1
- data/lib/moxml/element.rb +8 -1
- data/lib/moxml/node.rb +44 -38
- data/lib/moxml/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83f4ac58d2c22de225ec143ff3e78eb95e3460863b8fb1d67e8230a872bfad2a
|
|
4
|
+
data.tar.gz: c7401f4154a32e534a1c6a53f067a25406b16056de651eec8e768ac04c602dcc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d0ad7a04cbac82f8195be3be4318ee7d381974a812c7c2fce45110778875abfcb0be7ebb0c8e19339ddf2c2d8d9f4bd575254062b492a9cf4ad35072d8fe67fd
|
|
7
|
+
data.tar.gz: 301188cc44df6af9339502db3694651cc2a69238e3c222f6c0cda92393e72b80d5353cca335671be6b6560d5d64da4c32ad3bc4484f91d12239ddebf677e6aec
|
data/Gemfile
CHANGED
data/lib/moxml/element.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Moxml
|
|
4
|
-
|
|
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
|
-
|
|
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