diff options
| author | john.hackett@bytemark.co.uk <john.hackett@bytemark.co.uk> | 2013-02-07 17:19:27 +0000 | 
|---|---|---|
| committer | john.hackett@bytemark.co.uk <john.hackett@bytemark.co.uk> | 2013-02-07 17:19:27 +0000 | 
| commit | 0108169c85c7404aeafbdfe1ad8176240853ef6a (patch) | |
| tree | b78580ec650f56b38f5d89cd118a23178b129b1b /lib/custodian | |
| parent | 87ff4e6b0c1af2bba868f15ca2e6516a8f460251 (diff) | |
Cleaned up logic with inversion and return to be a bit less cumbersome and marginally less ugly.
Diffstat (limited to 'lib/custodian')
| -rw-r--r-- | lib/custodian/protocoltest/smtprelay.rb | 29 | 
1 files changed, 15 insertions, 14 deletions
| diff --git a/lib/custodian/protocoltest/smtprelay.rb b/lib/custodian/protocoltest/smtprelay.rb index d6c5bb4..2280f10 100644 --- a/lib/custodian/protocoltest/smtprelay.rb +++ b/lib/custodian/protocoltest/smtprelay.rb @@ -71,22 +71,22 @@ module Custodian              sent    = smtp.send_message message, "noreply@bytemark.co.uk", "noreply@bytemark.co.uk"              @status = sent.status.to_s -            if @inverted === true -              @success = true -              @failure = false -            else -              @success = false -              @failure = true -            end - -            if @status === "250" #and @inverted == true +            if @status === "250"                @error = "NOT OK: message sent on #{@host} with status #{@status}" -              return @success -            else +            else                 @error = "OK: message not sent on #{@host} with status #{@status}" -              return @failure              end - +             +            # +            # give the parser an appropriate response depending on the smtp code +            # and whether or not we're inverting the test. (eg, 'must not') +            # +             +            return @inverted  if @status == "250" and @inverted +            return !@inverted if @status == "250" and !@inverted +            return @inverted  if @status != "250" and !@inverted +            return !@inverted if @status != "250" and @inverted +                        end # Net SMTP          rescue Exception => ex @@ -94,7 +94,8 @@ module Custodian            # for if we fail to send a message; this is a good thing            #            @error = "OK: Timed out or connection refused on #{@host} with status #{@status}" -          return @failure +          return !@inverted if @inverted +          return @inverted if !@inverted                    end        end | 
