oga 3.1 → 3.4

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
  SHA256:
3
- metadata.gz: 7cbe3fa4c19b1995ca00c2efd90bb6052d08a5a874d98083ff647b5e150f96f8
4
- data.tar.gz: 8bc8e79907508eeceb1d5f176fb6df31c1037f2867f59cd00909dfb0891e7fef
3
+ metadata.gz: d59fc960905c257880ff37e28d05667cf6f8e8366c4f4dc9489992f7267be80a
4
+ data.tar.gz: 6a705ae14ac0488ae0cd9caeefdc28624ac9edb0cd45755c00f0b9f1857c5fcd
5
5
  SHA512:
6
- metadata.gz: 39358a1d0684dee4f428474361e5408a7a658099dbbdfc7794980c3aa7f10121db85f97f04201e3aa9f9cb98f5415e3cc2d28d60f8419a4368ed3a2f03629d9f
7
- data.tar.gz: 58bbbdfaac06cc266a8f9ed92ef71182b1fc4d599a68f41374b799af5457c92c9221dc42d9ffb6e23b47bc731d32c23245802c35928b3b270a891f5a84d48943
6
+ metadata.gz: b32f2033f4484bb8b2213c1c30726d5745cc3f5ff3de3b4001f3a969f34c0910a9620b3a95730ac2fc23e05dd997d8147b57cc51c960e787fbd2ec2093ffce50
7
+ data.tar.gz: 7849944d12cea80379a16b8bbd5e32e17b40694648a1842d0f8ee58caa2849f38ec3599f49bfa7412fd991c8d9394613f1fc12d1eabfcd204bdf62be4c9ab397
data/lib/oga/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Oga
2
- VERSION = '3.1'
2
+ VERSION = '3.4'
3
3
  end # Oga
@@ -46,6 +46,8 @@ module Oga
46
46
  # @param [Oga::XML::NodeSet|Array] nodes
47
47
  def children=(nodes)
48
48
  if nodes.is_a?(NodeSet)
49
+ nodes.owner = self
50
+ nodes.take_ownership_on_nodes
49
51
  @children = nodes
50
52
  else
51
53
  @children = NodeSet.new(nodes, self)
data/lib/oga/xml/node.rb CHANGED
@@ -49,6 +49,8 @@ module Oga
49
49
  # @param [Oga::XML::NodeSet|Array] nodes
50
50
  def children=(nodes)
51
51
  if nodes.is_a?(NodeSet)
52
+ nodes.owner = self
53
+ nodes.take_ownership_on_nodes
52
54
  @children = nodes
53
55
  else
54
56
  @children = NodeSet.new(nodes, self)
@@ -42,11 +42,7 @@ module Oga
42
42
  @owner = owner
43
43
  @existing = {}
44
44
 
45
- @nodes.each_with_index do |node, index|
46
- mark_existing(node)
47
-
48
- take_ownership(node, index) if @owner
49
- end
45
+ take_ownership_on_nodes
50
46
  end
51
47
 
52
48
  # Yields the supplied block for every node.
@@ -289,6 +285,14 @@ module Oga
289
285
  "NodeSet(#{values})"
290
286
  end
291
287
 
288
+ def take_ownership_on_nodes
289
+ @nodes.each_with_index do |node, index|
290
+ mark_existing(node)
291
+
292
+ take_ownership(node, index) if @owner
293
+ end
294
+ end
295
+
292
296
  private
293
297
 
294
298
  # Takes ownership of the given node. This only occurs when the current
@@ -63,8 +63,8 @@ module Oga
63
63
  #
64
64
  # @see [#xpath]
65
65
  # @return [Oga::XML::Node|Oga::XML::Attribute]
66
- def at_xpath(*args)
67
- result = xpath(*args)
66
+ def at_xpath(*args, namespaces: nil)
67
+ result = xpath(*args, namespaces: namespaces)
68
68
 
69
69
  result.is_a?(XML::NodeSet) ? result.first : result
70
70
  end
@@ -7,6 +7,8 @@ module Oga
7
7
  def to_xml
8
8
  Generator.new(self).to_xml
9
9
  end
10
+
11
+ alias_method :to_s, :to_xml
10
12
  end
11
13
  end
12
14
  end
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: '3.1'
4
+ version: '3.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yorick Peterse
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-08 00:00:00.000000000 Z
11
+ date: 2022-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast
@@ -210,7 +210,7 @@ homepage: https://gitlab.com/yorickpeterse/oga/
210
210
  licenses:
211
211
  - MPL-2.0
212
212
  metadata: {}
213
- post_install_message:
213
+ post_install_message:
214
214
  rdoc_options: []
215
215
  require_paths:
216
216
  - lib
@@ -225,8 +225,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
225
  - !ruby/object:Gem::Version
226
226
  version: '0'
227
227
  requirements: []
228
- rubygems_version: 3.0.6
229
- signing_key:
228
+ rubygems_version: 3.1.6
229
+ signing_key:
230
230
  specification_version: 4
231
231
  summary: Oga is an XML/HTML parser written in Ruby.
232
232
  test_files: []