addressfinder 1.15.0 → 1.16.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: c5898fc54f3fcd543748761e03afc308e2f0de4d071c4a507c1d25a3d59f34fd
4
- data.tar.gz: 894ba815fb72c6b4e6b340fc44204b376fd04d510a27abe8878e0fa5e5fb2c77
3
+ metadata.gz: '0365876ccfbc2b618dd2e417b9d2fa238eaee83f8e1c0afa17230c3895f3542e'
4
+ data.tar.gz: a76840892fae1cdd10c646031edc4ff8f7675d499e0c21e7d7e7c73ebf63c35c
5
5
  SHA512:
6
- metadata.gz: a12cb1500ce95ca0c64857ac7b8d37957704c51c24da9b86557884c926caa9acee0007f14ae409f7a424f5d53b251383afa7bec92c2d2017ccfed5091a91e83c
7
- data.tar.gz: 4e18036778cd7eeaf4178e099bf037963efbf667ee18ac5c7425349dc5f96108d67be76c802839dce66d8b04c312f88935ff55b79f4d807d4a72e905c63e936f
6
+ metadata.gz: c9fd2bc3220f84afdaa24c4075594dda01a846b8670ced3d5a4a019529e0995488b6981ccd8a28609ed759a3da9598cd0c81133f61a73519dd64f27b03809136
7
+ data.tar.gz: 386b3217887a2c3601a2290e2638f38989592cc33688eedde74df030afad8af7ed70ae867a39c8a9f65d03b4634b902b93175546f5f346aa0932ade795b89b68
data/CHANGELOG.md CHANGED
@@ -1,7 +1,13 @@
1
+ # Addressfinder 1.16.0 (September 2025) #
2
+
3
+ * Add CGI as dependency for Ruby 3.5+
4
+ * Add batch capability to Phone Numbers verification
5
+ * Don't enforce ssl as part of Net::HTTP configuration
6
+
1
7
  # Addressfinder 1.15.0 (March 2025) #
2
8
 
3
9
  * Automatically skip empty strings within Batch verification
4
- * Mark unverified addressses as false within Batch verification
10
+ * Mark unverified addresses as false within Batch verification
5
11
 
6
12
  # Addressfinder 1.14.0 (February 2025) #
7
13
 
@@ -20,12 +20,15 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'multi_json', '~> 1.15'
21
21
  gem.add_dependency "concurrent-ruby", "~> 1.2"
22
22
  gem.add_dependency 'ostruct', '> 0.6'
23
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.5")
24
+ gem.add_dependency "cgi", "~> 0.5"
25
+ end
23
26
 
24
27
  gem.add_development_dependency 'guard-rspec', '~> 4.7'
25
28
  gem.add_development_dependency 'listen', '~> 3.7'
26
29
  gem.add_development_dependency 'rake', '~> 13.0'
27
30
  gem.add_development_dependency 'rspec', '~> 3.11'
28
- gem.add_development_dependency 'webmock', '~> 1.21'
31
+ gem.add_development_dependency 'webmock', '~> 3.25'
29
32
  gem.add_development_dependency 'debug', '>= 1.0.0'
30
33
  gem.add_development_dependency 'standard', '>= 1.35'
31
34
  end
@@ -64,9 +64,9 @@ module AddressFinder
64
64
  config.proxy_password)
65
65
  http.open_timeout = config.timeout
66
66
  http.read_timeout = config.timeout
67
- http.use_ssl = true
67
+ http.use_ssl = config.port == 443
68
68
  http
69
69
  end
70
70
  end
71
71
  end
