nokolexbor 0.3.2-arm64-darwin → 0.3.3-arm64-darwin

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: 4e5a7bc5521955742ec2b981f546431fa550e180025782c57ad7b156ac24f8d2
4
- data.tar.gz: '095aae93a9e931dfba6b26e1273512246506737546695c474f222510d94e11ed'
3
+ metadata.gz: 0d3990d88b4adf5ec56a011b36d842c8add5c45ada73978dec977ceaab7b6d47
4
+ data.tar.gz: b9e84140c6263736043f34f4a3b46af5a1eac0f5bda23d26c4558cbd9849ee4c
5
5
  SHA512:
6
- metadata.gz: dc7cf5446ea341e121b8dfa2d04079e343126c12ae3f79328abbdfe7d86ca798389445f5d6941714302589476e752e7667ca6e7a403bd923427be0b7829bdb37
7
- data.tar.gz: e13ce217566e7c52b7cda596ab67dabc698a99a7f34e5c745344728c368ea5c5fe0815771bf560829928b90e3346c74d2e10493644241da0feff6da217ffc3a3
6
+ metadata.gz: a09f67d4f44889030a1d910ec1c5d2c8f6f6fb6d29e0892ca6e8f00de1d8ff8d0af1e46a3fe2c969c0d0d961a9d2a083acc772b7b51eafd4548000392e08beba
7
+ data.tar.gz: 576bebf4dbc21f0b785d7cf5064c2424f96ef0613e3d8544530734e30db57d4fbaff7978fbec31d231cca4c436a3e270f5241c29129d63cd9a27eedaaa84044f
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: arm64-darwin
6
6
  authors:
7
7
  - Yicheng Zhou
@@ -52,6 +52,7 @@ files:
52
52
  - lib/nokolexbor/3.1/nokolexbor.bundle
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