email_address 0.1.13 → 0.1.14
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/README.md +4 -2
- data/lib/email_address/address.rb +87 -92
- data/lib/email_address/config.rb +47 -45
- data/lib/email_address/exchanger.rb +27 -28
- data/lib/email_address/host.rb +116 -116
- data/lib/email_address/version.rb +1 -1
- data/test/email_address/test_host.rb +29 -31
- metadata +3 -3
| @@ -1,6 +1,4 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            require_relative '../test_helper'
         | 
| 3 | 
            -
             | 
| 1 | 
            +
            require_relative "../test_helper"
         | 
| 4 2 |  | 
| 5 3 | 
             
            class TestHost < MiniTest::Test
         | 
| 6 4 | 
             
              def test_host
         | 
| @@ -10,16 +8,16 @@ class TestHost < MiniTest::Test | |
| 10 8 | 
             
                assert_equal "example", a.registration_name
         | 
| 11 9 | 
             
                assert_equal "com", a.tld
         | 
| 12 10 | 
             
                assert_equal "ex*****", a.munge
         | 
| 13 | 
            -
                assert_nil | 
| 11 | 
            +
                assert_nil a.subdomains
         | 
| 14 12 | 
             
              end
         | 
| 15 13 |  | 
| 16 14 | 
             
              def test_dns_enabled
         | 
| 17 15 | 
             
                a = EmailAddress::Host.new("example.com")
         | 
| 18 16 | 
             
                assert_instance_of TrueClass, a.dns_enabled?
         | 
| 19 | 
            -
                 | 
| 20 | 
            -
                 | 
| 17 | 
            +
                a = EmailAddress::Host.new("example.com", host_validation: :syntax)
         | 
| 18 | 
            +
                assert_instance_of FalseClass, a.dns_enabled?
         | 
| 19 | 
            +
                a = EmailAddress::Host.new("example.com", dns_lookup: :off)
         | 
| 21 20 | 
             
                assert_instance_of FalseClass, a.dns_enabled?
         | 
| 22 | 
            -
                EmailAddress::Config.configure(host_validation: old_setting)
         | 
| 23 21 | 
             
              end
         | 
| 24 22 |  | 
| 25 23 | 
             
              def test_foreign_host
         | 
| @@ -53,54 +51,54 @@ class TestHost < MiniTest::Test | |
| 53 51 |  | 
| 54 52 | 
             
              def test_dmarc
         | 
| 55 53 | 
             
                d = EmailAddress::Host.new("yahoo.com").dmarc
         | 
| 56 | 
            -
                assert_equal  | 
| 54 | 
            +
                assert_equal "reject", d[:p]
         | 
| 57 55 | 
             
                d = EmailAddress::Host.new("example.com").dmarc
         | 
| 58 56 | 
             
                assert_equal true, d.empty?
         | 
| 59 57 | 
             
              end
         | 
| 60 58 |  | 
| 61 59 | 
             
              def test_ipv4
         | 
| 62 | 
            -
                h = EmailAddress::Host.new("[127.0.0.1]", host_allow_ip:true, host_local:true)
         | 
| 60 | 
            +
                h = EmailAddress::Host.new("[127.0.0.1]", host_allow_ip: true, host_local: true)
         | 
| 63 61 | 
             
                assert_equal "127.0.0.1", h.ip_address
         | 
| 64 62 | 
             
                assert_equal true, h.valid?
         | 
| 65 63 | 
             
              end
         | 
| 66 64 |  | 
| 67 65 | 
             
              def test_ipv6
         | 
| 68 | 
            -
                h = EmailAddress::Host.new("[IPv6:::1]", host_allow_ip:true, host_local:true)
         | 
| 66 | 
            +
                h = EmailAddress::Host.new("[IPv6:::1]", host_allow_ip: true, host_local: true)
         | 
| 69 67 | 
             
                assert_equal "::1", h.ip_address
         | 
| 70 68 | 
             
                assert_equal true, h.valid?
         | 
| 71 69 | 
             
              end
         | 
| 72 70 |  | 
| 73 71 | 
             
              def test_comment
         | 
| 74 72 | 
             
                h = EmailAddress::Host.new("(oops)gmail.com")
         | 
| 75 | 
            -
                assert_equal  | 
| 76 | 
            -
                assert_equal  | 
| 73 | 
            +
                assert_equal "gmail.com", h.to_s
         | 
| 74 | 
            +
                assert_equal "oops", h.comment
         | 
| 77 75 | 
             
                h = EmailAddress::Host.new("gmail.com(oops)")
         | 
| 78 | 
            -
                assert_equal  | 
| 79 | 
            -
                assert_equal  | 
| 76 | 
            +
                assert_equal "gmail.com", h.to_s
         | 
| 77 | 
            +
                assert_equal "oops", h.comment
         | 
| 80 78 | 
             
              end
         | 
| 81 79 |  | 
| 82 80 | 
             
              def test_matches
         | 
| 83 81 | 
             
                h = EmailAddress::Host.new("yahoo.co.jp")
         | 
| 84 82 | 
             
                assert_equal false, h.matches?("gmail.com")
         | 
| 85 | 
            -
                assert_equal  | 
| 86 | 
            -
                assert_equal  | 
| 87 | 
            -
                assert_equal  | 
| 88 | 
            -
                assert_equal  | 
| 89 | 
            -
                assert_equal  | 
| 83 | 
            +
                assert_equal "yahoo.co.jp", h.matches?("yahoo.co.jp")
         | 
| 84 | 
            +
                assert_equal ".co.jp", h.matches?(".co.jp")
         | 
