ox 2.9.0 → 2.9.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
- data/CHANGELOG.md +4 -0
- data/lib/ox/element.rb +17 -7
- data/lib/ox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeeadfb226235eca22604cef667feaa8e0331bbe101596394dd9f308cc1095e4
|
4
|
+
data.tar.gz: 91ce6eac0ca75791f106246eff0456f79e21fd5782bc8cad1235b58f9639a0be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53054044ddf3c9d7addc505391e0eb2061d1a2f73e35ca69cea7216e523ce89cce5c6ae8a0f3f836dec9c78fa17861c366d4fe627f32289fba3bc04bb4eeda6d
|
7
|
+
data.tar.gz: 560ef09372d68fdb43182a8725c80ebecbc8cc778b6b64feb1c316bff47880ea1f5be2cf45528dc6c7f6078a9ffb15c493d4f39fa416c57fb55872da9f5c203e
|
data/CHANGELOG.md
CHANGED
data/lib/ox/element.rb
CHANGED
@@ -10,9 +10,9 @@ module Ox
|
|
10
10
|
# sub elements or attributes simply by name. Repeating elements with the
|
11
11
|
# same name can be referenced with an element count as well. A few examples
|
12
12
|
# should explain the 'easy' API more clearly.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# *Example*
|
15
|
-
#
|
15
|
+
#
|
16
16
|
# doc = Ox.parse(%{
|
17
17
|
# <?xml?>
|
18
18
|
# <People>
|
@@ -26,7 +26,7 @@ module Ox
|
|
26
26
|
# </Person>
|
27
27
|
# </People>
|
28
28
|
# })
|
29
|
-
#
|
29
|
+
#
|
30
30
|
# doc.People.Person.given.text
|
31
31
|
# => "Peter"
|
32
32
|
# doc.People.Person(1).given.text
|
@@ -35,7 +35,7 @@ module Ox
|
|
35
35
|
# => "58"
|
36
36
|
class Element < Node
|
37
37
|
include HasAttrs
|
38
|
-
|
38
|
+
|
39
39
|
# Creates a new Element with the specified name.
|
40
40
|
# - +name+ [String] name of the Element
|
41
41
|
def initialize(name)
|
@@ -44,7 +44,7 @@ module Ox
|
|
44
44
|
@nodes = []
|
45
45
|
end
|
46
46
|
alias name value
|
47
|
-
|
47
|
+
|
48
48
|
# Returns the Element's nodes array. These are the sub-elements of this
|
49
49
|
# Element.
|
50
50
|
# *return* [Array] all child Nodes.
|
@@ -63,6 +63,16 @@ module Ox
|
|
63
63
|
self
|
64
64
|
end
|
65
65
|
|
66
|
+
# Prepend a Node to the Element's nodes array. Returns the element itself
|
67
|
+
# so multiple appends can be chained together.
|
68
|
+
# - +node+ [Node] Node to prepend to the nodes array
|
69
|
+
def prepend_child(node)
|
70
|
+
raise "argument to << must be a String or Ox::Node." unless node.is_a?(String) or node.is_a?(Node)
|
71
|
+
@nodes = [] if !instance_variable_defined?(:@nodes) or @nodes.nil?
|
72
|
+
@nodes.unshift(node)
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
66
76
|
# Returns true if this Object and other are of the same type and have the
|
67
77
|
# equivalent value and the equivalent elements otherwise false is returned.
|
68
78
|
# - +other+ [Object] Object compare _self_ to.
|
@@ -74,7 +84,7 @@ module Ox
|
|
74
84
|
true
|
75
85
|
end
|
76
86
|
alias == eql?
|
77
|
-
|
87
|
+
|
78
88
|
# Returns the first String in the elements nodes array or nil if there is
|
79
89
|
# no String node.
|
80
90
|
def text()
|
@@ -168,7 +178,7 @@ module Ox
|
|
168
178
|
end
|
169
179
|
found
|
170
180
|
end
|
171
|
-
|
181
|
+
|
172
182
|
# Handles the 'easy' API that allows navigating a simple XML by
|
173
183
|
# referencing elements and attributes by name.
|
174
184
|
# - +id+ [Symbol] element or attribute name
|
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.9.
|
4
|
+
version: 2.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-14 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
|
14
14
|
\ \nOptimized XML (Ox), as the name implies was written to provide speed
|