addressfinder 1.14.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: 0d90188a9c9fc48c8fe6f6969422dbd58fca983e1df1fcd847b30a901e517d57
4
- data.tar.gz: dbf03555650c7b18d98e95984eba7355dc23e6002bde8992222203d2cb5d33bc
3
+ metadata.gz: '0365876ccfbc2b618dd2e417b9d2fa238eaee83f8e1c0afa17230c3895f3542e'
4
+ data.tar.gz: a76840892fae1cdd10c646031edc4ff8f7675d499e0c21e7d7e7c73ebf63c35c
5
5
  SHA512:
6
- metadata.gz: 26482cf4b76f70993a20dac62aeb5c6bc4b9cda257343fb47dccd049adea2098a4bab8bf1027ae40377071b6eba02162e9bd6fa94a3391ee4afaf9bf74e2f008
7
- data.tar.gz: ed1ce7451090295ebf848e75133e2b19c376bed7c802dd584b72a516695b0e67172e043a4e88c85b3f93714dc5655b9b5f744f0a4b1a193b92f2c62671790383
6
+ metadata.gz: c9fd2bc3220f84afdaa24c4075594dda01a846b8670ced3d5a4a019529e0995488b6981ccd8a28609ed759a3da9598cd0c81133f61a73519dd64f27b03809136
7
+ data.tar.gz: 386b3217887a2c3601a2290e2638f38989592cc33688eedde74df030afad8af7ed70ae867a39c8a9f65d03b4634b902b93175546f5f346aa0932ade795b89b68
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
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
+
7
+ # Addressfinder 1.15.0 (March 2025) #
8
+
9
+ * Automatically skip empty strings within Batch verification
10
+ * Mark unverified addresses as false within Batch verification
11
+
1
12
  # Addressfinder 1.14.0 (February 2025) #
2
13
 