72
- end
72
+ end
@@ -0,0 +1,72 @@
1
+ module AddressFinder
2
+ module V1
3
+ module Phone
4
+ class BatchVerification
5
+ attr_reader :phone_numbers, :results
6
+
7
+ # Verifies an array of phone numbers using concurrency to reduce the execution time.
8
+ # The results of the verification are stored in the `results` attribute, in the same order
9
+ # in which they were supplied.
10
+ #
11
+ # @param [Array<String>] phone_numbers
12
+ # @param [String] default_country_code
13
+ # @param [AddressFinder::HTTP] http HTTP connection helper
14
+ # @param [Integer] concurrency How many threads to use for verification
15
+ # @param [Hash] args Any additional arguments that will be passed onto the EV API
16
+ def initialize(phone_numbers:, default_country_code:, http:, concurrency: 5, **args)
17
+ @phone_numbers = phone_numbers
18
+ @concurrency = concurrency
19
+ @default_country_code = default_country_code
20
+ @http = http
21
+ @args = args
22
+ end
23
+
24
+ def perform
25
+ confirm_concurrency_level
26
+ verify_each_phone_number_concurrently
27
+
28
+ self
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :args, :concurrency, :http, :default_country_code
34
+
35
+ MAX_CONCURRENCY_LEVEL = 10
36
+
37
+ def confirm_concurrency_level
38
+ return unless @concurrency > MAX_CONCURRENCY_LEVEL
39
+
40
+ warn "WARNING: Concurrency level of #{@concurrency} is higher than the maximum of #{MAX_CONCURRENCY_LEVEL}. Using #{MAX_CONCURRENCY_LEVEL}."
41
+ @concurrency = MAX_CONCURRENCY_LEVEL
42
+ end
43
+
44
+ def verify_each_phone_number_concurrently
45
+ @results = Concurrent::Array.new(phone_numbers.length)
46
+
47
+ pool = Concurrent::FixedThreadPool.new(concurrency)
48
+
49
+ @phone_numbers.each_with_index do |phone_number, index_of_phone_number|
50
+ # Start a new thread for each task
51
+ pool.post do
52
+ @results[index_of_phone_number] = verify_phone_number(phone_number)
53
+ end
54
+ end
55
+
56
+ ## Shutdown the pool and wait for all tasks to complete
57
+ pool.shutdown
58
+ pool.wait_for_termination
59
+ end
60
+
61
+ # Verifies a single phone number, and writes the result into @results
62
+ def verify_phone_number(phone_number)
63
+ return if phone_number.empty?
64
+
65
+ AddressFinder::V1::Phone::Verification.new(phone_number: phone_number, default_country_code: default_country_code, http: http.clone, **args).perform.result
66
+ rescue AddressFinder::RequestRejectedError => e
67
+ OpenStruct.new(success: false, body: e.body, status: e.status)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -1,3 +1,3 @@
1
1
  module AddressFinder
2
- VERSION = "1.15.0"
2
+ VERSION = "1.16.0"
3
3
  end
data/lib/addressfinder.rb CHANGED
@@ -16,6 +16,7 @@ require "addressfinder/bulk"
16
16
  require "addressfinder/v1/email/verification"
17
17
  require "addressfinder/v1/email/batch_verification"
18
18
  require "addressfinder/v1/phone/verification"
19
+ require "addressfinder/v1/phone/batch_verification"
19
20
  require "addressfinder/errors"
20
21
  require "addressfinder/util"
21
22
  require "addressfinder/http"
@@ -96,6 +97,10 @@ module AddressFinder
96
97
  AddressFinder::V1::Phone::Verification.new(**args.merge(http: AddressFinder::HTTP.new(configuration))).perform.result
97
98
  end
98
99
 
100
+ def phone_verification_batch(args = {})
101
+ AddressFinder::V1::Phone::BatchVerification.new(**args.merge(http: AddressFinder::HTTP.new(configuration))).perform.results
102
+ end
103
+
99
104
  def bulk(&block)
100
105
  AddressFinder::Bulk.new(
101
106
  http: AddressFinder::HTTP.new(configuration), verification_version: configuration.verification_version, default_country: configuration.default_country, &block
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: addressfinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.0
4
+ version: 1.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Ramsay
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2025-03-24 00:00:00.000000000 Z
15
+ date: 2025-09-01 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: multi_json
@@ -118,14 +118,14 @@ dependencies:
118
118
  requirements:
119
119
  - - "~>"
120
120
  - !ruby/object:Gem::Version
121
- version: '1.21'
121
+ version: '3.25'
122
122
  type: :development
123
123
  prerelease: false
124
124
  version_requirements: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - "~>"
127
127
  - !ruby/object:Gem::Version
128
- version: '1.21'
128
+ version: '3.25'
129
129
  - !ruby/object:Gem::Dependency
130
130
  name: debug
131
131
  requirement: !ruby/object:Gem::Requirement
@@ -185,6 +185,7 @@ files:
185
185
  - lib/addressfinder/v1/email/batch_verification.rb
186
186
  - lib/addressfinder/v1/email/verification.rb
187
187
  - lib/addressfinder/v1/nz/batch_verification.rb
188
+ - lib/addressfinder/v1/phone/batch_verification.rb
188
189
  - lib/addressfinder/v1/phone/verification.rb
189
190
  - lib/addressfinder/v2/au/batch_verification.rb
190
191
  - lib/addressfinder/v2/au/verification.rb
@@ -209,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
210
  - !ruby/object:Gem::Version
210
211
  version: '0'
211
212
  requirements: []
212
- rubygems_version: 3.5.22
213
+ rubygems_version: 3.3.27
213
214
  signing_key:
214
215
  specification_version: 4
215
216
  summary: Provides easy access to Addressfinder APIs