nokolexbor 0.3.2-x64-mingw32 → 0.3.3-x64-mingw32

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: 99150ff13df9107846b728c5e5671831bf55369b95807ccab622e6325a26ce8d
4
- data.tar.gz: cea9c9c19dd67f82430a6faf0a295de323397775d4feee5bc783bf7d8ec14707
3
+ metadata.gz: bf96f5d702ec86c586d572ceb17d3881f2473e47c965ac5de4bad9fffdb354dc
4
+ data.tar.gz: a3e4d040bf82985b3d841bb3e5b36d37ea4490e93255ffdc6a61cd315ee53b65
5
5
  SHA512:
6
- metadata.gz: 6d5efe7c91f775aab452c61607a593978727f6a245534c787c18ac32ec8920fe6e025d2415a27f74f60fa0fd5bef4e69f02e54287390254a0f3dedd2db47e026
7
- data.tar.gz: 53a48466dc564f5e8adef50bcff12c249edff7b84f16d55fe793f73745f78e8ba3a9fb4849d54de787028455788d58d93f248b3e8777cb2443042d8ec226cb1a
6
+ metadata.gz: 30fc1a3256f85fd806161dc9e3d63ef9612d364a7a15df8026ffdaae6a8cbaff17a5e4287b58786ccfea2ec05bc7a53803728b3e4383ad501cf77e06912ee13d
7
+ data.tar.gz: 055d31655593789ebb2e1789f03862bd1c929259295840907c4005d21e7274b6a79807b443f8ec71381f880943f72441f2a0483844aabbde11c44af3bcd9f63a
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: x64-mingw32
6
6
  authors:
7
7
  - Yicheng Zhou
@@ -51,6 +51,7 @@ files:
51
51
  - lib/nokolexbor/3.0/nokolexbor.so
52
52
  - lib/nokolexbor/attribute.rb
53
53
  - lib/nokolexbor/document.rb
54
+ - lib/nokolexbor/document_fragment.rb
54
55
  - lib/nokolexbor/node.rb
55
56
  - lib/nokolexbor/node_set.rb
56
57
  - lib/nokolexbor/version.rb