nokolexbor 0.2.6 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nokolexbor
4
- class NodeSet < Node
4
+ class NodeSet < Nokolexbor::Node
5
5
  include Enumerable
6
6
 
7
7
  def self.new(document, list = [])
@@ -54,16 +54,17 @@ module Nokolexbor
54
54
  alias_method :inner_text, :content
55
55
  alias_method :to_str, :content
56
56
 
57
- def inner_html
58
- self.map(&:inner_html).join
57
+ def inner_html(*args)
58
+ self.map { |n| n.inner_html(*args) }.join
59
59
  end
60
60
 
61
- def outer_html
62
- self.map(&:outer_html).join
61
+ def outer_html(*args)
62
+ self.map { |n| n.outer_html(*args) }.join
63
63
  end
64
64
 
65
65
  alias_method :to_s, :outer_html
66
66
  alias_method :to_html, :outer_html
67
+ alias_method :serialize, :outer_html
67
68
 
68
69
  def remove
69
70
  self.each(&:remove)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nokolexbor
4
- VERSION = '0.2.6'
4
+ VERSION = '0.3.1'
5
5
  end
data/lib/nokolexbor.rb CHANGED
@@ -1,6 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'nokolexbor/nokolexbor'
3
+ begin
4
+ # pre-compiled extension by rake-compiler is located inside lib/nokolexbor/<ruby_version>/
5
+ RUBY_VERSION =~ /(\d+\.\d+)/
6
+ require "nokolexbor/#{Regexp.last_match(1)}/nokolexbor"
7
+ rescue LoadError => e
8
+ if /GLIBC/.match?(e.message)
9
+ warn(<<~EOM)
10
+ ERROR: It looks like you're trying to use Nokolexbor as a precompiled native gem on a system
11
+ with an unsupported version of glibc.
12
+ #{e.message}
13
+ If that's the case, then please install Nokolexbor via the `ruby` platform gem:
14
+ gem install nokolexbor --platform=ruby
15
+ or:
16
+ bundle config set force_ruby_platform true
17
+ EOM
18
+ raise e
19
+ end
20
+
21
+ require 'nokolexbor/nokolexbor'
22
+ end
23
+
4
24
  require 'nokolexbor/version'
5
25
  require 'nokolexbor/node'
6
26
  require 'nokolexbor/document'
@@ -31,7 +31,7 @@ index 398d1bb..b35bfab 100644
31
31
  {"after", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_AFTER], 5, 0},
32
32
  {"first-letter", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_FIRST_LETTER], 12, 0},
33
33
  - {NULL, NULL, 0, 0},
34
- + {"text", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_TEXT], 4, 0},
34
+ + {"text", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_TEXT], 4, 0},
35
35
  {NULL, NULL, 0, 0},
36
36
  {"grammar-error", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_GRAMMAR_ERROR], 13, 0},
37
37
  {"before", (void *) &lxb_css_selectors_pseudo_data_pseudo_element[LXB_CSS_SELECTOR_PSEUDO_ELEMENT_BEFORE], 6, 0},
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokolexbor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yicheng Zhou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-22 00:00:00.000000000 Z
11
+ date: 2022-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.0'
41
- description: Nokolexbor is a high performance HTML5 parser, with support for both
41
+ description: Nokolexbor is a high-performance HTML5 parser, with support for both
42
42
  CSS selectors and XPath. It's API is designed to be compatible with Nokogiri.
43
43
  email: zyc9012@gmail.com
44
44
  executables: []
@@ -79,9 +79,12 @@ files:
79
79
  - ext/nokolexbor/libxml/xpathInternals.h
80
80
  - ext/nokolexbor/libxml/xpointer.h
81
81
  - ext/nokolexbor/memory.c
82
+ - ext/nokolexbor/nl_cdata.c
83
+ - ext/nokolexbor/nl_comment.c
82
84
  - ext/nokolexbor/nl_document.c
83
85
  - ext/nokolexbor/nl_node.c
84
86
  - ext/nokolexbor/nl_node_set.c
87
+ - ext/nokolexbor/nl_text.c
85
88
  - ext/nokolexbor/nl_xpath_context.c
86
89
  - ext/nokolexbor/nokolexbor.c
87
90
  - ext/nokolexbor/nokolexbor.h
@@ -555,5 +558,5 @@ requirements: []
555
558
  rubygems_version: 3.0.3.1
556
559
  signing_key:
557
560
  specification_version: 4
558
- summary: High performance HTML5 parser, with support for both CSS selectors and XPath.
561
+ summary: High-performance HTML5 parser, with support for both CSS selectors and XPath.
559
562
  test_files: []