3
14
  * Add support for Ruby 3.4
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Addressfinder Ruby Gem
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/addressfinder.svg)](http://badge.fury.io/rb/addressfinder)
4
- [![Build Status](https://travis-ci.com/github/AddressFinder/addressfinder-ruby.svg)](https://travis-ci.com/github/AddressFinder/addressfinder-ruby)
4
+ [![Build Status](https://github.com/addressfinder/addressfinder-ruby/actions/workflows/ruby.yml/badge.svg?branch=master)](https://github.com/addressfinder/addressfinder-ruby/actions/workflows/ruby.yml/badge.svg?branch=master)
5
5
 
6
6
  A client library for accessing the [Addressfinder](https://addressfinder.nz/?utm_source=github&utm_medium=readme&utm_campaign=addressfinder_rubygem&utm_term=AddressFinder) APIs.
7
7
 
@@ -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
@@ -47,7 +47,7 @@ module AddressFinder
47
47
  @emails.each_with_index do |email, index_of_email|
48
48
  # Start a new thread for each task
49
49
  pool.post do
50
- verify_email(email, index_of_email)
50
+ @results[index_of_email] = verify_email(email)
51
51
  end
52
52
  end
53
53
 
@@ -57,11 +57,12 @@ module AddressFinder
57
57
  end
58
58
 
59
59
  # Verifies a single email addresses, and writes the result into @results
60
- def verify_email(email, index_of_email)
61
- @results[index_of_email] =
62
- AddressFinder::V1::Email::Verification.new(email: email, http: http.clone, **args).perform.result
60
+ def verify_email(email)
61
+ return if email.empty?
62
+
63
+ AddressFinder::V1::Email::Verification.new(email: email, http: http.clone, **args).perform.result
63
64
  rescue AddressFinder::RequestRejectedError => e
64
- @results[index_of_email] = OpenStruct.new(success: false, body: e.body, status: e.status)
65
+ OpenStruct.new(success: false, body: e.body, status: e.status)
65
66
  end
66
67
  end
67
68
  end
@@ -48,7 +48,7 @@ module AddressFinder
48
48
  addresses.each_with_index do |address, index_of_address|
49
49
  # Start a new thread for each task
50
50
  pool.post do
51
- verify_address(address, index_of_address)
51
+ @results[index_of_address] = verify_address(address)
52
52
  end
53
53
  end
54
54
 
@@ -58,11 +58,12 @@ module AddressFinder
58
58
  end
59
59
 
60
60
  # Verifies a single address, and writes the result into @results
61
- def verify_address(address, index_of_address)
62
- @results[index_of_address] =
63
- AddressFinder::Verification.new(q: address, http: http.clone, **args).perform.result
61
+ def verify_address(address)
62
+ return if address.empty?
63
+
64
+ AddressFinder::Verification.new(q: address, http: http.clone, **args).perform.result || false
64
65
  rescue AddressFinder::RequestRejectedError => e
65
- @results[index_of_address] = OpenStruct.new(success: false, body: e.body, status: e.status)
66
+ OpenStruct.new(success: false, body: e.body, status: e.status)
66
67
  end
67
68
  end
68
69
  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
@@ -48,7 +48,7 @@ module AddressFinder
48
48
  addresses.each_with_index do |address, index_of_address|
49
49
  # Start a new thread for each task
50
50
  pool.post do
51
- verify_address(address, index_of_address)
51
+ @results[index_of_address] = verify_address(address)
52
52
  end
53
53
  end
54
54
 
@@ -58,11 +58,12 @@ module AddressFinder
58
58
  end
59
59
 
60
60
  # Verifies a single address, and writes the result into @results
61
- def verify_address(address, index_of_address)
62
- @results[index_of_address] =
63
- AddressFinder::V2::Au::Verification.new(q: address, http: http.clone, **args).perform.result
61
+ def verify_address(address)
62
+ return if address.empty?
63
+
64
+ AddressFinder::V2::Au::Verification.new(q: address, http: http.clone, **args).perform.result || false
64
65
  rescue AddressFinder::RequestRejectedError => e
65
- @results[index_of_address] = OpenStruct.new(success: false, body: e.body, status: e.status)
66
+ OpenStruct.new(success: false, body: e.body, status: e.status)
66
67
  end
67
68
  end
68
69
  end
@@ -1,3 +1,3 @@
1
1
  module AddressFinder
2
- VERSION = "1.14.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.14.0
4
+ version: 1.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Ramsay
@@ -9,9 +9,10 @@ authors:
9
9
  - Sean Arnold
10
10
  - Alexandre Barret
11
11
  - Cassandre Guinut
12
+ autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2025-02-28 00:00:00.000000000 Z
15
+ date: 2025-09-01 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: multi_json
@@ -117,14 +118,14 @@ dependencies:
117
118
  requirements:
118
119
  - - "~>"
119
120
  - !ruby/object:Gem::Version
120
- version: '1.21'
121
+ version: '3.25'
121
122
  type: :development
122
123
  prerelease: false
123
124
  version_requirements: !ruby/object:Gem::Requirement
124
125
  requirements:
125
126
  - - "~>"
126
127
  - !ruby/object:Gem::Version
127
- version: '1.21'
128
+ version: '3.25'
128
129
  - !ruby/object:Gem::Dependency
129
130
  name: debug
130
131
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +185,7 @@ files:
184
185
  - lib/addressfinder/v1/email/batch_verification.rb
185
186
  - lib/addressfinder/v1/email/verification.rb
186
187
  - lib/addressfinder/v1/nz/batch_verification.rb
188
+ - lib/addressfinder/v1/phone/batch_verification.rb
187
189
  - lib/addressfinder/v1/phone/verification.rb
188
190
  - lib/addressfinder/v2/au/batch_verification.rb
189
191
  - lib/addressfinder/v2/au/verification.rb
@@ -193,6 +195,7 @@ homepage: https://github.com/AddressFinder/addressfinder-ruby
193
195
  licenses:
194
196
  - MIT
195
197
  metadata: {}
198
+ post_install_message:
196
199
  rdoc_options: []
197
200
  require_paths:
198
201
  - lib
@@ -207,7 +210,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
210
  - !ruby/object:Gem::Version
208
211
  version: '0'
209
212
  requirements: []
210
- rubygems_version: 3.6.2
213
+ rubygems_version: 3.3.27
214
+ signing_key:
211
215
  specification_version: 4
212
216
  summary: Provides easy access to Addressfinder APIs
213
217
  test_files: []