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: 301d8d022004d83c27be9117139de33ab99c01bde0e090571f537efd49b633e1
4
- data.tar.gz: 3e10a85285cbb20b2d028b4b38c72e54efff4a18c2e3c9947873da9fc3482441
3
+ metadata.gz: bce223e2aa302e281865260a318c1c1aa1f93192e66a9fb81b3d206d2e6c1f8d
4
+ data.tar.gz: 886bc04905d21fcfcf5536dc27c8f05edba5c0118e327a29d34b08686f30033a
5
5
  SHA512:
6
- metadata.gz: 732464027e20b3aac0974a1590318553bebeff61828f8aba0cec7c8b5f7e10de88b93e5d9dce26bf7964b6c1a54e6c8a984267e4791a9b371f56dc88b8c7cdab
7
- data.tar.gz: 6cb38269b61d86cfca3a059b9bd8761c90abb4136cb4eeeedb2e38ac32927d7d6b1d4fba01598467a5235571a6fc558d6c8d82452410862ade220aaf644c7a9e
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
- return nil if r.blank?
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
- m[0].to_i
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
- r = string_value(node, xpath)
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)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aranha
4
4
  module Parsers
5
- VERSION = '0.28.0'
5
+ VERSION = '0.29.0'
6
6
  end
7
7
  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.28.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-16 00:00:00.000000000 Z
11
+ date: 2026-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport