oga 1.2.2-java → 1.2.3-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e2b6fa7e733f0f4d9316f55c840a244f5979279
4
- data.tar.gz: 9f3308d6bd9ed1cc449365ed39eada71d2cdb16b
3
+ metadata.gz: ecc2ee704871348245514551a7d0438c6b9df1a3
4
+ data.tar.gz: 13b7226f94f4a49f5dea21a5d65d7a22bf14ab7d
5
5
  SHA512:
6
- metadata.gz: e3d282efad377ae5e59c0ec92e05cd2281efd80c2ad18b553398f5dd6ac70be74a94cd83c0e730fb14d466717bdaee09798e1defe16d1d67977114ebcd51a6f3
7
- data.tar.gz: adf5e877c4e5f5316441c033da20d158f85dd2d871f1e6c1b95b90a7267ffefc7e69b63bc984060a34293c9e49bf1535862c96b2b9b3a7168cbfdb54710f8b9c
6
+ metadata.gz: 43c266a0b1fcac304f462e8cbe9f347badcd463a2024366cf2369573ce2807f633a1e9ca0494bf63bfd46092b682842568e7321c7a66802a9aed48b824626960
7
+ data.tar.gz: b67b963872f590d85bf1c3a1582b809d043bd318d304d771e436bd8fcc34553a7fef39a7b53d67a8128c61cd60c51295429bcd3e9248b43df98fd07df385b63c
Binary file
@@ -1,3 +1,3 @@
1
1
  module Oga
2
- VERSION = '1.2.2'
2
+ VERSION = '1.2.3'
3
3
  end # Oga
@@ -42,10 +42,15 @@ module Oga
42
42
  # @param [Oga::XML::NodeSet] owner The owner of the set.
43
43
  #
44
44
  def initialize(nodes = [], owner = nil)
45
- @nodes = nodes
46
- @owner = owner
45
+ @nodes = nodes
46
+ @owner = owner
47
+ @existing = {}
47
48
 
48
- @nodes.each { |node| take_ownership(node) } if owner
49
+ @nodes.each do |node|
50
+ mark_existing(node)
51
+
52
+ take_ownership(node) if @owner
53
+ end
49
54
  end
50
55
 
51
56
  ##
@@ -103,11 +108,13 @@ module Oga
103
108
  # @param [Oga::XML::Node] node
104
109
  #
105
110
  def push(node)
106
- return if @nodes.include?(node)
111
+ return if exists?(node)
107
112
 
108
113
  @nodes << node
109
114
 
110
- take_ownership(node)
115
+ mark_existing(node)
116
+
117
+ take_ownership(node) if @owner
111
118
  end
112
119
 
113
120
  alias_method :<<, :push
@@ -118,11 +125,13 @@ module Oga
118
125
  # @param [Oga::XML::Node] node
119
126
  #
120
127
  def unshift(node)
121
- return if @nodes.include?(node)
128
+ return if exists?(node)
122
129
 
123
130
  @nodes.unshift(node)
124
131
 
125
- take_ownership(node)
132
+ mark_existing(node)
133
+
134
+ take_ownership(node) if @owner
126
135
  end
127
136
 
128
137
  ##
@@ -133,7 +142,11 @@ module Oga
133
142
  def shift
134
143
  node = @nodes.shift
135
144
 
136
- remove_ownership(node)
145
+ if node
146
+ unmark_existing(node)
147
+
148
+ remove_ownership(node) if @owner
149
+ end
137
150
 
138
151
  node
139
152
  end
@@ -146,7 +159,11 @@ module Oga
146
159
  def pop
147
160
  node = @nodes.pop
148
161
 
149
- remove_ownership(node)
162
+ if node
163
+ unmark_existing(node)
164
+
165
+ remove_ownership(node) if @owner
166
+ end
150
167
 
151
168
  node
152
169
  end
@@ -158,11 +175,13 @@ module Oga
158
175
  # @param [Oga::XML::Node] node
159
176
  #
160
177
  def insert(index, node)
161
- return if @nodes.include?(node)
178
+ return if exists?(node)
162
179
 
163
180
  @nodes.insert(index, node)
164
181
 
165
- take_ownership(node)
182
+ mark_existing(node)
183
+
184
+ take_ownership(node) if @owner
166
185
  end
167
186
 
168
187
  ##
@@ -257,7 +276,11 @@ module Oga
257
276
  def delete(node)
258
277
  removed = @nodes.delete(node)
259
278
 
260
- remove_ownership(removed) if removed
279
+ if removed
280
+ unmark_existing(removed)
281
+
282
+ remove_ownership(removed) if @owner
283
+ end
261
284
 
262
285
  removed
263
286
  end
@@ -317,7 +340,7 @@ module Oga
317
340
  # @param [Oga::XML::Node] node
318
341
  #
319
342
  def take_ownership(node)
320
- node.node_set = self if owner
343
+ node.node_set = self
321
344
  end
322
345
 
323
346
  ##
@@ -328,6 +351,22 @@ module Oga
328
351
  def remove_ownership(node)
329
352
  node.node_set = nil if node.node_set == self
330
353
  end
354
+
355
+ # @param [Oga::XML::Node|Oga::XML::Attribute] node
356
+ # @return [TrueClass|FalseClass]
357
+ def exists?(node)
358
+ @existing.key?(node)
359
+ end
360
+
361
+ # @param [Oga::XML::Node|Oga::XML::Attribute] node
362
+ def mark_existing(node)
363
+ @existing[node] = true
364
+ end
365
+
366
+ # @param [Oga::XML::Node|Oga::XML::Attribute] node
367
+ def unmark_existing(node)
368
+ @existing.delete(node)
369
+ end
331
370
  end # NodeSet
332
371
  end # XML
333
372
  end # Oga
@@ -1691,7 +1691,9 @@ module Oga
1691
1691
  def name_matches?(xml_node, name)
1692
1692
  return false unless xml_node.respond_to?(:name)
1693
1693
 
1694
- name == STAR ? true : xml_node.name == name
1694
+ return true if name == STAR
1695
+
1696
+ xml_node.name == name || xml_node.name.casecmp(name) == 0
1695
1697
  end
1696
1698
 
1697
1699
  ##
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oga
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: java
6
6
  authors:
7
7
  - Yorick Peterse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-14 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement