nokolexbor 0.3.2-x86_64-linux → 0.3.3-x86_64-linux

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: f551e41377e49aa9e17cbb77df849a1319fc9a8c7699b7c50d74ee3fa25080e1
4
- data.tar.gz: 69fdd6ab8361b62d8a2e97aee0aa60010e6b010c847e60bd73b34ac555e6c58e
3
+ metadata.gz: c895511e9adc328d15ad25c7efc571e565a7bddf2580e970398c774c05e78503
4
+ data.tar.gz: ef7446f5afa9b8a7cef77268e2a9e1f67c3aaed62b6a225732134debd71ad539
5
5
  SHA512:
6
- metadata.gz: c29a23ba8a00b57bda6ac9b3e32edffe4830363dee6e0f3c41f56a6a69eb63ba59ca175b007e93e6eee33bac64c3ef2514260467fb87cec330f558e6d7f5ba65
7
- data.tar.gz: 353ce400f7dcb0f752fff16bc7a0ae8f86c3bc190b1b0813a1cd076a06a1b41ed325c8ed57c70a18632b67d4cedcf7fa4523411eb3fddef24119e515f6749c64
6
+ metadata.gz: a7b7f27b07d05964adfac448fd31348693c03e2577e45cd8ba3ab4e2028755a732c71db30a5a0f56e935dc5fba5f11b1fb3f0a87762ab356004578c024d64478
7
+ data.tar.gz: 3713237c751de5fd1a1a549b158657df56afe39dce62ecec34a0ebbef1422bccb8ef7a65a76e2401db14a42e0f74ab1ca40a88583033dbf595d00750d8eeabc5
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nokolexbor
4
+ class DocumentFragment < Nokolexbor::Node
5
+ def self.parse(tags)
6
+ new(Nokolexbor::Document.new, tags, nil)
7
+ end
8
+
9
+ def initialize(document, tags = nil, ctx = nil)
10
+ return self unless tags
11
+
12
+ ctx ||= document
13
+ node_set = ctx.parse(tags)
14
+ node_set.each { |child| child.parent = self } unless node_set.empty?
15
+ nil
16
+ end
17
+
18
+ def name
19
+ "#document-fragment"
20
+ end
21
+
22
+ alias_method :outer_html, :inner_html
23
+ alias_method :to_html, :outer_html
24
+ alias_method :to_s, :outer_html
25
+ alias_method :serialize, :outer_html
26
+
27
+ def fragment(data)
28
+ document.fragment(data)
29
+ end
30
+ end
31
+ end
@@ -182,6 +182,10 @@ module Nokolexbor
182
182
  end
183
183
  end
184
184
 
185
+ def fragment(tags)
186
+ Nokolexbor::DocumentFragment.new(document, tags, self)
187
+ end
188
+
185
189
  alias_method :inner_html=, :children=
186
190
 
187
191
  def css(*args)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nokolexbor
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
data/lib/nokolexbor.rb CHANGED
@@ -25,6 +25,7 @@ require 'nokolexbor/version'
25
25
  require 'nokolexbor/node'
26
26
  require 'nokolexbor/document'
27
27
  require 'nokolexbor/node_set'
28
+ require 'nokolexbor/document_fragment'
28
29
  require 'nokolexbor/attribute'
29
30
  require 'nokolexbor/xpath'
30
31
  require 'nokolexbor/xpath_context'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokolexbor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Yicheng Zhou
@@ -52,6 +52,7 @@ files:
52
52
  - lib/nokolexbor/3.1/nokolexbor.so
53
53
  - lib/nokolexbor/attribute.rb
54
54
  - lib/nokolexbor/document.rb
55
+ - lib/nokolexbor/document_fragment.rb
55
56
  - lib/nokolexbor/node.rb
56
57
  - lib/nokolexbor/node_set.rb
57
58
  - lib/nokolexbor/version.rb