aranha-parsers 0.16.0 → 0.17.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: c023094e51e5188e1979f5ab406b595a93b58006c656ccf7bb55609d1b828472
|
4
|
+
data.tar.gz: 1dab0c5d8cb5b000949c3484db3f30494cd893e1f82f194627ae622ece43a457
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a3da7fef40ee10d63806ae268939285b3eb7778ff2d4fe5570ce305ddb7b2ee9d07abc5cd9f31c7e79b484fa807bb57aa2dd04bd5a46f76251cf5f677576ba9
|
7
|
+
data.tar.gz: f96f07f064028911ae1723f97e1cb8543fe44f2e2813e35b70048894788a3a47130e464cef662fa60d75ba07d030eade04fba54b48a04fb6df6c20553622ef32
|
@@ -9,6 +9,34 @@ module Aranha
|
|
9
9
|
module Node
|
10
10
|
class Default < ::Aranha::Parsers::Html::Node::Base
|
11
11
|
module NumericSupport
|
12
|
+
# @param node [Nokogiri::XML::Element]
|
13
|
+
# @param xpath [String]
|
14
|
+
# @return [Float]
|
15
|
+
def decimal_comma_value(node, xpath)
|
16
|
+
parse_decimal_comma(node, xpath, true)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param node [Nokogiri::XML::Element]
|
20
|
+
# @param xpath [String]
|
21
|
+
# @return [Float, nil]
|
22
|
+
def decimal_comma_optional_value(node, xpath)
|
23
|
+
parse_decimal_comma(node, xpath, false)
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param node [Nokogiri::XML::Element]
|
27
|
+
# @param xpath [String]
|
28
|
+
# @return [Float]
|
29
|
+
def decimal_dot_value(node, xpath)
|
30
|
+
parse_decimal_dot(node, xpath, true)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param node [Nokogiri::XML::Element]
|
34
|
+
# @param xpath [String]
|
35
|
+
# @return [Float, nil]
|
36
|
+
def decimal_dot_optional_value(node, xpath)
|
37
|
+
parse_decimal_dot(node, xpath, false)
|
38
|
+
end
|
39
|
+
|
12
40
|
def integer_value(node, xpath)
|
13
41
|
r = string_value(node, xpath)
|
14
42
|
return nil if r.blank?
|
@@ -33,12 +61,20 @@ module Aranha
|
|
33
61
|
parse_float(node, xpath, false)
|
34
62
|
end
|
35
63
|
|
64
|
+
# @deprecated Use {#decimal_dot_value} instead.
|
65
|
+
# @param node [Nokogiri::XML::Element]
|
66
|
+
# @param xpath [String]
|
67
|
+
# @return [Float]
|
36
68
|
def us_decimal_value(node, xpath)
|
37
|
-
|
69
|
+
decimal_dot_value(node, xpath)
|
38
70
|
end
|
39
71
|
|
72
|
+
# @deprecated Use {#decimal_dot_optional_value} instead.
|
73
|
+
# @param node [Nokogiri::XML::Element]
|
74
|
+
# @param xpath [String]
|
75
|
+
# @return [Float, nil]
|
40
76
|
def us_decimal_optional_value(node, xpath)
|
41
|
-
|
77
|
+
decimal_dot_optional_value(node, xpath)
|
42
78
|
end
|
43
79
|
|
44
80
|
private
|
@@ -53,15 +89,38 @@ module Aranha
|
|
53
89
|
end
|
54
90
|
end
|
55
91
|
|
56
|
-
|
92
|
+
# @param node [Nokogiri::XML::Element]
|
93
|
+
# @param xpath [String]
|
94
|
+
# @param required [Boolean]
|
95
|
+
# @param separator [String]
|
96
|
+
# @param delimiter [String]
|
97
|
+
# @return [Float, nil]
|
98
|
+
def parse_decimal(node, xpath, required, separator, delimiter)
|
57
99
|
s = string_value(node, xpath)
|
58
|
-
m = /\d+(?:[
|
100
|
+
m = /\d+(?:[#{::Regexp.quote(separator + delimiter)}](\d+))?/.match(s)
|
59
101
|
if m
|
60
|
-
m[0].delete(
|
102
|
+
m[0].delete(delimiter).to_f
|
61
103
|
elsif required
|
62
|
-
raise "
|
104
|
+
raise "decimal [Separator=\"#{separator}, Delimiter=\"#{delimiter}\"] value not " \
|
105
|
+
"found in \"#{s}\""
|
63
106
|
end
|
64
107
|
end
|
108
|
+
|
109
|
+
# @param node [Nokogiri::XML::Element]
|
110
|
+
# @param xpath [String]
|
111
|
+
# @param required [Boolean]
|
112
|
+
# @return [Float, nil]
|
113
|
+
def parse_decimal_dot(node, xpath, required)
|
114
|
+
parse_decimal(node, xpath, required, '.', ',')
|
115
|
+
end
|
116
|
+
|
117
|
+
# @param node [Nokogiri::XML::Element]
|
118
|
+
# @param xpath [String]
|
119
|
+
# @param required [Boolean]
|
120
|
+
# @return [Float, nil]
|
121
|
+
def parse_decimal_comma(node, xpath, required)
|
122
|
+
parse_decimal(node, xpath, required, ',', '.')
|
123
|
+
end
|
65
124
|
end
|
66
125
|
end
|
67
126
|
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.17.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-03-
|
11
|
+
date: 2023-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|