aranha-parsers 0.19.1 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aranha/parsers/html/base.rb +7 -0
- data/lib/aranha/parsers/html/node/default/miscellaneous_support.rb +23 -0
- data/lib/aranha/parsers/html/node/default/nodes_support.rb +30 -0
- data/lib/aranha/parsers/html/node/default.rb +3 -23
- data/lib/aranha/parsers/version.rb +1 -1
- metadata +6 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6020b51d20ef2c677664058978015a69c4ed80c15c7c169f300acaa5b5335a22
|
4
|
+
data.tar.gz: 44bfaaa2b28b7cacd935074b9f48bfaf9cf62e9d952f2744e8bb76fe4045a72f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1a926d3f7b051f17ee9df3c4642fcf9cf7707c9c9c70600d9a58be63bce9f80fdc35e589c41899365a854e0c506ddcf038cb96776761c2fb0916f7acd8e84da
|
7
|
+
data.tar.gz: c27820771a1fd288597218fc7af862c43a4eed9eb3d9c87454cc4da84814b8e270782507d16a697bd42ffc85c859b1a672978fbe02401ec4978fb81eb22cbb78
|
@@ -25,6 +25,13 @@ module Aranha
|
|
25
25
|
from_string(node.to_html)
|
26
26
|
end
|
27
27
|
|
28
|
+
# @param node [String]
|
29
|
+
# @param klass [String]
|
30
|
+
# @return [String]
|
31
|
+
def xpath_contains_class(klass, node = '@class')
|
32
|
+
"contains(concat(' ', normalize-space(#{node}), ' '), ' #{klass} ')"
|
33
|
+
end
|
34
|
+
|
28
35
|
# @param haystack [String]
|
29
36
|
# @param needle [String]
|
30
37
|
# @return [String]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/html/node/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Aranha
|
7
|
+
module Parsers
|
8
|
+
module Html
|
9
|
+
module Node
|
10
|
+
class Default < ::Aranha::Parsers::Html::Node::Base
|
11
|
+
module MiscellaneousSupport
|
12
|
+
# @param node [Nokogiri::XML::Node]
|
13
|
+
# @param xpath [String]
|
14
|
+
# @return [Boolean]
|
15
|
+
def boolean_value(node, xpath)
|
16
|
+
node_value(node, xpath).to_bool
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/html/node/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Aranha
|
7
|
+
module Parsers
|
8
|
+
module Html
|
9
|
+
module Node
|
10
|
+
class Default < ::Aranha::Parsers::Html::Node::Base
|
11
|
+
module NodesSupport
|
12
|
+
# @param node [Nokogiri::XML::Node]
|
13
|
+
# @param xpath [String]
|
14
|
+
# @return [Nokogiri::XML::NodeSet]
|
15
|
+
def node_set_value(node, xpath)
|
16
|
+
node.xpath(xpath)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param node [Nokogiri::XML::Node]
|
20
|
+
# @param xpath [String]
|
21
|
+
# @return [Nokogiri::XML::Node]
|
22
|
+
def node_value(node, xpath)
|
23
|
+
node.at_xpath(xpath)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -10,31 +10,11 @@ module Aranha
|
|
10
10
|
class Default < ::Aranha::Parsers::Html::Node::Base
|
11
11
|
require_sub __FILE__, include_modules: true
|
12
12
|
|
13
|
-
def join_value(node, xpath)
|
14
|
-
m = ''
|
15
|
-
node_set_value(node, xpath).each do |n|
|
16
|
-
m << n.text.strip
|
17
|
-
end
|
18
|
-
m
|
19
|
-
end
|
20
|
-
|
21
|
-
def duration_value(node, xpath)
|
22
|
-
m = /(\d+) m/.match(join_value(node, xpath))
|
23
|
-
m ? m[1].to_i : nil
|
24
|
-
end
|
25
|
-
|
26
|
-
# @param node [Nokogiri::XML::Node]
|
27
|
-
# @param xpath [String]
|
28
|
-
# @return [Nokogiri::XML::NodeSet]
|
29
|
-
def node_set_value(node, xpath)
|
30
|
-
node.xpath(xpath)
|
31
|
-
end
|
32
|
-
|
33
13
|
# @param node [Nokogiri::XML::Node]
|
34
14
|
# @param xpath [String]
|
35
|
-
# @return [
|
36
|
-
def
|
37
|
-
node
|
15
|
+
# @return [Boolean]
|
16
|
+
def boolean_value(node, xpath)
|
17
|
+
node_value(node, xpath).to_bool
|
38
18
|
end
|
39
19
|
end
|
40
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aranha-parsers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -50,20 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 0.3.2
|
53
|
+
version: '0.4'
|
57
54
|
type: :runtime
|
58
55
|
prerelease: false
|
59
56
|
version_requirements: !ruby/object:Gem::Requirement
|
60
57
|
requirements:
|
61
58
|
- - "~>"
|
62
59
|
- !ruby/object:Gem::Version
|
63
|
-
version: '0.
|
64
|
-
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 0.3.2
|
60
|
+
version: '0.4'
|
67
61
|
- !ruby/object:Gem::Dependency
|
68
62
|
name: eac_ruby_utils
|
69
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,6 +141,8 @@ files:
|
|
147
141
|
- lib/aranha/parsers/html/node.rb
|
148
142
|
- lib/aranha/parsers/html/node/base.rb
|
149
143
|
- lib/aranha/parsers/html/node/default.rb
|
144
|
+
- lib/aranha/parsers/html/node/default/miscellaneous_support.rb
|
145
|
+
- lib/aranha/parsers/html/node/default/nodes_support.rb
|
150
146
|
- lib/aranha/parsers/html/node/default/numeric_support.rb
|
151
147
|
- lib/aranha/parsers/html/node/default/string_support.rb
|
152
148
|
- lib/aranha/parsers/invalid_state_exception.rb
|