| 85 | 
            +
                assert_equal ".jp", h.matches?(".jp")
         | 
| 86 | 
            +
                assert_equal "yahoo.", h.matches?("yahoo.")
         | 
| 87 | 
            +
                assert_equal "yah*.jp", h.matches?("yah*.jp")
         | 
| 90 88 | 
             
              end
         | 
| 91 89 |  | 
| 92 90 | 
             
              def test_ipv4_matches
         | 
| 93 | 
            -
                h = EmailAddress::Host.new("[123.123.123.8]", host_allow_ip:true)
         | 
| 91 | 
            +
                h = EmailAddress::Host.new("[123.123.123.8]", host_allow_ip: true)
         | 
| 94 92 | 
             
                assert_equal "123.123.123.8", h.ip_address
         | 
| 95 93 | 
             
                assert_equal false, h.matches?("127.0.0.0/8")
         | 
| 96 | 
            -
                assert_equal  | 
| 94 | 
            +
                assert_equal "123.123.123.0/24", h.matches?("123.123.123.0/24")
         | 
| 97 95 | 
             
              end
         | 
| 98 96 |  | 
| 99 97 | 
             
              def test_ipv6_matches
         | 
| 100 | 
            -
                h = EmailAddress::Host.new("[IPV6:2001:db8::1]", host_allow_ip:true)
         | 
| 98 | 
            +
                h = EmailAddress::Host.new("[IPV6:2001:db8::1]", host_allow_ip: true)
         | 
| 101 99 | 
             
                assert_equal "2001:db8::1", h.ip_address
         | 
| 102 100 | 
             
                assert_equal false, h.matches?("2002:db8::/118")
         | 
| 103 | 
            -
                assert_equal  | 
| 101 | 
            +
                assert_equal "2001:db8::/118", h.matches?("2001:db8::/118")
         | 
| 104 102 | 
             
              end
         | 
| 105 103 |  | 
| 106 104 | 
             
              def test_regexen
         | 
| @@ -112,18 +110,18 @@ class TestHost < MiniTest::Test | |
| 112 110 | 
             
              end
         | 
| 113 111 |  | 
| 114 112 | 
             
              def test_hosted_service
         | 
| 115 | 
            -
                assert EmailAddress.valid?( | 
| 116 | 
            -
                assert ! | 
| 113 | 
            +
                assert EmailAddress.valid?("test@jiff.com", dns_lookup: :mx)
         | 
| 114 | 
            +
                assert !EmailAddress.valid?("test@gmail.com", dns_lookup: :mx)
         | 
| 117 115 | 
             
              end
         | 
| 118 116 |  | 
| 119 117 | 
             
              def test_yahoo_bad_tld
         | 
| 120 | 
            -
                assert ! | 
| 121 | 
            -
                assert ! | 
| 118 | 
            +
                assert !EmailAddress.valid?("test@yahoo.badtld")
         | 
| 119 | 
            +
                assert !EmailAddress.valid?("test@yahoo.wtf") # Registered, but MX IP = 0.0.0.0
         | 
| 122 120 | 
             
              end
         | 
| 123 121 |  | 
| 124 122 | 
             
              def test_bad_formats
         | 
| 125 | 
            -
                assert ! | 
| 126 | 
            -
                assert EmailAddress::Host.new( | 
| 123 | 
            +
                assert !EmailAddress::Host.new("ya  hoo.com").valid?
         | 
| 124 | 
            +
                assert EmailAddress::Host.new("ya  hoo.com", host_remove_spaces: true).valid?
         | 
| 127 125 | 
             
              end
         | 
| 128 126 |  | 
| 129 127 | 
             
              def test_errors
         | 
| @@ -133,7 +131,7 @@ class TestHost < MiniTest::Test | |
| 133 131 | 
             
                assert_nil EmailAddress::Host.new("ajsdfhajshdfklasjhd.wtf", host_validation: :syntax).error
         | 
| 134 132 | 
             
                assert_equal EmailAddress::Host.new("ya  hoo.com", host_validation: :syntax).error, "Invalid Domain Name"
         | 
| 135 133 | 
             
                assert_equal EmailAddress::Host.new("[127.0.0.1]").error, "IP Addresses are not allowed"
         | 
| 136 | 
            -
                assert_equal EmailAddress::Host.new("[127.0.0.666]", host_allow_ip:true).error, "This is not a valid IPv4 address"
         | 
| 137 | 
            -
                assert_equal EmailAddress::Host.new("[IPv6::12t]", host_allow_ip:true).error, "This is not a valid IPv6 address"
         | 
| 134 | 
            +
                assert_equal EmailAddress::Host.new("[127.0.0.666]", host_allow_ip: true).error, "This is not a valid IPv4 address"
         | 
| 135 | 
            +
                assert_equal EmailAddress::Host.new("[IPv6::12t]", host_allow_ip: true).error, "This is not a valid IPv6 address"
         | 
| 138 136 | 
             
              end
         | 
| 139 137 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: email_address
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.14
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Allen Fair
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020- | 
| 11 | 
            +
            date: 2020-03-17 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rake
         | 
| @@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 183 183 | 
             
                - !ruby/object:Gem::Version
         | 
| 184 184 | 
             
                  version: '0'
         | 
| 185 185 | 
             
            requirements: []
         | 
| 186 | 
            -
            rubygems_version: 3. | 
| 186 | 
            +
            rubygems_version: 3.0.6
         | 
| 187 187 | 
             
            signing_key: 
         | 
| 188 188 | 
             
            specification_version: 4
         | 
| 189 189 | 
             
            summary: This gem provides a ruby language library for working with and validating
         |