From 0971310be8093ab53b430ac5a8c7217ba8bf76a9 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 21 Nov 2012 23:34:23 +0000 Subject: Serialize and cosntruct neatly --- lib/custodian/protocoltest/ftp.rb | 19 ++++++++++++++----- lib/custodian/protocoltest/jabber.rb | 17 ++++++++++++----- lib/custodian/protocoltest/rsync.rb | 17 ++++++++++++----- lib/custodian/protocoltest/smtp.rb | 18 +++++++++++++----- lib/custodian/protocoltest/ssh.rb | 18 +++++++++++++----- lib/custodian/protocoltest/tcp.rb | 18 ++++++++++++------ 6 files changed, 76 insertions(+), 31 deletions(-) (limited to 'lib/custodian/protocoltest') diff --git a/lib/custodian/protocoltest/ftp.rb b/lib/custodian/protocoltest/ftp.rb index 1d60e43..89b4a2b 100644 --- a/lib/custodian/protocoltest/ftp.rb +++ b/lib/custodian/protocoltest/ftp.rb @@ -12,6 +12,12 @@ class FTPTest < TCPTest + # + # The line from which we were constructed. + # + attr_reader :line + + # # The host to test against. # @@ -26,10 +32,17 @@ class FTPTest < TCPTest + # # Constructor # def initialize( line ) + + # + # Save the line + # + @line = line + # # Save the host # @@ -62,11 +75,7 @@ class FTPTest < TCPTest # Convert this class to JSON such that it may be serialized. # def to_json - hash = { - :test_type => 'ftp', - :test_target => @host, - :test_port => @port, - } + hash = { :line => @line } hash.to_json end diff --git a/lib/custodian/protocoltest/jabber.rb b/lib/custodian/protocoltest/jabber.rb index 1aef8b5..da400ac 100644 --- a/lib/custodian/protocoltest/jabber.rb +++ b/lib/custodian/protocoltest/jabber.rb @@ -11,6 +11,11 @@ # class JABBERTest < TCPTest + # + # The line from which we were constructed. + # + attr_reader :line + # # The host to test against. @@ -29,6 +34,12 @@ class JABBERTest < TCPTest # Constructor # def initialize( line ) + + # + # Save the line + # + @line = line + # # Save the host # @@ -61,11 +72,7 @@ class JABBERTest < TCPTest # Convert this class to JSON such that it may be serialized. # def to_json - hash = { - :test_type => 'jabber', - :test_target => @host, - :test_port => @port, - } + hash = { :line => @line } hash.to_json end diff --git a/lib/custodian/protocoltest/rsync.rb b/lib/custodian/protocoltest/rsync.rb index c35758e..c8a2095 100644 --- a/lib/custodian/protocoltest/rsync.rb +++ b/lib/custodian/protocoltest/rsync.rb @@ -11,6 +11,11 @@ # class RSYNCTest < TCPTest + # + # The line from which we were constructed. + # + attr_reader :line + # # The host to test against. @@ -30,6 +35,12 @@ class RSYNCTest < TCPTest # Constructor # def initialize( line ) + + # + # Save the line. + # + @line = line + # # Save the host # @@ -62,11 +73,7 @@ class RSYNCTest < TCPTest # Convert this class to JSON such that it may be serialized. # def to_json - hash = { - :test_type => 'rsync', - :test_target => @host, - :test_port => @port, - } + hash = { :line => @line } hash.to_json end diff --git a/lib/custodian/protocoltest/smtp.rb b/lib/custodian/protocoltest/smtp.rb index dce5ddf..2e1e1e6 100644 --- a/lib/custodian/protocoltest/smtp.rb +++ b/lib/custodian/protocoltest/smtp.rb @@ -12,6 +12,12 @@ class SMTPTest < TCPTest + # + # The line from which we were constructed. + # + attr_reader :line + + # # The host to test against. # @@ -30,6 +36,12 @@ class SMTPTest < TCPTest # Constructor # def initialize( line ) + + # + # Save the line. + # + @line = line + # # Save the host # @@ -62,11 +74,7 @@ class SMTPTest < TCPTest # Convert this class to JSON such that it may be serialized. # def to_json - hash = { - :test_type => 'smtp', - :test_target => @host, - :test_port => @port, - } + hash = { :line => @line } hash.to_json end diff --git a/lib/custodian/protocoltest/ssh.rb b/lib/custodian/protocoltest/ssh.rb index 18f13bc..78e8e67 100644 --- a/lib/custodian/protocoltest/ssh.rb +++ b/lib/custodian/protocoltest/ssh.rb @@ -12,6 +12,12 @@ class SSHTest < TCPTest + # + # The line from which we were constructed. + # + attr_reader :line + + # # The host to test against. # @@ -31,6 +37,12 @@ class SSHTest < TCPTest # Ensure we received a port to run the test against. # def initialize( line ) + + # + # Save the line + # + @line = line + # # Save the host # @@ -64,11 +76,7 @@ class SSHTest < TCPTest # serialized. # def to_json - hash = { - :test_type => 'ssh', - :test_target => @host, - :test_port => @port - } + hash = { :line => @line } hash.to_json end diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb index 5f29b7f..9806565 100644 --- a/lib/custodian/protocoltest/tcp.rb +++ b/lib/custodian/protocoltest/tcp.rb @@ -16,6 +16,12 @@ require 'timeout' class TCPTest < ProtocolTest + # + # The input line + # + attr_reader :line + + # # The host to test against. # @@ -43,6 +49,11 @@ class TCPTest < ProtocolTest # def initialize( line ) + # + # Save the line + # + @line = line + # # Save the host # @@ -90,12 +101,7 @@ class TCPTest < ProtocolTest # Convert this class to JSON such that it may be serialized. # def to_json - hash = { - :test_type => 'tcp', - :test_target => @host, - :test_port => @port, - :banner => @banner - } + hash = { :line => @line } hash.to_json end -- cgit v1.2.1