nokolexbor 0.3.2-x64-mingw-ucrt → 0.3.3-x64-mingw-ucrt

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: 84dbcded2e705c7a97e6e2409e504aaa8d88f668a9a951e9d116bd80fa6187c3
4
- data.tar.gz: 5bf9ec35839e7736e75815e5f45f0d8f516c6b8a6ab69ba17e1a29caff8e3686
3
+ metadata.gz: b3a9ae41e4e72bc88b565954821978a8aceefd5cad7834addd14270aa97d974a
4
+ data.tar.gz: 965ae4b6706d44027dc96453bdcf75a8990257a6e00ec43cfc813a2aa622ee21
5
5
  SHA512:
6
- metadata.gz: dc908e49de45ba73f0a488a8e287231bfdc25447ce1fa8d543220effdc59c9e906b3bc621959b8d0acbaf70f5a302f9039cc8baf65b4db73f1260339662f5c56
7
- data.tar.gz: f321b363e12b9b7c30fb7fe4d8e1e581a643a2c15f6bad122bef70a6b7540eb61535a87d9ae17a1442fb4eadca0ed286365d1125ec07edccdb3472550d0fab4a
6
+ metadata.gz: 3c3a908f950c137e317a3030a9e2b0b63d7fd94b688e50a3deac249baff9f3c95aadcb735ec401e59bb28fa563320c7157574852724641ab6fbbf8c846b0846d
7
+ data.tar.gz: 59f4f3b30a2e77d04d4a716f765da0c243fdca766409076fe373a219450240e18e002e8240dc63bc1bb2fe95262ae24f96b958d3f16f5c9813c3c6679f57b330
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: x64-mingw-ucrt
6
6
  authors:
7
7
  - Yicheng Zhou
@@ -49,6 +49,7 @@ files:
49
49
  - lib/nokolexbor/3.1/nokolexbor.so
50
50
  - lib/nokolexbor/attribute.rb
51
51
  - lib/nokolexbor/document.rb
52
+ - lib/nokolexbor/document_fragment.rb
52
53
  - lib/nokolexbor/node.rb
53
54
  - lib/nokolexbor/node_set.rb
54
55
  - lib/nokolexbor/version.rb