ox 2.13.1 → 2.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/README.md +32 -5
- data/ext/ox/builder.c +5 -1
- data/ext/ox/dump.c +7 -19
- data/ext/ox/extconf.rb +12 -34
- data/ext/ox/gen_load.c +18 -96
- data/ext/ox/hash_load.c +39 -12
- data/ext/ox/obj_load.c +35 -64
- data/ext/ox/ox.c +60 -48
- data/ext/ox/ox.h +7 -15
- data/ext/ox/parse.c +7 -20
- data/ext/ox/sax.c +21 -91
- data/ext/ox/sax.h +1 -3
- data/ext/ox/sax_as.c +2 -6
- data/ext/ox/sax_buf.c +1 -1
- data/ext/ox/special.c +4 -3
- data/lib/ox/element.rb +21 -11
- data/lib/ox/version.rb +1 -1
- metadata +6 -6
data/lib/ox/element.rb
CHANGED
@@ -44,6 +44,7 @@ module Ox
|
|
44
44
|
@nodes = []
|
45
45
|
end
|
46
46
|
alias name value
|
47
|
+
alias name= value=
|
47
48
|
|
48
49
|
# Returns the Element's nodes array. These are the sub-elements of this
|
49
50
|
# Element.
|
@@ -114,17 +115,8 @@ module Ox
|
|
114
115
|
# matching name will be yielded to. If the cond is a Hash then the
|
115
116
|
# keys-value pairs in the cond must match the child attribute values with
|
116
117
|
# the same keys. Any other cond type will yield to nothing.
|
117
|
-
def each(cond=nil)
|
118
|
-
|
119
|
-
nodes.each { |n| yield(n) }
|
120
|
-
else
|
121
|
-
cond = cond.to_s if cond.is_a?(Symbol)
|
122
|
-
if cond.is_a?(String)
|
123
|
-
nodes.each { |n| yield(n) if n.is_a?(Element) && cond == n.name }
|
124
|
-
elsif cond.is_a?(Hash)
|
125
|
-
nodes.each { |n| yield(n) if n.is_a?(Element) && n.attr_match(cond) }
|
126
|
-
end
|
127
|
-
end
|
118
|
+
def each(cond=nil, &block)
|
119
|
+
build_enumerator(cond).each(&block)
|
128
120
|
end
|
129
121
|
|
130
122
|
# Returns an array of Nodes or Strings that correspond to the locations
|
@@ -412,6 +404,24 @@ module Ox
|
|
412
404
|
|
413
405
|
private
|
414
406
|
|
407
|
+
# Builds an enumerator for use in `#each` call
|
408
|
+
#
|
409
|
+
# - +cond+ [Hash, String, nil] an element filter
|
410
|
+
def build_enumerator(cond)
|
411
|
+
if cond.nil?
|
412
|
+
nodes.each
|
413
|
+
else
|
414
|
+
cond = cond.to_s if cond.is_a?(Symbol)
|
415
|
+
Enumerator.new do |yielder|
|
416
|
+
if cond.is_a?(String)
|
417
|
+
nodes.each { |n| yielder.yield(n) if n.is_a?(Element) && cond == n.name }
|
418
|
+
elsif cond.is_a?(Hash)
|
419
|
+
nodes.each { |n| yielder.yield(n) if n.is_a?(Element) && n.attr_match(cond) }
|
420
|
+
end
|
421
|
+
end
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
415
425
|
# Removes recursively children for nodes and sub_nodes
|
416
426
|
#
|
417
427
|
# - +found+ [Array] An array of Ox::Element
|
data/lib/ox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "A fast XML parser and object serializer that uses only standard C lib.\n\nOptimized
|
14
14
|
XML (Ox), as the name implies was written to provide speed optimized\nXML handling.
|
@@ -76,7 +76,7 @@ homepage: http://www.ohler.com/ox
|
|
76
76
|
licenses:
|
77
77
|
- MIT
|
78
78
|
metadata: {}
|
79
|
-
post_install_message:
|
79
|
+
post_install_message:
|
80
80
|
rdoc_options:
|
81
81
|
- "--main"
|
82
82
|
- README.md
|
@@ -98,8 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
102
|
-
signing_key:
|
101
|
+
rubygems_version: 3.2.3
|
102
|
+
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: A fast XML parser and object serializer.
|
105
105
|
test_files: []
|