email_domain_checker 0.1.1 → 0.1.2
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 +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +24 -0
- data/lib/email_domain_checker/config.rb +31 -3
- data/lib/email_domain_checker/domain_validator.rb +4 -0
- data/lib/email_domain_checker/version.rb +1 -1
- data/lib/email_domain_checker.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9482f21ae74333979292271bf830aa22164a859388ba73b29a090118185ac797
|
|
4
|
+
data.tar.gz: 12fa14a045d73af82ff4d179c55d9f7c425ec25a1bc171d3328e60f5045f92de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab00a7b94993e50f3e5e8c4b7d7fa74c270a77778c4bd7c5796f84420fe1ffb0c929ec3efa4999d573ba38325e431cca20359e55dcfe68d4b73f67367f57a92d
|
|
7
|
+
data.tar.gz: 7a1f651e88f540389f8d213e381a37047c96370d3ff2bb1b4bd8a3655045ac9bb9cf749695ca8c774d2cca38050028e11468f181c883ff6b391abaf57f1d544a
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.2] - 2025-11-05
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Test mode feature to skip DNS checks during testing with block syntax support for configuration ([#4](https://github.com/tatematsu-k/email_domain_checker/pull/4))
|
|
12
|
+
|
|
13
|
+
## [0.1.1] - 2025-11-04
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- ActiveModel/ActiveRecord validator integration (`DomainCheckValidator`) ([#3](https://github.com/tatematsu-k/email_domain_checker/pull/3))
|
|
17
|
+
- Automatic email normalization option in validator ([#3](https://github.com/tatematsu-k/email_domain_checker/pull/3))
|
|
18
|
+
- Ruby 3.4+ compatibility support for ActiveModel integration ([#3](https://github.com/tatematsu-k/email_domain_checker/pull/3))
|
|
19
|
+
- Comprehensive test coverage for ActiveModel validator ([#3](https://github.com/tatematsu-k/email_domain_checker/pull/3))
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- CI: Added ActiveRecord version matrix testing for better compatibility testing ([#3](https://github.com/tatematsu-k/email_domain_checker/pull/3))
|
|
23
|
+
|
|
24
|
+
### Documentation
|
|
25
|
+
- Added ActiveModel integration documentation with usage examples ([#3](https://github.com/tatematsu-k/email_domain_checker/pull/3))
|
|
26
|
+
|
|
8
27
|
## [0.1.0] - 2025-11-4
|
|
9
28
|
|
|
10
29
|
### Added
|
data/README.md
CHANGED
|
@@ -39,6 +39,11 @@ EmailDomainChecker.normalize("User@Example.COM") # => "user@example.com"
|
|
|
39
39
|
|
|
40
40
|
# Configure default options globally
|
|
41
41
|
EmailDomainChecker.configure(timeout: 10, check_mx: true)
|
|
42
|
+
|
|
43
|
+
# Enable test mode (skips DNS checks)
|
|
44
|
+
EmailDomainChecker.configure do |config|
|
|
45
|
+
config.test_mode = true
|
|
46
|
+
end
|
|
42
47
|
```
|
|
43
48
|
|
|
44
49
|
### Using Checker class
|
|
@@ -125,6 +130,25 @@ end
|
|
|
125
130
|
- `check_mx`: Check MX records for domain (default: true)
|
|
126
131
|
- `check_a`: Check A records for domain (default: false)
|
|
127
132
|
- `timeout`: DNS lookup timeout in seconds (default: 5)
|
|
133
|
+
- `test_mode`: Skip DNS checks (useful for testing with dummy data) (default: false)
|
|
134
|
+
|
|
135
|
+
### Test Mode
|
|
136
|
+
|
|
137
|
+
When writing tests, you may want to skip DNS checks to avoid external requests. Enable test mode to skip all DNS validations (MX and A record checks):
|
|
138
|
+
|
|
139
|
+
```ruby
|
|
140
|
+
# In spec_helper.rb or test_helper.rb
|
|
141
|
+
EmailDomainChecker.configure do |config|
|
|
142
|
+
config.test_mode = true
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Or in a before block
|
|
146
|
+
before do
|
|
147
|
+
EmailDomainChecker::Config.test_mode = true
|
|
148
|
+
end
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
When test mode is enabled, domain validation will always return `true` without making any DNS requests, allowing you to use dummy email addresses in your tests without external dependencies.
|
|
128
152
|
|
|
129
153
|
## Development
|
|
130
154
|
|
|
@@ -11,15 +11,43 @@ module EmailDomainChecker
|
|
|
11
11
|
}.freeze
|
|
12
12
|
|
|
13
13
|
class << self
|
|
14
|
-
attr_accessor :default_options
|
|
14
|
+
attr_accessor :default_options, :test_mode
|
|
15
15
|
|
|
16
|
-
def configure(options = {})
|
|
17
|
-
|
|
16
|
+
def configure(options = {}, &block)
|
|
17
|
+
if block_given?
|
|
18
|
+
config_instance = new
|
|
19
|
+
block.call(config_instance)
|
|
20
|
+
@default_options = DEFAULT_OPTIONS.merge(options)
|
|
21
|
+
config_instance
|
|
22
|
+
else
|
|
23
|
+
@default_options = DEFAULT_OPTIONS.merge(options)
|
|
24
|
+
new
|
|
25
|
+
end
|
|
18
26
|
end
|
|
19
27
|
|
|
20
28
|
def reset
|
|
21
29
|
@default_options = DEFAULT_OPTIONS.dup
|
|
30
|
+
@test_mode = false
|
|
22
31
|
end
|
|
32
|
+
|
|
33
|
+
def test_mode=(value)
|
|
34
|
+
@test_mode = value
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_mode?
|
|
38
|
+
@test_mode == true
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
attr_accessor :test_mode
|
|
43
|
+
|
|
44
|
+
def initialize
|
|
45
|
+
@test_mode = self.class.test_mode || false
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_mode=(value)
|
|
49
|
+
@test_mode = value
|
|
50
|
+
self.class.test_mode = value
|
|
23
51
|
end
|
|
24
52
|
|
|
25
53
|
reset
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "dns_resolver"
|
|
4
|
+
require_relative "config"
|
|
4
5
|
|
|
5
6
|
module EmailDomainChecker
|
|
6
7
|
class DomainValidator
|
|
@@ -18,6 +19,9 @@ module EmailDomainChecker
|
|
|
18
19
|
def valid?(domain)
|
|
19
20
|
return false if domain.nil? || domain.empty?
|
|
20
21
|
|
|
22
|
+
# Skip DNS checks if test mode is enabled
|
|
23
|
+
return true if Config.test_mode?
|
|
24
|
+
|
|
21
25
|
check_domain_records(domain)
|
|
22
26
|
end
|
|
23
27
|
|
data/lib/email_domain_checker.rb
CHANGED