aranha-parsers 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bce223e2aa302e281865260a318c1c1aa1f93192e66a9fb81b3d206d2e6c1f8d
|
|
4
|
+
data.tar.gz: 886bc04905d21fcfcf5536dc27c8f05edba5c0118e327a29d34b08686f30033a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 383b4c9df2bdb587ae6d594ad43130c925aba0dff5915fa807b130672f6c32f7053690919aa2f090578be9fa153bba55cf12d95a7a3fb757eef00d5fa85b70c8
|
|
7
|
+
data.tar.gz: 48d76b6907e16067ae1220664712dd80b802fd0d984c14f38913808597f2153161518be256191765e73bc2e2650f6e866f3cb91010d03a4a9ec9802c13825cd9
|
|
@@ -6,6 +6,10 @@ module Aranha
|
|
|
6
6
|
module Node
|
|
7
7
|
class Default < ::Aranha::Parsers::Html::Node::Base
|
|
8
8
|
module NumericSupport
|
|
9
|
+
INTEGER_PARSER = /\d+/.to_parser do |m|
|
|
10
|
+
m[0].to_i
|
|
11
|
+
end
|
|
12
|
+
|
|
9
13
|
# @param node [Nokogiri::XML::Element]
|
|
10
14
|
# @param xpath [String]
|
|
11
15
|
# @return [Float]
|
|
@@ -62,26 +66,33 @@ module Aranha
|
|
|
62
66
|
decimal_dot_optional_value(node, xpath).to_i
|
|
63
67
|
end
|
|
64
68
|
|
|
69
|
+
# @param node [Nokogiri::XML::Node]
|
|
70
|
+
# @param xpath [String]
|
|
71
|
+
# @return [Integer]
|
|
65
72
|
def integer_value(node, xpath)
|
|
66
73
|
r = string_value(node, xpath)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
m = /\d+/.match(r)
|
|
70
|
-
raise "Integer not found in \"#{r}\"" unless m
|
|
74
|
+
raise "String value is blank (\"#{r}\")" if r.blank?
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
INTEGER_PARSER.parse!(r)
|
|
73
77
|
end
|
|
74
78
|
|
|
79
|
+
# @param node [Nokogiri::XML::Node]
|
|
80
|
+
# @param xpath [String]
|
|
81
|
+
# @return [Integer, nil]
|
|
75
82
|
def integer_optional_value(node, xpath)
|
|
76
|
-
|
|
77
|
-
m = /\d+/.match(r)
|
|
78
|
-
m ? m[0].to_i : nil
|
|
83
|
+
INTEGER_PARSER.parse(string_value(node, xpath))
|
|
79
84
|
end
|
|
80
85
|
|
|
86
|
+
# @param node [Nokogiri::XML::Node]
|
|
87
|
+
# @param xpath [String]
|
|
88
|
+
# @return [Float]
|
|
81
89
|
def float_value(node, xpath)
|
|
82
90
|
parse_float(node, xpath, true)
|
|
83
91
|
end
|
|
84
92
|
|
|
93
|
+
# @param node [Nokogiri::XML::Node]
|
|
94
|
+
# @param xpath [String]
|
|
95
|
+
# @return [Float, nil]
|
|
85
96
|
def float_optional_value(node, xpath)
|
|
86
97
|
parse_float(node, xpath, false)
|
|
87
98
|
end
|
|
@@ -104,6 +115,10 @@ module Aranha
|
|
|
104
115
|
|
|
105
116
|
private
|
|
106
117
|
|
|
118
|
+
# @param node [Nokogiri::XML::Node]
|
|
119
|
+
# @param xpath [String]
|
|
120
|
+
# @param required [Boolean]
|
|
121
|
+
# @return [Float, nil]
|
|
107
122
|
def parse_float(node, xpath, required)
|
|
108
123
|
s = string_value(node, xpath)
|
|
109
124
|
m = /\d+(?:[.,](\d+))?/.match(s)
|
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.29.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: 2026-05-
|
|
11
|
+
date: 2026-05-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|