nokolexbor 0.3.2-x86_64-darwin → 0.3.3-x86_64-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: 643714048497a0e912335327ed7f21270dabacc9bd6eb3b5a80619e07d80f471
4
- data.tar.gz: 477fe7e93c8099d17b918cc5ec8bd308ab7b65537246cefbcbaafdbf8af24435
3
+ metadata.gz: cead1d5973dbabeb2bac9e3e413d21e7dbe4e36e42e58fdf22ad110e02f3decf
4
+ data.tar.gz: 443c22b64508e785863c7e552ead72cc00f71369b216f6ea38d2e29d10bb4f8a
5
5
  SHA512:
6
- metadata.gz: 8c0f49471e4db5159f2358ca1884c2792c496c55a5ae5eae109db89b773f44755942b78e077ea0751c8575c5613b40e32069fbcb604f28f0232332a5c980da6d
7
- data.tar.gz: 439cacd2f57207e3b8225a893309ee1e764ff0512e041fa6ff20ca85216e9c9520d3df3be9f433653b8e56ffe955d3de920ed54e983a69d57f487b252591f546
6
+ metadata.gz: 82efd32a9058e2e3ee63e1215dddfa3bb24fbe11a81d50f795738d10406b0d09eed48d00e301aab44796124150e7cf3d6cfd11295d833f0edfda3b21a50a5bb5
7
+ data.tar.gz: abce68297cb6cdfd144291d1ad40b8c1c5d16b512400890e5405eedf16976e3d8434a79838cab2690ebb54763f3770c996c1c4b5926b5196efb1ed25f3116524
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-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