nokolexbor 0.3.2-x86-mingw32 → 0.3.3-x86-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: ab3000358a691830b406aaa6144934f7c92a7c368b19b46d34288ef58e84c080
4
- data.tar.gz: d9d12df4eab59e9d0ec351bea52a9295eaee9f9066142b5450d5b4557fa98d0b
3
+ metadata.gz: b9a79ff39442443b15408d7cf69d764305c070074a5afc793d6b940ca5cc74ea
4
+ data.tar.gz: 30543c046dc70f8bfb492ad475957ac9b7b6af337cd7c592555ac075c21f3468
5
5
  SHA512:
6
- metadata.gz: 90d08634350f0e3de69b38eee35442e8bcf0948a01b8e49df933f84c5b9adba4dd0c9ecafe9b323de4bdd3a599269b9e88195d65bd2b6d448cdf2f3a9dd2b26e
7
- data.tar.gz: e9e9d4199625432f0fbd6a353bad90b1c651db903a6edf87b4192056bfc9520bcd5e2373e40f3640d7bbdf124b274ee3da84a931d16856fb9e04d7b3ed55ac10
6
+ metadata.gz: 62125e7065e2653faf0a2d9ffabbc0089c7c69ec0bbd080cd7f0f5281e8e4254335cf0ed672b4bffbbcbf634fec5e66376d77b8ddf6abd66a225a8605bbff7d0
7
+ data.tar.gz: 498a0389415e8b821d267d477826fc178d7e7ce50680cd0adad370dcca6cac599a1010078d88e924ba8001a02774a1c00583991b8313a282732a0d453b74054e
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-mingw32
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