summaryrefslogtreecommitdiff
path: root/lib/custodian
diff options
context:
space:
mode:
authorjohn hackett <john.hackett@bytemark.co.uk>2013-02-07 17:19:27 +0000
committerjohn hackett <john.hackett@bytemark.co.uk>2013-02-07 17:19:27 +0000
commit9bc4ac7de2d105f74130f936855a6c7598bf2c61 (patch)
treef51ca6ef27d3a50ca15f3158c89c53a468bbc540 /lib/custodian
parentaa1126939b4446abfa6bc00392206fac9ac04f28 (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.rb29
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