summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-03-09 13:19:47 +0000
committerSteve Kemp <steve@steve.org.uk>2015-03-09 13:19:47 +0000
commit54b21cf54c51dfe40784a8096f84c7a80b015bd4 (patch)
tree4763692624732650daf1a9e02c91576d3f7ee8d0
parenta22b8e96ead33b0f97ed5243dbad7f7b6cd5135d (diff)
Removed spaces inside parenthesis.
-rwxr-xr-xbin/custodian-dequeue2
-rwxr-xr-xbin/custodian-enqueue8
-rwxr-xr-xbin/custodian-queue4
-rwxr-xr-xbin/multi-ping4
-rw-r--r--lib/custodian/alertfactory.rb10
-rw-r--r--lib/custodian/alerts/file.rb14
-rw-r--r--lib/custodian/alerts/graphite.rb6
-rw-r--r--lib/custodian/alerts/mauve.rb52
-rw-r--r--lib/custodian/alerts/redis-state.rb16
-rw-r--r--lib/custodian/alerts/smtp.rb10
-rw-r--r--lib/custodian/parser.rb74
-rw-r--r--lib/custodian/protocoltest/dns.rb26
-rw-r--r--lib/custodian/protocoltest/dnsbl.rb12
-rw-r--r--lib/custodian/protocoltest/ftp.rb6
-rw-r--r--lib/custodian/protocoltest/http.rb12
-rw-r--r--lib/custodian/protocoltest/imap.rb6
-rw-r--r--lib/custodian/protocoltest/jabber.rb6
-rw-r--r--lib/custodian/protocoltest/ldap.rb8
-rw-r--r--lib/custodian/protocoltest/mx.rb8
-rw-r--r--lib/custodian/protocoltest/mysql.rb6
-rw-r--r--lib/custodian/protocoltest/named.rb6
-rw-r--r--lib/custodian/protocoltest/openproxy.rb8
-rw-r--r--lib/custodian/protocoltest/ping.rb18
-rw-r--r--lib/custodian/protocoltest/pop3.rb6
-rw-r--r--lib/custodian/protocoltest/postgresql.rb6
-rw-r--r--lib/custodian/protocoltest/redis.rb6
-rw-r--r--lib/custodian/protocoltest/rsync.rb6
-rw-r--r--lib/custodian/protocoltest/smtp.rb6
-rw-r--r--lib/custodian/protocoltest/smtprelay.rb10
-rw-r--r--lib/custodian/protocoltest/ssh.rb6
-rw-r--r--lib/custodian/protocoltest/ssl.rb16
-rw-r--r--lib/custodian/protocoltest/tcp.rb28
-rw-r--r--lib/custodian/protocoltest/telnet.rb6
-rw-r--r--lib/custodian/queue.rb22
-rw-r--r--lib/custodian/settings.rb32
-rw-r--r--lib/custodian/testfactory.rb14
-rw-r--r--lib/custodian/util/bytemark.rb2
-rw-r--r--lib/custodian/util/dns.rb10
-rw-r--r--lib/custodian/util/ping.rb16
-rw-r--r--lib/custodian/util/timespan.rb22
-rw-r--r--lib/custodian/worker.rb92
-rwxr-xr-xt/test-custodian-alertfactory.rb22
-rwxr-xr-xt/test-custodian-parser.rb130
-rwxr-xr-xt/test-custodian-queue.rb6
-rwxr-xr-xt/test-custodian-settings.rb34
-rwxr-xr-xt/test-custodian-testfactory.rb114
-rwxr-xr-xt/test-custodian-util-bytemark.rb4
-rwxr-xr-xt/test-custodian-util-dns.rb36
-rwxr-xr-xt/test-custodian-util-ping.rb24
-rwxr-xr-xt/test-custodian-util-timespan.rb98
-rwxr-xr-xt/test-http-vs-https.rb28
-rwxr-xr-xt/test-ldap-probe.rb14
52 files changed, 569 insertions, 569 deletions
diff --git a/bin/custodian-dequeue b/bin/custodian-dequeue
index 7a4b629..3d0c851 100755
--- a/bin/custodian-dequeue
+++ b/bin/custodian-dequeue
@@ -130,7 +130,7 @@ if __FILE__ == $PROGRAM_NAME then
# Create the worker, passing it the settings object so it can
# sort out its own logfile, etc.
#
- worker = Custodian::Worker.new( settings )
+ worker = Custodian::Worker.new(settings)
#
diff --git a/bin/custodian-enqueue b/bin/custodian-enqueue
index 83e462e..4d8b354 100755
--- a/bin/custodian-enqueue
+++ b/bin/custodian-enqueue
@@ -130,7 +130,7 @@ if __FILE__ == $PROGRAM_NAME then
# Connected to the queue - be it redis or beanstalkd
#
settings = Custodian::Settings.instance
- queue = Custodian::QueueType.create( settings.queue_type )
+ queue = Custodian::QueueType.create(settings.queue_type)
if ! queue
puts "Failed to connect to the #{settings.queue_type} queue"
exit 1
@@ -148,11 +148,11 @@ if __FILE__ == $PROGRAM_NAME then
# exit this script.
#
begin
- mon.parse_file( ENV['FILE'] )
+ mon.parse_file(ENV['FILE'])
rescue => e
puts "Failure in parsing the configuration file : #{ENV['FILE']}"
puts e.to_s
- exit( 1 )
+ exit(1)
end
mon.jobs.each do |test|
@@ -162,7 +162,7 @@ if __FILE__ == $PROGRAM_NAME then
elsif ENV['DUMP']
puts test
else
- queue.add( test.to_s )
+ queue.add(test.to_s)
end
end
diff --git a/bin/custodian-queue b/bin/custodian-queue
index 26f214d..e793657 100755
--- a/bin/custodian-queue
+++ b/bin/custodian-queue
@@ -125,7 +125,7 @@ if __FILE__ == $PROGRAM_NAME then
# Create the queue object.
#
settings = Custodian::Settings.instance
- queue = Custodian::QueueType.create( settings.queue_type )
+ queue = Custodian::QueueType.create(settings.queue_type)
#
# Alerting on a queue that is too-full?
@@ -151,7 +151,7 @@ if __FILE__ == $PROGRAM_NAME then
if $STATS
jobs = queue.size?
puts "There are #{jobs || 0} jobs pending."
- exit( 0 )
+ exit(0)
end
diff --git a/bin/multi-ping b/bin/multi-ping
index 9760b35..118fe66 100755
--- a/bin/multi-ping
+++ b/bin/multi-ping
@@ -45,7 +45,7 @@ $manual = false
opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
- [ '--manual', '-m', GetoptLong::NO_ARGUMENT ] )
+ [ '--manual', '-m', GetoptLong::NO_ARGUMENT ])
begin
opts.each do |opt,arg|
@@ -115,7 +115,7 @@ end
#
# Create the object
#
-helper = Custodian::Util::Ping.new( hostname )
+helper = Custodian::Util::Ping.new(hostname)
#
diff --git a/lib/custodian/alertfactory.rb b/lib/custodian/alertfactory.rb
index 78ad9cf..1baa0e3 100644
--- a/lib/custodian/alertfactory.rb
+++ b/lib/custodian/alertfactory.rb
@@ -44,14 +44,14 @@ module Custodian
# The "obj" here is the test-case that will be generating the
# raise/clear event.
#
- def self.create( alert_type, obj )
+ def self.create(alert_type, obj)
raise ArgumentError, 'The type of notifier to create cannot be nil' if alert_type.nil?
raise ArgumentError, 'The type of notifier to create must be a string' unless alert_type.kind_of? String
c = @@subclasses[alert_type]
if c
- c.new( obj )
+ c.new(obj)
else
raise ArgumentError, "Bad alert type: '#{alert_type}'"
end
@@ -81,7 +81,7 @@ module Custodian
#
def get_type
@@subclasses.each do |name,value|
- if ( value == self.class )
+ if (value == self.class)
return name
end
end
@@ -93,7 +93,7 @@ module Custodian
#
# Set the target for this alert.
#
- def set_target( target )
+ def set_target(target)
@target = target
end
@@ -102,7 +102,7 @@ module Custodian
#
# Store a reference to the settings
#
- def set_settings( obj )
+ def set_settings(obj)
@settings = obj
end
diff --git a/lib/custodian/alerts/file.rb b/lib/custodian/alerts/file.rb
index cb04084..06a704e 100644
--- a/lib/custodian/alerts/file.rb
+++ b/lib/custodian/alerts/file.rb
@@ -21,7 +21,7 @@ module Custodian
#
# Constructor - save the test-object away.
#
- def initialize( obj )
+ def initialize(obj)
@test = obj
end
@@ -31,15 +31,15 @@ module Custodian
# Record a raise event for the given test.
#
def raise
- write_message( "RAISE: #{test.target} failed #{test.get_type}-test - #{test.error}" )
+ write_message("RAISE: #{test.target} failed #{test.get_type}-test - #{test.error}")
end
#
# Record the duration of the given test.
#
- def duration( seconds )
- write_message( "#{test.get_type}-test against #{test.target} took #{seconds}ms to complete" )
+ def duration(seconds)
+ write_message("#{test.get_type}-test against #{test.target} took #{seconds}ms to complete")
end
@@ -47,16 +47,16 @@ module Custodian
# Record a clear event for the given test.
#
def clear
- write_message( "CLEAR: #{test.target} failed #{test.get_type}-test" )
+ write_message("CLEAR: #{test.target} failed #{test.get_type}-test")
end
#
# Write the actual message to our target.
#
- def write_message( msg )
+ def write_message(msg)
file = File.open(@target, 'a')
- file.puts( "#{Time.now} #{msg}" )
+ file.puts("#{Time.now} #{msg}")
file.close
end
diff --git a/lib/custodian/alerts/graphite.rb b/lib/custodian/alerts/graphite.rb
index c98f6bf..9d69c28 100644
--- a/lib/custodian/alerts/graphite.rb
+++ b/lib/custodian/alerts/graphite.rb
@@ -22,7 +22,7 @@ module Custodian
#
# Constructor - save the test-object away.
#
- def initialize( obj )
+ def initialize(obj)
@test = obj
end
@@ -47,7 +47,7 @@ module Custodian
#
# Send the test test-duration to graphite/carbon
#
- def duration( ms )
+ def duration(ms)
#
# hostname + test-type
@@ -64,7 +64,7 @@ module Custodian
# Send via UDP.
#
socket = UDPSocket.new
- socket.send( payload, 0, @target, 2003 )
+ socket.send(payload, 0, @target, 2003)
socket.close
end
diff --git a/lib/custodian/alerts/mauve.rb b/lib/custodian/alerts/mauve.rb
index 4c20b08..947f019 100644
--- a/lib/custodian/alerts/mauve.rb
+++ b/lib/custodian/alerts/mauve.rb
@@ -41,7 +41,7 @@ module Custodian
#
# Constructor
#
- def initialize( obj )
+ def initialize(obj)
@test = obj
begin
@@ -62,7 +62,7 @@ module Custodian
#
def raise
- return unless( @loaded )
+ return unless(@loaded)
#
# Get ready to send to mauve.
@@ -75,7 +75,7 @@ module Custodian
#
# Construct a new alert structure.
#
- alert = _get_alert( true )
+ alert = _get_alert(true)
#
# We're raising this alert.
@@ -96,21 +96,21 @@ module Custodian
#
# Lookup the start of the day.
#
- day_start = @settings.key( 'day_start' ).to_i || 10
- day_end = @settings.key( 'day_end' ).to_i || 18
+ day_start = @settings.key('day_start').to_i || 10
+ day_end = @settings.key('day_end').to_i || 18
#
# In hour suppress
#
- working_suppress = @settings.key( 'working_suppress' ).to_i || 4
- oncall_suppress = @settings.key( 'oncall_suppress' ).to_i || 10
+ working_suppress = @settings.key('working_suppress').to_i || 4
+ oncall_suppress = @settings.key('oncall_suppress').to_i || 10
#
# If we're Monday-Friday, between the start & end time, then
# we're in the working day.
#
- if ( ( wday != 0 ) && ( wday != 6 ) ) &&
- ( hour >= day_start && hour < day_end )
+ if ((wday != 0) && (wday != 6)) &&
+ (hour >= day_start && hour < day_end)
working = true
end
@@ -127,13 +127,13 @@ module Custodian
#
# We're going to suppress this alert now
#
- alert.suppress_until = Time.now.to_i + ( period * 60 )
+ alert.suppress_until = Time.now.to_i + (period * 60)
#
# Update it and send it
#
update.alert << alert
- Mauve::Sender.new( @target ).send(update)
+ Mauve::Sender.new(@target).send(update)
end
@@ -144,7 +144,7 @@ module Custodian
#
def clear
- return unless( @loaded )
+ return unless(@loaded)
#
# Get ready to send to mauve.
@@ -157,7 +157,7 @@ module Custodian
#
# Construct a new alert structure.
#
- alert = _get_alert( false )
+ alert = _get_alert(false)
#
# We're clearing this alert.
@@ -168,7 +168,7 @@ module Custodian
# Update it and send it
#
update.alert << alert
- Mauve::Sender.new( @target ).send(update)
+ Mauve::Sender.new(@target).send(update)
end
@@ -184,7 +184,7 @@ module Custodian
# Most of the mess of this method is ensuring there is some
# "helpful" data in the detail-field of the alert.
#
- def _get_alert( failure )
+ def _get_alert(failure)
#
# The subject of an alert MUST be one of:
@@ -198,9 +198,9 @@ module Custodian
#
subject = @test.target
- if ( subject =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ ) ||
- ( subject =~ /^([0-9a-f:]+)$/ )
- res = Custodian::Util::DNS.ip_to_hostname( subject )
+ if (subject =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/) ||
+ (subject =~ /^([0-9a-f:]+)$/)
+ res = Custodian::Util::DNS.ip_to_hostname(subject)
if res
subject = res
end
@@ -256,7 +256,7 @@ module Custodian
#
# Determine if this is inside/outside the bytemark network
#
- location = expand_inside_bytemark( test_host )
+ location = expand_inside_bytemark(test_host)
if !location.nil? && location.length
alert.detail = "#{alert.detail}\n#{location}"
end
@@ -274,7 +274,7 @@ module Custodian
# or not.
#
#
- def expand_inside_bytemark( host )
+ def expand_inside_bytemark(host)
#
# If the host is a URL then we need to work with the hostname component alone.
@@ -296,11 +296,11 @@ module Custodian
#
# Resolve the target to an IP, unless it is already an address.
#
- if ( target =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ ) ||
- ( target =~ /^([0-9a-f:]+)$/ )
+ if (target =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/) ||
+ (target =~ /^([0-9a-f:]+)$/)
resolved = target
else
- resolved = Custodian::Util::DNS.hostname_to_ip( target )
+ resolved = Custodian::Util::DNS.hostname_to_ip(target)
end
@@ -313,14 +313,14 @@ module Custodian
#
# Return the formatted message
#
- if Custodian::Util::Bytemark.inside?( resolved.to_s )
- if ( resolved == target )
+ if Custodian::Util::Bytemark.inside?(resolved.to_s)
+ if (resolved == target)
return "<p>#{host} is inside the Bytemark network.</p>"
else
return "<p>#{host} resolves to #{resolved} which is inside the Bytemark network.</p>"
end
else
- if ( resolved == target )
+ if (resolved == target)
return "<p>#{host} is OUTSIDE the Bytemark network.</p>"
else
return "<p>#{host} resolves to #{resolved} which is OUTSIDE the Bytemark network.</p>"
diff --git a/lib/custodian/alerts/redis-state.rb b/lib/custodian/alerts/redis-state.rb
index 27bb2c4..bef0015 100644
--- a/lib/custodian/alerts/redis-state.rb
+++ b/lib/custodian/alerts/redis-state.rb
@@ -29,14 +29,14 @@ module Custodian
# Constructor - save the test-object away & instantiate
# the redis connection.
#
- def initialize( obj )
+ def initialize(obj)
begin
require 'rubygems'
require 'redis'
require 'json'
- @redis = Redis.new(:host => @target )
+ @redis = Redis.new(:host => @target)
rescue
puts 'ERROR Loading redis rubygem!'
@@ -52,7 +52,7 @@ module Custodian
#
def raise
- return unless( @redis )
+ return unless(@redis)
tmp = {}
tmp['time'] = Time.now.to_i
@@ -63,8 +63,8 @@ module Custodian
tmp['test' ] = @test.to_s
tmp['class' ] = @test.class
- @redis.lpush( 'recent-tests', tmp.to_json)
- @redis.ltrim( 'recent-tests', 0, 100 )
+ @redis.lpush('recent-tests', tmp.to_json)
+ @redis.ltrim('recent-tests', 0, 100)
end
@@ -75,7 +75,7 @@ module Custodian
#
def clear
- return unless( @redis )
+ return unless(@redis)
tmp = {}
@@ -87,8 +87,8 @@ module Custodian
tmp['test' ] = @test.to_s
tmp['class' ] = @test.class
- @redis.lpush( 'recent-tests', tmp.to_json)
- @redis.ltrim( 'recent-tests', 0, 100 )
+ @redis.lpush('recent-tests', tmp.to_json)
+ @redis.ltrim('recent-tests', 0, 100)
end
register_alert_type 'redis'
diff --git a/lib/custodian/alerts/smtp.rb b/lib/custodian/alerts/smtp.rb
index 38ef29e..e6cfef0 100644
--- a/lib/custodian/alerts/smtp.rb
+++ b/lib/custodian/alerts/smtp.rb
@@ -20,7 +20,7 @@ module Custodian
#
# Constructor - save the test-object away.
#
- def initialize( obj )
+ def initialize(obj)
@test = obj
end
@@ -33,7 +33,7 @@ module Custodian
subject = "#{test.target} alert #{test.get_type}-test - #{test.error}"
body = "The alert has raised, with the following details:\n#{test.error}\nRegards\n"
- _send_mail( @target, subject, body )
+ _send_mail(@target, subject, body)
end
@@ -45,7 +45,7 @@ module Custodian
subject = "#{test.target} cleared #{test.get_type}-test"
body = "The alert has cleared\nRegards\n"
- _send_mail( @target, subject, body )
+ _send_mail(@target, subject, body)
end
@@ -53,7 +53,7 @@ module Custodian
#
# Send an email
#
- def _send_mail( to, subject, body )
+ def _send_mail(to, subject, body)
msg = <<END_OF_MESSAGE
From: #{to}
To: #{to}
@@ -63,7 +63,7 @@ Subject: #{subject}
END_OF_MESSAGE
Net::SMTP.start('127.0.0.1') do |smtp|
- smtp.send_message( msg, to, to)
+ smtp.send_message(msg, to, to)
end
end
diff --git a/lib/custodian/parser.rb b/lib/custodian/parser.rb
index 6942da8..b0626f5 100644
--- a/lib/custodian/parser.rb
+++ b/lib/custodian/parser.rb
@@ -87,10 +87,10 @@ module Custodian
end
- if ( response.code.to_i != 200 )
+ if (response.code.to_i != 200)
puts "Status code of #{uri_str} was #{response.code}"
puts 'ABORTING'
- exit( 0 )
+ exit(0)
end
case response
@@ -98,7 +98,7 @@ module Custodian
then
newURL = response['location'].match(/^http/)?
response['Location']:uri_str+response['Location']
- return( get_url_contents(newURL) )
+ return(get_url_contents(newURL))
else
return response.body
end
@@ -117,7 +117,7 @@ module Custodian
#
# Define a macro, from the configuration file.
#
- def define_macro( line )
+ def define_macro(line)
name = nil
val = []
@@ -138,8 +138,8 @@ module Custodian
uri = $1.dup.chomp('.')
text = get_url_contents(uri)
- text.split( /[\r\n]/ ).each do |line|
- val.push( line ) if line.length > 0
+ text.split(/[\r\n]/).each do |line|
+ val.push(line) if line.length > 0
end
elsif line =~ /\s(is|are)\s+(.*)\.+$/
@@ -153,19 +153,19 @@ module Custodian
# If there is " and " then tokenize
#
if hosts =~ /\s+and\s+/
- tmp = hosts.split( /\s+and\s+/ )
+ tmp = hosts.split(/\s+and\s+/)
tmp.each do |entry|
- val.push( entry )
+ val.push(entry)
end
else
#
# Otherwise a single host
#
- val.push( hosts )
+ val.push(hosts)
end
end
- if is_macro?( name )
+ if is_macro?(name)
raise ArgumentError, "The macro #{name} is already defined"
end
@@ -192,7 +192,7 @@ module Custodian
#
# Is the given string of text a macro?
#
- def is_macro?( name )
+ def is_macro?(name)
!(@MACROS[name]).nil?
end
@@ -201,7 +201,7 @@ module Custodian
#
# Return an array of hosts if the given string was a macro identifier.
#
- def get_macro_targets( name )
+ def get_macro_targets(name)
@MACROS[name]
end
@@ -210,7 +210,7 @@ module Custodian
#
# Return multiple copies of a line for each macro-target
#
- def expand_macro( input )
+ def expand_macro(input)
r = []
@@ -220,12 +220,12 @@ module Custodian
end
- if is_macro?( macro )
+ if is_macro?(macro)
get_macro_targets(macro).each do |host|
- r.push( "#{host} #{rest}" )
+ r.push("#{host} #{rest}")
end
else
- r.push( input )
+ r.push(input)
end
r
@@ -235,9 +235,9 @@ module Custodian
#
# Parse a single line from the configuration file.
#
- def parse_line( line )
+ def parse_line(line)
- raise ArgumentError, "Line is not a string: #{line}" unless( line.kind_of? String )
+ raise ArgumentError, "Line is not a string: #{line}" unless(line.kind_of? String)
line.chomp! if !line.nil?
@@ -246,7 +246,7 @@ module Custodian
#
# A blank line, or a comment may be skipped.
#
- return nil if ( line.nil? ) || ( line =~ /^#/ ) || ( line.length < 1 )
+ return nil if (line.nil?) || (line =~ /^#/) || (line.length < 1)
#
# Look for a time period.
@@ -267,7 +267,7 @@ module Custodian
#
# Does the hour match the period?
#
- inside = Custodian::Util::TimeSpan.inside?( p_start, p_end, hour )
+ inside = Custodian::Util::TimeSpan.inside?(p_start, p_end, hour)
#
# Should we exclude the test?
@@ -283,10 +283,10 @@ module Custodian
# Look for macro definitions, inline
#
if line =~ /^([0-9A-Z]_+)\s+are\s+fetched\s+from\s+([^\s]+)\.?/
- define_macro( line )
+ define_macro(line)
elsif line =~ /^([0-9A-Z_]+)\s+(is|are)\s+/
- define_macro( line )
+ define_macro(line)
elsif line =~ /^(\S+)\s+must\s+ping(.*)/
#
@@ -308,14 +308,14 @@ module Custodian
pre = $1.dup
post = $2.dup
new_line = "#{pre} must run ping #{post}"
- return( parse_line( new_line ) )
+ return(parse_line(new_line))
elsif line =~ /^\S+\s+must(\s+not)?\s+run\s+([^\s]+)(\s+|\.|$)/i
#
# Expand the macro if we should
#
- tests = expand_macro( line )
+ tests = expand_macro(line)
#
# The array of objects we will return to the caller.
@@ -342,10 +342,10 @@ module Custodian
# if there are multiple handlers and we should always have one -
# or an unknown job-type of course!
#
- job = Custodian::TestFactory.create( macro_expanded )
+ job = Custodian::TestFactory.create(macro_expanded)
- if job && ( job.kind_of? Array )
- ret.push( job[0].to_s )
+ if job && (job.kind_of? Array)
+ ret.push(job[0].to_s)
end
rescue => ex
raise ArgumentError, "Parsing a line to a protocol test gave the error: #{ex}"
@@ -363,13 +363,13 @@ module Custodian
#
# Parse a text-snippet, with multiple lines.
#
- def parse_lines( text )
+ def parse_lines(text)
#
# If we're given a string then split it on newline
#
- if text.kind_of?( String )
- a = text.split( /[\r\n]/ )
+ if text.kind_of?(String)
+ a = text.split(/[\r\n]/)
text = a
end
@@ -379,7 +379,7 @@ module Custodian
# Split on newline
#
text.each do |line|
- ret = parse_line( line )
+ ret = parse_line(line)
#
# The return value from the parse_line method
@@ -392,9 +392,9 @@ module Custodian
# The line was a comment.
#
#
- if ret.kind_of?( Array )
+ if ret.kind_of?(Array)
ret.each do |probe|
- @jobs.push( probe )
+ @jobs.push(probe)
end
end
end
@@ -409,20 +409,20 @@ module Custodian
#
# This updates our @jobs array with the tests.
#
- def parse_file( filename )
+ def parse_file(filename)
raise ArgumentError, 'Missing configuration file!' if filename.nil?
- raise ArgumentError, "File not found: #{@file}" unless File.exist?( filename)
+ raise ArgumentError, "File not found: #{@file}" unless File.exist?(filename)
#
# Read the configuration file.
#
- out = File.open( filename, 'r') {|file| file.readlines.collect}
+ out = File.open(filename, 'r') {|file| file.readlines.collect}
#
# Parse it
#
- parse_lines( out )
+ parse_lines(out)
end
diff --git a/lib/custodian/protocoltest/dns.rb b/lib/custodian/protocoltest/dns.rb
index 7f4b997..add4a87 100644
--- a/lib/custodian/protocoltest/dns.rb
+++ b/lib/custodian/protocoltest/dns.rb
@@ -37,7 +37,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -64,15 +64,15 @@ module Custodian
#
# Ensure we had all the data.
#
- raise ArgumentError, 'Missing host to resolve' unless( @resolve_name )
- raise ArgumentError, 'Missing type of record to lookup' unless( @resolve_type )
- raise ArgumentError, 'Missing expected results' unless( @resolve_expected )
- raise ArgumentError, "Uknown record type: #{@resolve_type}" unless( @resolve_type =~ /^(A|NS|MX|AAAA)$/ )
+ raise ArgumentError, 'Missing host to resolve' unless(@resolve_name)
+ raise ArgumentError, 'Missing type of record to lookup' unless(@resolve_type)
+ raise ArgumentError, 'Missing expected results' unless(@resolve_expected)
+ raise ArgumentError, "Uknown record type: #{@resolve_type}" unless(@resolve_type =~ /^(A|NS|MX|AAAA)$/)
#
# The host to query against
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
end
@@ -106,7 +106,7 @@ module Custodian
#
# Do the lookup
#
- results = resolve_via( @host, resolve_type, resolve_name, period )
+ results = resolve_via(@host, resolve_type, resolve_name, period)
return false if results.nil?
#
@@ -126,12 +126,12 @@ module Custodian
#
# Resolve an IP
#
- def resolve_via( server, ltype, name, period )
+ def resolve_via(server, ltype, name, period)
results = []
begin
- timeout( period ) do
+ timeout(period) do
begin
#
@@ -147,16 +147,16 @@ module Custodian
case ltype
when /^A$/ then
- dns.getresources(name, Resolv::DNS::Resource::IN::A).map{ |r| results.push( r.address.to_s ) }
+ dns.getresources(name, Resolv::DNS::Resource::IN::A).map{ |r| results.push(r.address.to_s) }
when /^AAAA$/ then
- dns.getresources(name, Resolv::DNS::Resource::IN::AAAA).map{ |r| results.push( r.address.to_s ) }
+ dns.getresources(name, Resolv::DNS::Resource::IN::AAAA).map{ |r| results.push(r.address.to_s) }
when /^NS$/ then
- dns.getresources(name, Resolv::DNS::Resource::IN::NS).map{ |r| results.push( Resolv.getaddresses( r.name.to_s ) ) }
+ dns.getresources(name, Resolv::DNS::Resource::IN::NS).map{ |r| results.push(Resolv.getaddresses(r.name.to_s)) }
when /^MX$/ then
- dns.getresources(name, Resolv::DNS::Resource::IN::MX).map{ |r| results.push( Resolv.getaddresses( r.exchange.to_s ) ) }
+ dns.getresources(name, Resolv::DNS::Resource::IN::MX).map{ |r| results.push(Resolv.getaddresses(r.exchange.to_s)) }
else
@error = "Unknown record type to resolve: '#{ltype}'"
diff --git a/lib/custodian/protocoltest/dnsbl.rb b/lib/custodian/protocoltest/dnsbl.rb
index d307470..6d55260 100644
--- a/lib/custodian/protocoltest/dnsbl.rb
+++ b/lib/custodian/protocoltest/dnsbl.rb
@@ -24,14 +24,14 @@ module Custodian
#
# Save away state from the configuration line.
#
- def initialize( line )
+ def initialize(line)
@line = line
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
# Ensure the host is an IP address.
#
- raise ArgumentError, 'The target must be an IP address' unless( @host =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ )
+ raise ArgumentError, 'The target must be an IP address' unless(@host =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/)
#
# See which blacklist(s) we're testing against.
@@ -73,7 +73,7 @@ module Custodian
# The error is empty.
@error = nil
- @zones.split( ',' ).each do |zone|
+ @zones.split(',').each do |zone|
#
# Convert the IP to be looked up.
@@ -85,9 +85,9 @@ module Custodian
name = "#{$4}.#{$3}.#{$2}.#{$1}.#{zone}"
- result = Custodian::Util::DNS.hostname_to_ip( name )
+ result = Custodian::Util::DNS.hostname_to_ip(name)
- if ( !result.nil? ) && ( result.length > 0 )
+ if (!result.nil?) && (result.length > 0)
@error = "IP #{@host} listed in blacklist #{zone}. Lookup of #{name} lead to result: #{result}"
return true
end
diff --git a/lib/custodian/protocoltest/ftp.rb b/lib/custodian/protocoltest/ftp.rb
index 921de62..ddefe45 100644
--- a/lib/custodian/protocoltest/ftp.rb
+++ b/lib/custodian/protocoltest/ftp.rb
@@ -21,7 +21,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -31,7 +31,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
if @host =~ /^ftp:\/\/([^\/]+)\/?/
@host = $1.dup
end
@@ -76,7 +76,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port, /^220/, true )
+ run_test_internal(@host, @port, /^220/, true)
end
diff --git a/lib/custodian/protocoltest/http.rb b/lib/custodian/protocoltest/http.rb
index 6ed3c5b..7bbc3e2 100644
--- a/lib/custodian/protocoltest/http.rb
+++ b/lib/custodian/protocoltest/http.rb
@@ -38,7 +38,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -48,7 +48,7 @@ module Custodian
#
# Save the URL
#
- @url = line.split( /\s+/)[0]
+ @url = line.split(/\s+/)[0]
@host = @url
#
@@ -90,8 +90,8 @@ module Custodian
#
# Get the schema of the URL
#
- u = URI.parse( @url )
- if ( u.scheme != test_type )
+ u = URI.parse(@url)
+ if (u.scheme != test_type)
raise ArgumentError, "The test case has a different protocol in the URI than that which we're testing: #{@line} - \"#{test_type} != #{u.scheme}\""
end
@@ -222,7 +222,7 @@ module Custodian
# running with cache-busting.
#
if @cache_busting
- u = URI.parse( test_url )
+ u = URI.parse(test_url)
if ! u.query
u.query = "ctime=#{Time.now.to_i}"
test_url = u.to_s
@@ -268,7 +268,7 @@ module Custodian
protocol_msg = (resolve_mode == :ipv4 ? 'IPv4' : 'IPv6')
begin
- timeout( period ) do
+ timeout(period) do
c.perform
status = c.response_code
content = c.body_str
diff --git a/lib/custodian/protocoltest/imap.rb b/lib/custodian/protocoltest/imap.rb
index fb80305..3512cd5 100644
--- a/lib/custodian/protocoltest/imap.rb
+++ b/lib/custodian/protocoltest/imap.rb
@@ -22,7 +22,7 @@ module Custodian
#
# Ensure we received a port to run the test against.
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -32,7 +32,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
@@ -76,7 +76,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port, /OK/i, true )
+ run_test_internal(@host, @port, /OK/i, true)
end
diff --git a/lib/custodian/protocoltest/jabber.rb b/lib/custodian/protocoltest/jabber.rb
index 916f15f..ba94499 100644
--- a/lib/custodian/protocoltest/jabber.rb
+++ b/lib/custodian/protocoltest/jabber.rb
@@ -22,7 +22,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -32,7 +32,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
# Is this test inverted?
@@ -74,7 +74,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port, nil, false )
+ run_test_internal(@host, @port, nil, false)
end
diff --git a/lib/custodian/protocoltest/ldap.rb b/lib/custodian/protocoltest/ldap.rb
index a5f6605..ed75ae7 100644
--- a/lib/custodian/protocoltest/ldap.rb
+++ b/lib/custodian/protocoltest/ldap.rb
@@ -21,7 +21,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line.
@@ -31,7 +31,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
# The username/password
@@ -101,7 +101,7 @@ module Custodian
begin
# Connect.
- ldap = LDAP::Conn.new( @host, @port )
+ ldap = LDAP::Conn.new(@host, @port)
ldap.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
# Hardwired search is bad..
@@ -111,7 +111,7 @@ module Custodian
attrs = ['sn', 'cn']
# Bind.
- ldap.bind( @ldap_user, @ldap_pass )
+ ldap.bind(@ldap_user, @ldap_pass)
if ldap.bound?
#
diff --git a/lib/custodian/protocoltest/mx.rb b/lib/custodian/protocoltest/mx.rb
index 61e838c..a9cac62 100644
--- a/lib/custodian/protocoltest/mx.rb
+++ b/lib/custodian/protocoltest/mx.rb
@@ -20,7 +20,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
# Save the line away
@line = line
@@ -69,11 +69,11 @@ module Custodian
# Lookup the MX record
#
begin
- timeout( period ) do
+ timeout(period) do
Resolv::DNS.open do |dns|
ress = dns.getresources(@host, Resolv::DNS::Resource::IN::MX)
- ress.map { |r| mx.push( IPSocket.getaddress(r.exchange.to_s) ) }
+ ress.map { |r| mx.push(IPSocket.getaddress(r.exchange.to_s)) }
end
end
rescue Timeout::Error => e
@@ -110,7 +110,7 @@ module Custodian
begin
timeout(period) do
begin
- socket = TCPSocket.new( backend, 25 )
+ socket = TCPSocket.new(backend, 25)
read = socket.sysread(1024)
# trim to a sane length & strip newlines.
diff --git a/lib/custodian/protocoltest/mysql.rb b/lib/custodian/protocoltest/mysql.rb
index 7abc28f..ce63639 100644
--- a/lib/custodian/protocoltest/mysql.rb
+++ b/lib/custodian/protocoltest/mysql.rb
@@ -22,7 +22,7 @@ module Custodian
#
# Ensure we received a port to run the test against.
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -32,7 +32,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
@@ -76,7 +76,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port )
+ run_test_internal(@host, @port)
end
diff --git a/lib/custodian/protocoltest/named.rb b/lib/custodian/protocoltest/named.rb
index 4c1b134..321c9d5 100644
--- a/lib/custodian/protocoltest/named.rb
+++ b/lib/custodian/protocoltest/named.rb
@@ -22,7 +22,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -32,7 +32,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
# Is this test inverted?
@@ -74,7 +74,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port, nil, false )
+ run_test_internal(@host, @port, nil, false)
end
diff --git a/lib/custodian/protocoltest/openproxy.rb b/lib/custodian/protocoltest/openproxy.rb
index 04fe833..4beaaca 100644
--- a/lib/custodian/protocoltest/openproxy.rb
+++ b/lib/custodian/protocoltest/openproxy.rb
@@ -29,7 +29,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -39,7 +39,7 @@ module Custodian
#
# Save the target
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
# Is this test inverted?
@@ -84,7 +84,7 @@ module Custodian
period = settings.timeout
begin
- timeout( period ) do
+ timeout(period) do
begin
c = Curl::Easy.new
c.follow_location = true
@@ -121,7 +121,7 @@ module Custodian
# A this point we've either had an exception, or we've
# got a result.
#
- if ( @status.to_i == 200 )
+ if (@status.to_i == 200)
return true
else
@error = "Proxy fetch of http://google.com/ via #{@host} failed"
diff --git a/lib/custodian/protocoltest/ping.rb b/lib/custodian/protocoltest/ping.rb
index 7d3d802..c2c9a04 100644
--- a/lib/custodian/protocoltest/ping.rb
+++ b/lib/custodian/protocoltest/ping.rb
@@ -26,7 +26,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -36,7 +36,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
# Is this test inverted?
@@ -71,7 +71,7 @@ module Custodian
#
binary = nil
binary = './bin/multi-ping'
- binary = '/usr/bin/multi-ping' if File.exist?( '/usr/bin/multi-ping' )
+ binary = '/usr/bin/multi-ping' if File.exist?('/usr/bin/multi-ping')
if binary.nil?
@error = "Failed to find '/usr/bin/multi-ping'"
@@ -108,9 +108,9 @@ module Custodian
# Does the name look like an IP?
#
begin
- x = IPAddr.new( @host )
+ x = IPAddr.new(@host)
if x.ipv4? or x.ipv6?
- ips.push( @host )
+ ips.push(@host)
end
rescue ArgumentError
end
@@ -137,16 +137,16 @@ module Custodian
# look it up, as both IPv4 and IPv6.
#
begin
- timeout( period ) do
+ timeout(period) do
Resolv::DNS.open do |dns|
if do_ipv4
ress = dns.getresources(@host, Resolv::DNS::Resource::IN::A)
- ress.map { |r| ips.push( r.address.to_s ) }
+ ress.map { |r| ips.push(r.address.to_s) }
end
if do_ipv6
ress = dns.getresources(@host, Resolv::DNS::Resource::IN::AAAA)
- ress.map { |r| ips.push( r.address.to_s ) }
+ ress.map { |r| ips.push(r.address.to_s) }
end
end
end
@@ -171,7 +171,7 @@ module Custodian
# were given.
#
ips.each do |ip|
- if ( system( binary, ip ) != true )
+ if (system(binary, ip) != true)
@error = "Ping failed for #{ip} - from #{@host} "
return false
end
diff --git a/lib/custodian/protocoltest/pop3.rb b/lib/custodian/protocoltest/pop3.rb
index 3be34b3..eeb1e60 100644
--- a/lib/custodian/protocoltest/pop3.rb
+++ b/lib/custodian/protocoltest/pop3.rb
@@ -22,7 +22,7 @@ module Custodian
#
# Ensure we received a port to run the test against.
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -32,7 +32,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
@@ -76,7 +76,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port, /\+OK/i, true )
+ run_test_internal(@host, @port, /\+OK/i, true)
end
diff --git a/lib/custodian/protocoltest/postgresql.rb b/lib/custodian/protocoltest/postgresql.rb
index 2dad5cd..f97776c 100644
--- a/lib/custodian/protocoltest/postgresql.rb
+++ b/lib/custodian/protocoltest/postgresql.rb
@@ -22,7 +22,7 @@ module Custodian
#
# Ensure we received a port to run the test against.
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -32,7 +32,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
@@ -76,7 +76,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port )
+ run_test_internal(@host, @port)
end
diff --git a/lib/custodian/protocoltest/redis.rb b/lib/custodian/protocoltest/redis.rb
index d1815aa..1293cc9 100644
--- a/lib/custodian/protocoltest/redis.rb
+++ b/lib/custodian/protocoltest/redis.rb
@@ -22,7 +22,7 @@ module Custodian
#
# Ensure we received a port to run the test against.
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -32,7 +32,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
@@ -76,7 +76,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port )
+ run_test_internal(@host, @port)
end
diff --git a/lib/custodian/protocoltest/rsync.rb b/lib/custodian/protocoltest/rsync.rb
index 0f3c288..89f4e65 100644
--- a/lib/custodian/protocoltest/rsync.rb
+++ b/lib/custodian/protocoltest/rsync.rb
@@ -22,7 +22,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line.
@@ -32,7 +32,7 @@ module Custodian
#
# If the target is an URL then strip to the hostname.
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
if @host =~ /^rsync:\/\/([^\/]+)\/?/
@host = $1.dup
end
@@ -78,7 +78,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port, /^@RSYNCD/, true )
+ run_test_internal(@host, @port, /^@RSYNCD/, true)
end
diff --git a/lib/custodian/protocoltest/smtp.rb b/lib/custodian/protocoltest/smtp.rb
index 6a8cd65..b27901d 100644
--- a/lib/custodian/protocoltest/smtp.rb
+++ b/lib/custodian/protocoltest/smtp.rb
@@ -22,7 +22,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line.
@@ -32,7 +32,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
# Is this test inverted?
@@ -74,7 +74,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port, /^220/, true )
+ run_test_internal(@host, @port, /^220/, true)
end
diff --git a/lib/custodian/protocoltest/smtprelay.rb b/lib/custodian/protocoltest/smtprelay.rb
index ef07f82..0a98a9d 100644
--- a/lib/custodian/protocoltest/smtprelay.rb
+++ b/lib/custodian/protocoltest/smtprelay.rb
@@ -24,9 +24,9 @@ module Custodian
#
# Save away state from the configuration line.
#
- def initialize( line )
+ def initialize(line)
@line = line
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
# Save the port
@@ -63,8 +63,8 @@ module Custodian
def get_hostname
hostname = 'localhost.localdomain'
- if File.exist?( '/etc/hostname' )
- File.readlines('/etc/hostname' ).each do |line|
+ if File.exist?('/etc/hostname')
+ File.readlines('/etc/hostname').each do |line|
hostname = line if !line.nil?
hostname.chomp!
end
@@ -86,7 +86,7 @@ module Custodian
begin
- Net::SMTP.start(@host,@port, get_hostname ) do |smtp|
+ Net::SMTP.start(@host,@port, get_hostname) do |smtp|
sent = smtp.send_message message, 'noreply@bytemark.co.uk', 'noreply@bytemark.co.uk'
@status = sent.status.to_s
diff --git a/lib/custodian/protocoltest/ssh.rb b/lib/custodian/protocoltest/ssh.rb
index 3d5e9fb..324f87d 100644
--- a/lib/custodian/protocoltest/ssh.rb
+++ b/lib/custodian/protocoltest/ssh.rb
@@ -23,7 +23,7 @@ module Custodian
#
# Ensure we received a port to run the test against.
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -33,7 +33,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
@@ -77,7 +77,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port, /SSH/i, true )
+ run_test_internal(@host, @port, /SSH/i, true)
end
diff --git a/lib/custodian/protocoltest/ssl.rb b/lib/custodian/protocoltest/ssl.rb
index 39a962d..dc62a77 100644
--- a/lib/custodian/protocoltest/ssl.rb
+++ b/lib/custodian/protocoltest/ssl.rb
@@ -18,7 +18,7 @@ class SSLCheck
attr_reader :errors
# This is a helper for console-debugging.
- def verbose( msg )
+ def verbose(msg)
(msg)
end
@@ -350,7 +350,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -360,7 +360,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
end
@@ -404,7 +404,7 @@ module Custodian
# If outside 10AM-5PM we don't run the test.
#
if hour < 10 || hour > 17
- puts( "Outside office hours - Not running SSL-Verification of #{@host}" )
+ puts("Outside office hours - Not running SSL-Verification of #{@host}")
return true
end
@@ -412,7 +412,7 @@ module Custodian
# Double-check we've got an SSL host
#
if ! @host =~ /^https:\/\//
- puts( 'Not an SSL URL' )
+ puts('Not an SSL URL')
return true
end
@@ -420,13 +420,13 @@ module Custodian
result = s.verify
if true == result
- puts( "SSL Verification succeeded for #{@host}" )
+ puts("SSL Verification succeeded for #{@host}")
return true
elsif result.nil?
- puts( "SSL Verification returned no result (timeout?) #{@host}" )
+ puts("SSL Verification returned no result (timeout?) #{@host}")
return true
else
- puts( "SSL Verification for #{@host} has failed." )
+ puts("SSL Verification for #{@host} has failed.")
@error = "SSL Verification for #{@host} failed: "
@error += s.errors.join("\n")
return false
diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb
index ca622bb..0f7e2b5 100644
--- a/lib/custodian/protocoltest/tcp.rb
+++ b/lib/custodian/protocoltest/tcp.rb
@@ -60,7 +60,7 @@ module Custodian
#
# Ensure we received a port to run the TCP-test against.
#
- def initialize( line )
+ def initialize(line)
#
# Save the line
@@ -70,7 +70,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
# Is this test inverted?
@@ -126,7 +126,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- ( run_test_internal( @host, @port, @banner, ( ! @banner.nil? ) ) )
+ (run_test_internal(@host, @port, @banner, (! @banner.nil?)))
end
@@ -148,7 +148,7 @@ module Custodian
#
# A failure in either version will result in a failure.
#
- def run_test_internal( host, port, banner = nil, do_read = false )
+ def run_test_internal(host, port, banner = nil, do_read = false)
#
# Get the timeout period.
@@ -165,9 +165,9 @@ module Custodian
# Does the name look like an IP?
#
begin
- x = IPAddr.new( host )
+ x = IPAddr.new(host)
if x.ipv4? or x.ipv6?
- ips.push( host )
+ ips.push(host)
end
rescue ArgumentError
#
@@ -197,17 +197,17 @@ module Custodian
# look it up, as both IPv4 and IPv6.
#
begin
- timeout( period ) do
+ timeout(period) do
Resolv::DNS.open do |dns|
if do_ipv4
ress = dns.getresources(host, Resolv::DNS::Resource::IN::A)
- ress.map { |r| ips.push( r.address.to_s ) }
+ ress.map { |r| ips.push(r.address.to_s) }
end
if do_ipv6
ress = dns.getresources(host, Resolv::DNS::Resource::IN::AAAA)
- ress.map { |r| ips.push( r.address.to_s ) }
+ ress.map { |r| ips.push(r.address.to_s) }
end
end
end
@@ -232,7 +232,7 @@ module Custodian
# were given.
#
ips.each do |ip|
- if ! run_test_internal_real( ip, port, banner, do_read )
+ if ! run_test_internal_real(ip, port, banner, do_read)
return false
#
@@ -260,7 +260,7 @@ module Custodian
# This method will ONLY ever be invoked with an IP-address for a
# destination.
#
- def run_test_internal_real( host, port, banner = nil, do_read = false )
+ def run_test_internal_real(host, port, banner = nil, do_read = false)
#
# Get the timeout period for this test.
@@ -271,7 +271,7 @@ module Custodian
begin
timeout(period) do
begin
- socket = TCPSocket.new( host, port )
+ socket = TCPSocket.new(host, port)
# read a banner from the remote server, if we're supposed to.
read = nil
@@ -293,14 +293,14 @@ module Custodian
# regexp.
if banner.kind_of? Regexp
- if ( !read.nil? ) && ( banner.match(read) )
+ if (!read.nil?) && (banner.match(read))
return true
end
end
# string.
if banner.kind_of? String
- if ( !read.nil? ) && ( read =~ /#{banner}/i )
+ if (!read.nil?) && (read =~ /#{banner}/i)
return true
end
end
diff --git a/lib/custodian/protocoltest/telnet.rb b/lib/custodian/protocoltest/telnet.rb
index f485191..a73b35c 100644
--- a/lib/custodian/protocoltest/telnet.rb
+++ b/lib/custodian/protocoltest/telnet.rb
@@ -22,7 +22,7 @@ module Custodian
#
# Constructor
#
- def initialize( line )
+ def initialize(line)
#
# Save the line.
@@ -32,7 +32,7 @@ module Custodian
#
# Save the host
#
- @host = line.split( /\s+/)[0]
+ @host = line.split(/\s+/)[0]
#
# Is this test inverted?
@@ -74,7 +74,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- run_test_internal( @host, @port, nil, false )
+ run_test_internal(@host, @port, nil, false)
end
diff --git a/lib/custodian/queue.rb b/lib/custodian/queue.rb
index 12db68d..4517c61 100644
--- a/lib/custodian/queue.rb
+++ b/lib/custodian/queue.rb
@@ -6,7 +6,7 @@
begin
require library
rescue LoadError
- ENV['DEBUG'] && puts( "Failed to load the library: #{library}" )
+ ENV['DEBUG'] && puts("Failed to load the library: #{library}")
end
end
@@ -81,7 +81,7 @@ end
#
def initialize
host = ENV['QUEUE_ADDRESS'] || '127.0.0.1'
- @redis = Redis.new( :host => host )
+ @redis = Redis.new(:host => host)
end
@@ -94,14 +94,14 @@ end
def fetch(timeout = 1)
job = nil
- while( true )
+ while(true)
- foo, job = @redis.blpop( 'queue', :timeout => timeout )
+ foo, job = @redis.blpop('queue', :timeout => timeout)
if job
return job
else
- sleep( timeout )
+ sleep(timeout)
end
end
@@ -112,7 +112,7 @@ end
# Add a new job to the queue.
#
def add(job_string)
- @redis.rpush( 'queue', job_string )
+ @redis.rpush('queue', job_string)
end
@@ -120,7 +120,7 @@ end
# How many jobs in the queue?
#
def size?
- @redis.llen( 'queue' )
+ @redis.llen('queue')
end
@@ -128,7 +128,7 @@ end
# Empty the queue, discarding all pending jobs.
#
def flush!
- @redis.del( 'queue' )
+ @redis.del('queue')
end
end
@@ -145,7 +145,7 @@ end
#
def initialize
host = ENV['QUEUE_ADDRESS'] || '127.0.0.1'
- @queue = Beanstalk::Pool.new( ["#{host}:11300" ] )
+ @queue = Beanstalk::Pool.new(["#{host}:11300" ])
end
@@ -183,7 +183,7 @@ end
#
def size?
stats = @queue.stats
- ( stats['current-jobs-ready'] || 0 )
+ (stats['current-jobs-ready'] || 0)
end
@@ -191,7 +191,7 @@ end
# Flush the queue, discarding all pending jobs.
#
def flush!
- while( fetch(1) )
+ while(fetch(1))
# nop
end
end
diff --git a/lib/custodian/settings.rb b/lib/custodian/settings.rb
index c4b11cb..5635ef3 100644
--- a/lib/custodian/settings.rb
+++ b/lib/custodian/settings.rb
@@ -35,7 +35,7 @@ module Custodian
#
# Load the configuration file; called only once.
#
- def _load( file = '/etc/custodian/custodian.cfg' )
+ def _load(file = '/etc/custodian/custodian.cfg')
@parsed = true
@settings = {}
@@ -43,12 +43,12 @@ module Custodian
#
# The global configuration file.
#
- return unless( File.exist?( file ) )
+ return unless(File.exist?(file))
#
# Load and "parse" the key=value content.
#
- File.open( file, 'r' ).each_line do |line|
+ File.open(file, 'r').each_line do |line|
next if line.nil? || line =~ /^#/
if line =~ /^(.*)=(.*)$/
key = $1.dup
@@ -66,7 +66,7 @@ module Custodian
#
# Used by the test-suite.
#
- def _store( key, val )
+ def _store(key, val)
@settings[key] = val
@parsed = true
end
@@ -83,8 +83,8 @@ module Custodian
#
# Retrieve an arbitrary key
#
- def key( name )
- _load unless( _loaded? )
+ def key(name)
+ _load unless(_loaded?)
@settings[name]
end
@@ -93,7 +93,7 @@ module Custodian
# The timeout period for each individual test.
#
def timeout
- _load unless( _loaded? )
+ _load unless(_loaded?)
if @settings['timeout']
@settings['timeout'].to_i
@@ -109,7 +109,7 @@ module Custodian
# before raising an alert.
#
def retries
- _load unless( _loaded? )
+ _load unless(_loaded?)
if @settings['retries']
@settings['retries'].to_i
@@ -129,7 +129,7 @@ module Custodian
# A delay of zero is permissable.
#
def retry_delay
- _load unless( _loaded? )
+ _load unless(_loaded?)
if @settings['retry_delay']
@settings['retry_delay'].to_i
@@ -146,7 +146,7 @@ module Custodian
# environmental variable 'QUEUE_ADDRESS'.
#
def queue_type
- _load unless( _loaded? )
+ _load unless(_loaded?)
@settings['queue_type'] || 'redis'
end
@@ -157,7 +157,7 @@ module Custodian
# The filename for the logfile.
#
def log_file
- _load unless( _loaded? )
+ _load unless(_loaded?)
@settings['log_file'] || 'custodian-dequeue.log'
end
@@ -167,7 +167,7 @@ module Custodian
# The alerter to use
#
def alerter
- _load unless( _loaded? )
+ _load unless(_loaded?)
@settings['alerter'] || 'file'
end
@@ -177,7 +177,7 @@ module Custodian
# The alert-source we send. Only used when the notifier is set to mauve.
#
def alert_source
- _load unless( _loaded? )
+ _load unless(_loaded?)
@settings['alert_source'] || 'Custodian'
end
@@ -194,8 +194,8 @@ module Custodian
#
# When the alerter is "redis" the target is the redis-server address.
#
- def alerter_target( alert )
- _load unless( _loaded? )
+ def alerter_target(alert)
+ _load unless(_loaded?)
#
@@ -203,7 +203,7 @@ module Custodian
#
# if we have something setup then use it.
if @settings["#{alert}_target"]
- return( @settings["#{alert}_target"] )
+ return(@settings["#{alert}_target"])
end
# otherwise per-test defaults.
diff --git a/lib/custodian/testfactory.rb b/lib/custodian/testfactory.rb
index 7383ca2..b28d30a 100644
--- a/lib/custodian/testfactory.rb
+++ b/lib/custodian/testfactory.rb
@@ -28,7 +28,7 @@ module Custodian
#
# The line will be like "target must run tcp|ssh|ftp|smtp .."
#
- def self.create( line )
+ def self.create(line)
raise ArgumentError, 'The type of test to create cannot be nil' if line.nil?
@@ -46,7 +46,7 @@ module Custodian
if line =~ /must\s+(not\s+)?run\s+(\S+)(\s+|\.|$)/
test_type = $2.dup
- test_type.chomp!( '.' )
+ test_type.chomp!('.')
if @@subclasses[test_type].nil?
raise ArgumentError, "There is no handler registered for the '#{test_type}' test-type"
@@ -59,7 +59,7 @@ module Custodian
@@subclasses[test_type].each do |impl|
if impl
- obj = impl.new( line )
+ obj = impl.new(line)
#
# Get the notification text, which is not specific to the test-type
@@ -67,7 +67,7 @@ module Custodian
# We do this only after we've instantiated the test.
#
if line =~ /\s+otherwise\s+'([^']+)'/
- obj.set_notification_text( $1.dup )
+ obj.set_notification_text($1.dup)
end
result.push(obj)
@@ -77,7 +77,7 @@ module Custodian
end
# return the test-types.
- return( result )
+ return(result)
else
raise "Failed to instantiate a suitable protocol-test for '#{line}'"
@@ -113,7 +113,7 @@ module Custodian
# for each handler ..
@@subclasses[name].each do |impl|
- if ( impl == self.class )
+ if (impl == self.class)
return name
end
end
@@ -145,7 +145,7 @@ module Custodian
#
# Set the user-text which is returned on error.
#
- def set_notification_text( str )
+ def set_notification_text(str)
@notification_text = str
end
diff --git a/lib/custodian/util/bytemark.rb b/lib/custodian/util/bytemark.rb
index 07e5684..db3304d 100644
--- a/lib/custodian/util/bytemark.rb
+++ b/lib/custodian/util/bytemark.rb
@@ -26,7 +26,7 @@ module Custodian
#
# Is the named target inside the Bytemark IP-range?
#
- def self.inside?( target )
+ def self.inside?(target)
inside = false
if BYTEMARK_RANGES.any?{|range| range.include?(IPAddr.new(target))}
diff --git a/lib/custodian/util/dns.rb b/lib/custodian/util/dns.rb
index 2a0c705..b93fef5 100644
--- a/lib/custodian/util/dns.rb
+++ b/lib/custodian/util/dns.rb
@@ -20,7 +20,7 @@ module Custodian
#
# Return the reverse DNS for the specified IP address, nil on failure.
#
- def DNS.ip_to_hostname( ip )
+ def DNS.ip_to_hostname(ip)
resolved = nil
#
@@ -30,9 +30,9 @@ module Custodian
period = settings.timeout
begin
- timeout( period ) do
+ timeout(period) do
begin
- resolved = Socket.getnameinfo(Socket.sockaddr_in(80, ip) ).first
+ resolved = Socket.getnameinfo(Socket.sockaddr_in(80, ip)).first
rescue SocketError
resolved = nil
end
@@ -47,7 +47,7 @@ module Custodian
#
# Convert a hostname to an IP address, return nil on failure.
#
- def DNS.hostname_to_ip( hostname )
+ def DNS.hostname_to_ip(hostname)
resolved = nil
@@ -58,7 +58,7 @@ module Custodian
period = settings.timeout
begin
- timeout( period ) do
+ timeout(period) do
begin
Socket.getaddrinfo(hostname, 'echo').each do |a|
resolved = a[3] if a
diff --git a/lib/custodian/util/ping.rb b/lib/custodian/util/ping.rb
index cf79754..f8b7c75 100644
--- a/lib/custodian/util/ping.rb
+++ b/lib/custodian/util/ping.rb
@@ -24,13 +24,13 @@ module Custodian
#
# Save the hostname away, resolve it if possible.
#
- def initialize( hostname )
+ def initialize(hostname)
raise ArgumentError, 'Hostname must not be nil' if hostname.nil?
- raise ArgumentError, 'Hostname must be a String' unless hostname.kind_of?( String )
+ raise ArgumentError, 'Hostname must be a String' unless hostname.kind_of?(String)
@hostname = hostname
- @resolved = Custodian::Util::DNS.hostname_to_ip( hostname )
+ @resolved = Custodian::Util::DNS.hostname_to_ip(hostname)
end
@@ -47,7 +47,7 @@ module Custodian
# Does the hostname resolve to an IPv4 address?
#
def is_ipv4?
- if ( ! @resolved.nil? ) && ( @resolved =~ /^([0-9]+).([0-9]+).([0-9]+).([0-9]+)$/ )
+ if (! @resolved.nil?) && (@resolved =~ /^([0-9]+).([0-9]+).([0-9]+).([0-9]+)$/)
true
else
false
@@ -59,7 +59,7 @@ module Custodian
# Does the hostname resolve to an IPv6 address?
#
def is_ipv6?
- if ( ! @resolved.nil? ) && ( @resolved =~ /^([a-f0-9:]+)$/i )
+ if (! @resolved.nil?) && (@resolved =~ /^([a-f0-9:]+)$/i)
true
else
false
@@ -75,11 +75,11 @@ module Custodian
#
def run_ping
if is_ipv6?
- if ( system( "ping6 -c 1 #{@resolved} 2>/dev/null >/dev/null" ) == true )
+ if (system("ping6 -c 1 #{@resolved} 2>/dev/null >/dev/null") == true)
return true
end
- elsif( is_ipv4? )
- if ( system( "ping -c 1 #{@resolved} 2>/dev/null >/dev/null" ) == true )
+ elsif(is_ipv4?)
+ if (system("ping -c 1 #{@resolved} 2>/dev/null >/dev/null") == true)
return true
end
else
diff --git a/lib/custodian/util/timespan.rb b/lib/custodian/util/timespan.rb
index a033675..9b79867 100644
--- a/lib/custodian/util/timespan.rb
+++ b/lib/custodian/util/timespan.rb
@@ -12,13 +12,13 @@ module Custodian
#
# Convert an hour-string into a sane integer.
#
- def TimeSpan.to_hour( desc )
+ def TimeSpan.to_hour(desc)
#
# Handle PM times.
#
- if ( desc.kind_of? String ) &&
- ( desc =~ /([0-9]+)pm$/i )
+ if (desc.kind_of? String) &&
+ (desc =~ /([0-9]+)pm$/i)
desc = $1.dup.to_i + 12
end
@@ -26,15 +26,15 @@ module Custodian
# Handle AM times.
#
if desc.kind_of? String
- desc = desc.sub( /am$/, '' )
+ desc = desc.sub(/am$/, '')
desc = desc.to_i
end
#
# Ensure within a valid range
#
- raise ArgumentError, 'Integer required for time' unless( desc.kind_of? Integer )
- raise ArgumentError, "Invalid time: #{desc}" unless( ( desc >= 0 ) && ( desc <= 23 ) )
+ raise ArgumentError, 'Integer required for time' unless(desc.kind_of? Integer)
+ raise ArgumentError, "Invalid time: #{desc}" unless((desc >= 0) && (desc <= 23))
#
@@ -51,7 +51,7 @@ module Custodian
# to a hash of hours which are inside the
# range - inclusively.
#
- def TimeSpan.to_hours( p_start, p_end )
+ def TimeSpan.to_hours(p_start, p_end)
p_start = Custodian::Util::TimeSpan.to_hour(p_start)
p_end = Custodian::Util::TimeSpan.to_hour(p_end)
@@ -67,7 +67,7 @@ module Custodian
# Iterate over the hours. Store in a hash.
#
hour = p_start
- while( hour != p_end )
+ while(hour != p_end)
valid[hour] = 1
hour += 1
hour = 0 if hour > 23
@@ -87,7 +87,7 @@ module Custodian
# Given a starting hour, such as 10pm, and an ending hour,
# such as 4am, test whether a time is within that period.
#
- def TimeSpan.inside?( p_start, p_end, cur_hour = nil)
+ def TimeSpan.inside?(p_start, p_end, cur_hour = nil)
#
# Default to the current hour, if not specified.
@@ -107,13 +107,13 @@ module Custodian
# Get the expanded hours
#
valid =
- Custodian::Util::TimeSpan.to_hours( p_start, p_end )
+ Custodian::Util::TimeSpan.to_hours(p_start, p_end)
#
# Lookup to see if the specified hour is within the
# hours between the range.
#
- ( valid[cur_hour] == 1 )
+ (valid[cur_hour] == 1)
end
end
diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb
index e5df5e5..746416f 100644
--- a/lib/custodian/worker.rb
+++ b/lib/custodian/worker.rb
@@ -67,13 +67,13 @@ module Custodian
#
# Connect to the queue, and record interesting settings away.
#
- def initialize( settings )
+ def initialize(settings)
# Save the settings
@settings = settings
# Connect to the queue
- @queue = QueueType.create( @settings.queue_type )
+ @queue = QueueType.create(@settings.queue_type)
# Get the alerter-type(s) to instantiate
@alerter = @settings.alerter
@@ -92,7 +92,7 @@ module Custodian
#
# Show a message on STDOUT if "--verbose" was specified.
#
- def log_message( msg )
+ def log_message(msg)
puts msg if ENV['VERBOSE' ]
end
@@ -103,8 +103,8 @@ module Custodian
# Process jobs from the queue - never return.
#
def run!
- while( true )
- log_message( 'Waiting for job..' )
+ while(true)
+ log_message('Waiting for job..')
process_single_job
end
end
@@ -131,8 +131,8 @@ module Custodian
#
# Create test-objects from our class-factory, and process them.
#
- Custodian::TestFactory.create( job ).each do |test|
- process_single_test( test )
+ Custodian::TestFactory.create(job).each do |test|
+ process_single_test(test)
end
end
@@ -144,11 +144,11 @@ module Custodian
#
# Any test which fails for N-times in a row will raise an alert.
#
- def process_single_test( test )
+ def process_single_test(test)
begin
- log_message( "Acquired job: #{test}" )
+ log_message("Acquired job: #{test}")
#
# The count of times this test has run, the result, and the start-time
@@ -162,9 +162,9 @@ module Custodian
#
# We exit here if we receive a single success.
#
- while ( count < ( @retry_count + 1 ) ) && ( result == false )
+ while (count < (@retry_count + 1)) && (result == false)
- log_message( "Running test - [#{count}/#{@retry_count}]" )
+ log_message("Running test - [#{count}/#{@retry_count}]")
#
# Run the test - inverting the result if we should
@@ -173,8 +173,8 @@ module Custodian
result = ! result if test.inverted
if result
- log_message( 'Test succeeed - clearing alert' )
- do_clear( test )
+ log_message('Test succeeed - clearing alert')
+ do_clear(test)
end
#
@@ -186,9 +186,9 @@ module Custodian
# The intention here is that if the test passes then there will
# be no delay. If the test fails then we'll sleep.
#
- if ( result == false ) && ( @retry_delay > 0 ) && ( count < @retry_count )
- log_message( "Sleeping for #{@retry_delay} seconds to allow cool-down" )
- sleep( @retry_delay )
+ if (result == false) && (@retry_delay > 0) && (count < @retry_count)
+ log_message("Sleeping for #{@retry_delay} seconds to allow cool-down")
+ sleep(@retry_delay)
end
#
@@ -205,14 +205,14 @@ module Custodian
#
# Duration of the test-run, in milliseconds
#
- duration = (( end_time - start_time ) * 1000.0).to_i
+ duration = ((end_time - start_time) * 1000.0).to_i
#
# Record that, if we have any alerters that are interested
# in run-times.
#
- do_duration( test, duration )
+ do_duration(test, duration)
#
@@ -223,12 +223,12 @@ module Custodian
#
# Raise the alert, passing the error message.
#
- log_message( "Test failed - alerting with #{test.error}" )
- do_raise( test )
+ log_message("Test failed - alerting with #{test.error}")
+ do_raise(test)
end
rescue => ex
- log_message( "Exception raised processing job: #{ex}" )
+ log_message("Exception raised processing job: #{ex}")
end
@@ -239,18 +239,18 @@ module Custodian
#
# Raise an alert, with each registered alerter.
#
- def do_raise( test )
- @alerter.split( ',' ).each do |alerter|
+ def do_raise(test)
+ @alerter.split(',').each do |alerter|
- log_message( "Creating alerter: #{alerter}" )
- alert = Custodian::AlertFactory.create( alerter, test )
+ log_message("Creating alerter: #{alerter}")
+ alert = Custodian::AlertFactory.create(alerter, test)
- target = @settings.alerter_target( alerter )
- alert.set_target( target )
+ target = @settings.alerter_target(alerter)
+ alert.set_target(target)
log_message("Target for alert is #{target}")
# give the alerter a reference to the settings object.
- alert.set_settings( @settings )
+ alert.set_settings(@settings)
alert.raise
end
@@ -260,17 +260,17 @@ module Custodian
#
# Clear an alert, with each registered alerter.
#
- def do_clear( test )
- @alerter.split( ',' ).each do |alerter|
- log_message( "Creating alerter: #{alerter}" )
- alert = Custodian::AlertFactory.create( alerter, test )
+ def do_clear(test)
+ @alerter.split(',').each do |alerter|
+ log_message("Creating alerter: #{alerter}")
+ alert = Custodian::AlertFactory.create(alerter, test)
- target = @settings.alerter_target( alerter )
- alert.set_target( target )
- log_message( "Target for alert is #{target}" )
+ target = @settings.alerter_target(alerter)
+ alert.set_target(target)
+ log_message("Target for alert is #{target}")
# give the alerter a reference to the settings object.
- alert.set_settings( @settings )
+ alert.set_settings(@settings)
alert.clear
end
@@ -279,19 +279,19 @@ module Custodian
#
# Log the test duration with each registered alerter.
#
- def do_duration( test, duration )
- @alerter.split( ',' ).each do |alerter|
- log_message( "Creating alerter: #{alerter}" )
- alert = Custodian::AlertFactory.create( alerter, test )
+ def do_duration(test, duration)
+ @alerter.split(',').each do |alerter|
+ log_message("Creating alerter: #{alerter}")
+ alert = Custodian::AlertFactory.create(alerter, test)
- target = @settings.alerter_target( alerter )
- alert.set_target( target )
- log_message( "Target for alert is #{target}" )
+ target = @settings.alerter_target(alerter)
+ alert.set_target(target)
+ log_message("Target for alert is #{target}")
# give the alerter a reference to the settings object.
- alert.set_settings( @settings )
+ alert.set_settings(@settings)
- alert.duration( duration ) if alert.respond_to? 'duration'
+ alert.duration(duration) if alert.respond_to? 'duration'
end
end
@@ -300,7 +300,7 @@ module Custodian
# Process jobs until we see a failure, then stop.
#
def process_until_fail
- while( process_single_job )
+ while(process_single_job)
# nop
end
end
diff --git a/t/test-custodian-alertfactory.rb b/t/test-custodian-alertfactory.rb
index eea35ac..c18e719 100755
--- a/t/test-custodian-alertfactory.rb
+++ b/t/test-custodian-alertfactory.rb
@@ -31,8 +31,8 @@ class TestAlertFactory < Test::Unit::TestCase
# Ensure we can create each of the two alert types we care about
#
methods = []
- methods.push( 'file' )
- methods.push( 'smtp' )
+ methods.push('file')
+ methods.push('smtp')
#
# Mauve + Redis are optional
@@ -54,29 +54,29 @@ class TestAlertFactory < Test::Unit::TestCase
mauve = false
end
- methods.push( 'redis' ) if redis
- methods.push( 'mauve' ) if mauve
+ methods.push('redis') if redis
+ methods.push('mauve') if mauve
methods.each do |name|
#
# Use the factory to instantiate the correct object.
#
- obj = Custodian::AlertFactory.create( name, nil )
+ obj = Custodian::AlertFactory.create(name, nil)
#
# Get the name of the class, and ensure it matches
# what we expect.
#
a_type = obj.get_type
- assert_equal( name, a_type)
+ assert_equal(name, a_type)
#
# Ensure that the object implements the raise() + clear()
# methods we mandate.
#
- assert( obj.respond_to? 'raise' )
- assert( obj.respond_to? 'clear' )
+ assert(obj.respond_to? 'raise')
+ assert(obj.respond_to? 'clear')
end
@@ -84,17 +84,17 @@ class TestAlertFactory < Test::Unit::TestCase
# Creating an alert we don't know about is an error
#
assert_raise ArgumentError do
- obj = Custodian::AlertFactory.create( 'not found', nil )
+ obj = Custodian::AlertFactory.create('not found', nil)
end
#
# A string is mandatory
#
assert_raise ArgumentError do
- obj = Custodian::AlertFactory.create( nil, nil )
+ obj = Custodian::AlertFactory.create(nil, nil)
end
assert_raise ArgumentError do
- obj = Custodian::AlertFactory.create( [], nil )
+ obj = Custodian::AlertFactory.create([], nil)
end
end
diff --git a/t/test-custodian-parser.rb b/t/test-custodian-parser.rb
index bbdb8ad..514f2a4 100755
--- a/t/test-custodian-parser.rb
+++ b/t/test-custodian-parser.rb
@@ -51,8 +51,8 @@ class TestCustodianParser < Test::Unit::TestCase
def test_period
parser = Custodian::Parser.new
- result = parser.parse_line( 'example.vm.bytemark.co.uk must run ping except between 00-23' )
- assert( result.nil? )
+ result = parser.parse_line('example.vm.bytemark.co.uk must run ping except between 00-23')
+ assert(result.nil?)
end
@@ -72,20 +72,20 @@ class TestCustodianParser < Test::Unit::TestCase
parser = Custodian::Parser.new
# 1.a. Comment lines return nil.
- result = parser.parse_line( '# this is a comment' )
- assert( result.nil? )
+ result = parser.parse_line('# this is a comment')
+ assert(result.nil?)
# 1.b. Non-strings are an error
assert_raise ArgumentError do
- result = parser.parse_line( nil )
+ result = parser.parse_line(nil)
end
# 1.c. Adding a test will return an array of test-objects.
- result = parser.parse_line( "smtp.bytemark.co.uk must run smtp on 25 otherwise 'failure'." )
- assert( !result.nil? )
- assert( result.kind_of? Array )
- assert( result.size == 1 )
+ result = parser.parse_line("smtp.bytemark.co.uk must run smtp on 25 otherwise 'failure'.")
+ assert(!result.nil?)
+ assert(result.kind_of? Array)
+ assert(result.size == 1)
#
@@ -94,15 +94,15 @@ class TestCustodianParser < Test::Unit::TestCase
parser = Custodian::Parser.new
# 2.a. Comment lines return nil.
tmp = []
- tmp.push( '# This is a comment..' )
- assert( parser.parse_lines( tmp ).nil? )
+ tmp.push('# This is a comment..')
+ assert(parser.parse_lines(tmp).nil?)
# 2.b. Adding a test will return an array of test-objects.
tmp = []
- tmp.push( "smtp.bytemark.co.uk must run ssh on 22 otherwise 'oops'." )
- ret = parser.parse_lines( tmp )
- assert( ret.kind_of? Array )
- assert( ret.size == 1 )
+ tmp.push("smtp.bytemark.co.uk must run ssh on 22 otherwise 'oops'.")
+ ret = parser.parse_lines(tmp)
+ assert(ret.kind_of? Array)
+ assert(ret.size == 1)
#
# 3. By lines
@@ -113,16 +113,16 @@ class TestCustodianParser < Test::Unit::TestCase
# This is a comment
# This is also a fine comment
EOF
- assert( parser.parse_lines( str ).nil? )
+ assert(parser.parse_lines(str).nil?)
# 3.b. Adding a test will return an array of test-objects.
str = <<EOF
smtp.bytemark.co.uk must run smtp on 25.
google.com must run ping otherwise 'internet broken?'.
EOF
- ret = parser.parse_lines( str )
- assert( ret.kind_of? Array )
- assert( ret.size == 1 )
+ ret = parser.parse_lines(str)
+ assert(ret.kind_of? Array)
+ assert(ret.size == 1)
end
@@ -147,15 +147,15 @@ EOF
#
# Test the parser with this text
#
- parser.parse_lines( text )
+ parser.parse_lines(text)
#
# We should now have two macros.
#
macros = parser.macros
- assert( ! macros.empty? )
- assert( macros.size == 2 )
+ assert(! macros.empty?)
+ assert(macros.size == 2)
end
@@ -172,21 +172,21 @@ EOF
# Input text
#
text = []
- text.push( 'FOO is kvm1.vm.bytemark.co.uk.' )
- text.push( 'FOO2 is kvm2.vm.bytemark.co.uk.' )
+ text.push('FOO is kvm1.vm.bytemark.co.uk.')
+ text.push('FOO2 is kvm2.vm.bytemark.co.uk.')
#
# Test the parser with this text
#
- parser.parse_lines( text )
+ parser.parse_lines(text)
#
# We should now have two macros.
#
macros = parser.macros
- assert( ! macros.empty? )
- assert( macros.size == 2 )
+ assert(! macros.empty?)
+ assert(macros.size == 2)
end
@@ -203,14 +203,14 @@ EOF
# Input text to parse.
#
text = []
- text.push( 'FOO is kvm1.vm.bytemark.co.uk.' )
- text.push( 'FOO is kvm2.vm.bytemark.co.uk.' )
+ text.push('FOO is kvm1.vm.bytemark.co.uk.')
+ text.push('FOO is kvm2.vm.bytemark.co.uk.')
#
# Test the parser with this text
#
assert_raise ArgumentError do
- parser.parse_lines( text )
+ parser.parse_lines(text)
end
@@ -218,8 +218,8 @@ EOF
# We should now have one macro.
#
macros = parser.macros
- assert( ! macros.empty? )
- assert( macros.size == 1 )
+ assert(! macros.empty?)
+ assert(macros.size == 1)
end
@@ -235,42 +235,42 @@ EOF
#
parser = Custodian::Parser.new
macros = parser.macros
- assert( macros.empty? )
+ assert(macros.empty?)
#
# Expand a line - which should result in no change
# as the line does not involve a known-macro
#
in_txt = 'example.bytemark.co.uk must run smtp.'
- out_txt = parser.expand_macro( in_txt )
+ out_txt = parser.expand_macro(in_txt)
#
# The difference is the return value will be an array
#
- assert( out_txt.kind_of? Array )
- assert( out_txt.size == 1 )
- assert( out_txt[0] == in_txt )
+ assert(out_txt.kind_of? Array)
+ assert(out_txt.size == 1)
+ assert(out_txt[0] == in_txt)
#
# Now define a macro
#
- parser.parse_line( 'TARGET is example1.bytemark.co.uk and example2.bytemark.co.uk.' )
+ parser.parse_line('TARGET is example1.bytemark.co.uk and example2.bytemark.co.uk.')
macros = parser.macros
- assert( !macros.empty? )
+ assert(!macros.empty?)
#
# Now we have a two-host macro, repeat the expansion
#
- ret = parser.expand_macro( 'TARGET must run smtp on 25.' )
+ ret = parser.expand_macro('TARGET must run smtp on 25.')
#
# The result should be an array
#
- assert( ret.kind_of? Array )
- assert_equal( ret.size, 2 )
- assert( ret[0] =~ /example1/)
- assert( ret[1] =~ /example2/)
+ assert(ret.kind_of? Array)
+ assert_equal(ret.size, 2)
+ assert(ret[0] =~ /example1/)
+ assert(ret[1] =~ /example2/)
end
@@ -298,17 +298,17 @@ EOF
#
# Create the new parser
#
- obj = Custodian::TestFactory.create( str )
+ obj = Custodian::TestFactory.create(str)
- assert( !obj.nil? )
- assert( obj.kind_of? Array )
- assert( obj.size == 1 )
- assert_equal( obj[0].to_s, str )
+ assert(!obj.nil?)
+ assert(obj.kind_of? Array)
+ assert(obj.size == 1)
+ assert_equal(obj[0].to_s, str)
if follow
- assert( obj[0].follow_redirects? )
+ assert(obj[0].follow_redirects?)
else
- assert( ! obj[0].follow_redirects? )
+ assert(! obj[0].follow_redirects?)
end
end
end
@@ -337,17 +337,17 @@ EOF
#
# Create the new parser
#
- obj = Custodian::TestFactory.create( str )
+ obj = Custodian::TestFactory.create(str)
- assert( !obj.nil? )
- assert( obj.kind_of? Array )
- assert( obj.size == 1 )
- assert_equal( obj[0].to_s, str )
+ assert(!obj.nil?)
+ assert(obj.kind_of? Array)
+ assert(obj.size == 1)
+ assert_equal(obj[0].to_s, str)
if cb
- assert( obj[0].cache_busting? )
+ assert(obj[0].cache_busting?)
else
- assert( ! obj[0].cache_busting? )
+ assert(! obj[0].cache_busting?)
end
end
end
@@ -383,17 +383,17 @@ EOF
#
# Create the new parser
#
- obj = Custodian::TestFactory.create( str )
+ obj = Custodian::TestFactory.create(str)
- assert( !obj.nil? )
- assert( obj.kind_of? Array )
- assert( obj.size == 1 )
- assert_equal( obj[0].to_s, str )
+ assert(!obj.nil?)
+ assert(obj.kind_of? Array)
+ assert(obj.size == 1)
+ assert_equal(obj[0].to_s, str)
if fail.nil?
- assert( obj[0].get_notification_text.nil? )
+ assert(obj[0].get_notification_text.nil?)
else
- assert_equal( obj[0].get_notification_text, fail )
+ assert_equal(obj[0].get_notification_text, fail)
end
end
diff --git a/t/test-custodian-queue.rb b/t/test-custodian-queue.rb
index bec83e2..bcd615c 100755
--- a/t/test-custodian-queue.rb
+++ b/t/test-custodian-queue.rb
@@ -40,7 +40,7 @@ class TestCustodianQueue < Test::Unit::TestCase
# creation will fail
assert_raise RuntimeError do
- t = Custodian::QueueType.create( 'foo' )
+ t = Custodian::QueueType.create('foo')
end
end
@@ -50,7 +50,7 @@ class TestCustodianQueue < Test::Unit::TestCase
def test_redis
q = nil
assert_nothing_raised do
- q = Custodian::QueueType.create( 'redis' )
+ q = Custodian::QueueType.create('redis')
end
#
@@ -68,7 +68,7 @@ class TestCustodianQueue < Test::Unit::TestCase
def test_beanstalkd
q = nil
assert_nothing_raised do
- q = Custodian::QueueType.create( 'redis' )
+ q = Custodian::QueueType.create('redis')
end
#
diff --git a/t/test-custodian-settings.rb b/t/test-custodian-settings.rb
index 1923b0f..74f881b 100755
--- a/t/test-custodian-settings.rb
+++ b/t/test-custodian-settings.rb
@@ -32,9 +32,9 @@ class TestConfigurationSingleton < Test::Unit::TestCase
a = Custodian::Settings.instance
b = Custodian::Settings.instance
- assert( a )
- assert( b )
- assert_equal( a.object_id, b.object_id )
+ assert(a)
+ assert(b)
+ assert_equal(a.object_id, b.object_id)
end
@@ -47,37 +47,37 @@ class TestConfigurationSingleton < Test::Unit::TestCase
# retry delay - probably unset.
a = settings.retry_delay
- assert( a.class == Fixnum )
+ assert(a.class == Fixnum)
# store a number
- settings._store( 'retry_delay', 5 )
+ settings._store('retry_delay', 5)
a = settings.retry_delay
- assert( a.class == Fixnum )
- assert( a == 5 )
+ assert(a.class == Fixnum)
+ assert(a == 5)
# store a string
- settings._store( 'retry_delay', '35' )
+ settings._store('retry_delay', '35')
a = settings.retry_delay
- assert( a.class == Fixnum )
- assert( a == 35 )
+ assert(a.class == Fixnum)
+ assert(a == 35)
# timeout - probably unset.
a = settings.timeout
- assert( a.class == Fixnum )
+ assert(a.class == Fixnum)
# store a number
- settings._store( 'timeout', 5 )
+ settings._store('timeout', 5)
a = settings.timeout
- assert( a.class == Fixnum )
- assert( a == 5 )
+ assert(a.class == Fixnum)
+ assert(a == 5)
# store a string
- settings._store( 'timeout', '35' )
+ settings._store('timeout', '35')
a = settings.timeout
- assert( a.class == Fixnum )
- assert( a == 35 )
+ assert(a.class == Fixnum)
+ assert(a == 35)
end
diff --git a/t/test-custodian-testfactory.rb b/t/test-custodian-testfactory.rb
index af3e3b3..bde76f2 100755
--- a/t/test-custodian-testfactory.rb
+++ b/t/test-custodian-testfactory.rb
@@ -28,11 +28,11 @@ class TestTestFactory < Test::Unit::TestCase
def test_init
assert_raise ArgumentError do
- obj = Custodian::TestFactory.create( nil, nil )
+ obj = Custodian::TestFactory.create(nil, nil)
end
assert_raise ArgumentError do
- obj = Custodian::TestFactory.create( [], nil )
+ obj = Custodian::TestFactory.create([], nil)
end
@@ -45,15 +45,15 @@ class TestTestFactory < Test::Unit::TestCase
def test_ftp_uri
assert_nothing_raised do
- assert( Custodian::TestFactory.create( 'ftp.example.com must run ftp.' ) )
- assert( Custodian::TestFactory.create( 'ftp://ftp.example.com/ must run ftp.' ) )
- assert( Custodian::TestFactory.create( 'ftp://ftp.example.com/ must run ftp on 21.' ) )
- assert( Custodian::TestFactory.create( "ftp://ftp.example.com/ must run ftp on 21 otherwise 'xxx'." ) )
+ assert(Custodian::TestFactory.create('ftp.example.com must run ftp.'))
+ assert(Custodian::TestFactory.create('ftp://ftp.example.com/ must run ftp.'))
+ assert(Custodian::TestFactory.create('ftp://ftp.example.com/ must run ftp on 21.'))
+ assert(Custodian::TestFactory.create("ftp://ftp.example.com/ must run ftp on 21 otherwise 'xxx'."))
end
- assert( Custodian::TestFactory.create( 'ftp.example.com must run ftp.' )[0].target == 'ftp.example.com' )
- assert( Custodian::TestFactory.create( 'ftp://ftp.example.com/ must run ftp.' )[0].target == 'ftp.example.com' )
+ assert(Custodian::TestFactory.create('ftp.example.com must run ftp.')[0].target == 'ftp.example.com')
+ assert(Custodian::TestFactory.create('ftp://ftp.example.com/ must run ftp.')[0].target == 'ftp.example.com')
#
@@ -72,12 +72,12 @@ class TestTestFactory < Test::Unit::TestCase
data.each do |str,prt|
assert_nothing_raised do
- obj = Custodian::TestFactory.create( str )
+ obj = Custodian::TestFactory.create(str)
- assert( obj.kind_of? Array )
- assert( ! obj.empty? )
- assert_equal( obj[0].get_type, 'ftp' )
- assert_equal( obj[0].port.to_s, prt )
+ assert(obj.kind_of? Array)
+ assert(! obj.empty?)
+ assert_equal(obj[0].get_type, 'ftp')
+ assert_equal(obj[0].port.to_s, prt)
end
end
@@ -104,12 +104,12 @@ class TestTestFactory < Test::Unit::TestCase
data.each do |str,prt|
assert_nothing_raised do
- obj = Custodian::TestFactory.create( str )
+ obj = Custodian::TestFactory.create(str)
assert(obj)
- assert( obj.kind_of? Array )
- assert( ! obj.empty? )
- assert( obj[0].port.to_s == prt , "'#{str}' gave expected port '#{prt}'.")
+ assert(obj.kind_of? Array)
+ assert(! obj.empty?)
+ assert(obj[0].port.to_s == prt , "'#{str}' gave expected port '#{prt}'.")
end
end
@@ -124,16 +124,16 @@ class TestTestFactory < Test::Unit::TestCase
assert_nothing_raised do
- assert( Custodian::TestFactory.create( 'example.com must run rsync.' ) )
- assert( Custodian::TestFactory.create( 'ftp://example.com/ must run rsync.' ) )
- assert( Custodian::TestFactory.create( 'ftp://example.com/ must run rsync on 333.' ) )
- assert( Custodian::TestFactory.create( "ftp://example.com/ must run rsync on 3311 otherwise 'xxx'." ) )
+ assert(Custodian::TestFactory.create('example.com must run rsync.'))
+ assert(Custodian::TestFactory.create('ftp://example.com/ must run rsync.'))
+ assert(Custodian::TestFactory.create('ftp://example.com/ must run rsync on 333.'))
+ assert(Custodian::TestFactory.create("ftp://example.com/ must run rsync on 3311 otherwise 'xxx'."))
end
- assert( Custodian::TestFactory.create( 'rsync.example.com must run rsync.' )[0].target ==
- 'rsync.example.com' )
- assert( Custodian::TestFactory.create( 'rsync://rsync.example.com/ must run rsync.' )[0].target ==
- 'rsync.example.com' )
+ assert(Custodian::TestFactory.create('rsync.example.com must run rsync.')[0].target ==
+ 'rsync.example.com')
+ assert(Custodian::TestFactory.create('rsync://rsync.example.com/ must run rsync.')[0].target ==
+ 'rsync.example.com')
#
@@ -152,11 +152,11 @@ class TestTestFactory < Test::Unit::TestCase
data.each do |str,prt|
assert_nothing_raised do
- obj = Custodian::TestFactory.create( str )
+ obj = Custodian::TestFactory.create(str)
- assert( obj.kind_of? Array )
- assert( ! obj.empty? )
- assert( obj[0].port.to_s == prt , "'#{str}' gave expected port '#{prt}'.")
+ assert(obj.kind_of? Array)
+ assert(! obj.empty?)
+ assert(obj[0].port.to_s == prt , "'#{str}' gave expected port '#{prt}'.")
end
end
end
@@ -170,28 +170,28 @@ class TestTestFactory < Test::Unit::TestCase
def test_dns_handler
assert_nothing_raised do
- assert( Custodian::TestFactory.create( "a.ns.bytemark.co.uk must run dns for bytemark.co.uk resolving NS as '80.68.80.26;85.17.170.78;80.68.80.27'." ) )
+ assert(Custodian::TestFactory.create("a.ns.bytemark.co.uk must run dns for bytemark.co.uk resolving NS as '80.68.80.26;85.17.170.78;80.68.80.27'."))
end
#
# Missing record-type
#
assert_raise ArgumentError do
- Custodian::TestFactory.create( "a.ns.bytemark.co.uk must run dns for bytemark.co.uk as '80.68.80.26;85.17.170.78;80.68.80.27'." )
+ Custodian::TestFactory.create("a.ns.bytemark.co.uk must run dns for bytemark.co.uk as '80.68.80.26;85.17.170.78;80.68.80.27'.")
end
#
# Missing target
#
assert_raise ArgumentError do
- assert( Custodian::TestFactory.create( "a.ns.bytemark.co.uk must run dns resolving NS as '80.68.80.26;85.17.170.78;80.68.80.27'." ) )
+ assert(Custodian::TestFactory.create("a.ns.bytemark.co.uk must run dns resolving NS as '80.68.80.26;85.17.170.78;80.68.80.27'."))
end
#
# Missing expected results
#
assert_raise ArgumentError do
- assert( Custodian::TestFactory.create( 'a.ns.bytemark.co.uk must run dns for www.bytemark.co.uk resolving NS ' ) )
+ assert(Custodian::TestFactory.create('a.ns.bytemark.co.uk must run dns for www.bytemark.co.uk resolving NS '))
end
end
@@ -205,9 +205,9 @@ class TestTestFactory < Test::Unit::TestCase
assert_nothing_raised do
- assert( Custodian::TestFactory.create( 'example.com must not run rsync.' ) )
- assert( Custodian::TestFactory.create( 'ftp://example.com/ must not run rsync.' ) )
- assert( Custodian::TestFactory.create( 'ftp://example.com/ must not run rsync on 333.' ) )
+ assert(Custodian::TestFactory.create('example.com must not run rsync.'))
+ assert(Custodian::TestFactory.create('ftp://example.com/ must not run rsync.'))
+ assert(Custodian::TestFactory.create('ftp://example.com/ must not run rsync on 333.'))
end
@@ -228,16 +228,16 @@ class TestTestFactory < Test::Unit::TestCase
data.each do |str,inv|
assert_nothing_raised do
- obj = Custodian::TestFactory.create( str )
+ obj = Custodian::TestFactory.create(str)
- assert( obj.kind_of? Array )
- assert( ! obj.empty? )
+ assert(obj.kind_of? Array)
+ assert(! obj.empty?)
#
# Ensure we got the object, and the port was correct.
#
assert(obj, "created object via TestFactory.create('#{str}')")
- assert( obj[0].inverted == inv, "#{str} -> #{inv}" )
+ assert(obj[0].inverted == inv, "#{str} -> #{inv}")
end
end
@@ -269,14 +269,14 @@ class TestTestFactory < Test::Unit::TestCase
assert_nothing_raised do
- test_one_obj = Custodian::TestFactory.create( test_one )
- assert( !test_one_obj[0].inverted )
+ test_one_obj = Custodian::TestFactory.create(test_one)
+ assert(!test_one_obj[0].inverted)
- test_two_obj = Custodian::TestFactory.create( test_two )
- assert( test_two_obj[0].inverted, "Found inverted test for #{tst}" )
+ test_two_obj = Custodian::TestFactory.create(test_two)
+ assert(test_two_obj[0].inverted, "Found inverted test for #{tst}")
- assert_equal( tst, test_one_obj[0].get_type )
- assert_equal( tst, test_two_obj[0].get_type )
+ assert_equal(tst, test_one_obj[0].get_type)
+ assert_equal(tst, test_two_obj[0].get_type)
end
end
end
@@ -292,21 +292,21 @@ class TestTestFactory < Test::Unit::TestCase
a = []
- a.push( 'test.host.example.com must run ftp.')
- a.push( 'ftp://test.host.example.com/ must run ftp.')
- a.push( 'ftp://test.host.example.com/foo must run ftp.')
- a.push( 'test.host.example.com must run ping.')
- a.push( "test.host.example.com must run dns for bytemark.co.uk resolving NS as '80.68.80.26;85.17.170.78;80.68.80.27'.")
- a.push( 'rsync://test.host.example.com must run rsync.')
- a.push( 'rsync://test.host.example.com must run rsync.')
+ a.push('test.host.example.com must run ftp.')
+ a.push('ftp://test.host.example.com/ must run ftp.')
+ a.push('ftp://test.host.example.com/foo must run ftp.')
+ a.push('test.host.example.com must run ping.')
+ a.push("test.host.example.com must run dns for bytemark.co.uk resolving NS as '80.68.80.26;85.17.170.78;80.68.80.27'.")
+ a.push('rsync://test.host.example.com must run rsync.')
+ a.push('rsync://test.host.example.com must run rsync.')
a.each do |entry|
assert_nothing_raised do
- obj = Custodian::TestFactory.create( entry )
+ obj = Custodian::TestFactory.create(entry)
assert(obj)
- assert( obj.kind_of? Array )
- assert( ! obj.empty? )
- assert_equal( 'test.host.example.com', obj[0].target )
+ assert(obj.kind_of? Array)
+ assert(! obj.empty?)
+ assert_equal('test.host.example.com', obj[0].target)
end
end
end
diff --git a/t/test-custodian-util-bytemark.rb b/t/test-custodian-util-bytemark.rb
index 30bb480..3b17f4f 100755
--- a/t/test-custodian-util-bytemark.rb
+++ b/t/test-custodian-util-bytemark.rb
@@ -53,9 +53,9 @@ class TestBytemarkUtil < Test::Unit::TestCase
to_test.each do |name,inside|
if inside
- assert( Custodian::Util::Bytemark.inside?( name ) == true )
+ assert(Custodian::Util::Bytemark.inside?(name) == true)
else
- assert( Custodian::Util::Bytemark.inside?( name ) == false )
+ assert(Custodian::Util::Bytemark.inside?(name) == false)
end
end
diff --git a/t/test-custodian-util-dns.rb b/t/test-custodian-util-dns.rb
index 2582d94..399639b 100755
--- a/t/test-custodian-util-dns.rb
+++ b/t/test-custodian-util-dns.rb
@@ -30,27 +30,27 @@ class TestDNSUtil < Test::Unit::TestCase
#
def test_lookup
- details = Custodian::Util::DNS.hostname_to_ip( 'bytemark.co.uk' )
- assert( ( details == '2001:41c9:0:1019:81::80' ) ||
- ( details == '80.68.81.80' ) )
+ details = Custodian::Util::DNS.hostname_to_ip('bytemark.co.uk')
+ assert((details == '2001:41c9:0:1019:81::80') ||
+ (details == '80.68.81.80'))
- details = Custodian::Util::DNS.hostname_to_ip( 'www.bytemark.co.uk' )
- assert( ( details == '2001:41c9:0:1019:81::80' ) ||
- ( details == '80.68.81.80' ) )
+ details = Custodian::Util::DNS.hostname_to_ip('www.bytemark.co.uk')
+ assert((details == '2001:41c9:0:1019:81::80') ||
+ (details == '80.68.81.80'))
- details = Custodian::Util::DNS.hostname_to_ip( 'ipv4.steve.org.uk' )
- assert( details == '80.68.84.103' )
+ details = Custodian::Util::DNS.hostname_to_ip('ipv4.steve.org.uk')
+ assert(details == '80.68.84.103')
- details = Custodian::Util::DNS.hostname_to_ip( 'ipv6.steve.org.uk' )
- assert( details == '2001:41c8:10b:103::10' )
+ details = Custodian::Util::DNS.hostname_to_ip('ipv6.steve.org.uk')
+ assert(details == '2001:41c8:10b:103::10')
#
# Failure case
#
- details = Custodian::Util::DNS.hostname_to_ip( 'this.doesnot.exist' )
- assert( details.nil? )
+ details = Custodian::Util::DNS.hostname_to_ip('this.doesnot.exist')
+ assert(details.nil?)
end
@@ -63,20 +63,20 @@ class TestDNSUtil < Test::Unit::TestCase
#
# IPv6 lookup
#
- details = Custodian::Util::DNS.ip_to_hostname( '2001:41c9:0:1019:81::80' )
- assert( details =~ /bytemark(-?hosting)?\.(com|eu|co\.uk)$/i )
+ details = Custodian::Util::DNS.ip_to_hostname('2001:41c9:0:1019:81::80')
+ assert(details =~ /bytemark(-?hosting)?\.(com|eu|co\.uk)$/i)
#
# IPv4 lookup
#
- details = Custodian::Util::DNS.ip_to_hostname( '80.68.81.80' )
- assert( details =~ /bytemark(-?hosting)?\.(com|eu|co\.uk)$/i )
+ details = Custodian::Util::DNS.ip_to_hostname('80.68.81.80')
+ assert(details =~ /bytemark(-?hosting)?\.(com|eu|co\.uk)$/i)
#
# Bogus lookup - should return nil.
#
- details = Custodian::Util::DNS.ip_to_hostname( '800.683.853.348' )
- assert( details.nil? )
+ details = Custodian::Util::DNS.ip_to_hostname('800.683.853.348')
+ assert(details.nil?)
end
end
diff --git a/t/test-custodian-util-ping.rb b/t/test-custodian-util-ping.rb
index e01ef8d..8de1cd5 100755
--- a/t/test-custodian-util-ping.rb
+++ b/t/test-custodian-util-ping.rb
@@ -41,7 +41,7 @@ class TestPingUtil < Test::Unit::TestCase
# A hostname must be supplied
#
assert_raise ArgumentError do
- Custodian::Util::Ping.new( nil )
+ Custodian::Util::Ping.new(nil)
end
@@ -49,10 +49,10 @@ class TestPingUtil < Test::Unit::TestCase
# A hostname is a string, not an array, hash, or similar.
#
assert_raise ArgumentError do
- Custodian::Util::Ping.new( {})
+ Custodian::Util::Ping.new({})
end
assert_raise ArgumentError do
- Custodian::Util::Ping.new( [])
+ Custodian::Util::Ping.new([])
end
@@ -64,9 +64,9 @@ class TestPingUtil < Test::Unit::TestCase
#
def test_lookup_ipv4
- helper = Custodian::Util::Ping.new( 'ipv4.steve.org.uk' )
- assert( helper.is_ipv4? )
- assert( ! helper.is_ipv6? )
+ helper = Custodian::Util::Ping.new('ipv4.steve.org.uk')
+ assert(helper.is_ipv4?)
+ assert(! helper.is_ipv6?)
end
@@ -76,9 +76,9 @@ class TestPingUtil < Test::Unit::TestCase
#
def test_lookup_ipv6
- helper = Custodian::Util::Ping.new( 'ipv6.steve.org.uk' )
- assert( helper.is_ipv6? )
- assert( ! helper.is_ipv4? )
+ helper = Custodian::Util::Ping.new('ipv6.steve.org.uk')
+ assert(helper.is_ipv6?)
+ assert(! helper.is_ipv4?)
end
@@ -88,10 +88,10 @@ class TestPingUtil < Test::Unit::TestCase
def test_lookup_fail
%w( tessf.dfsdf.sdf.sdfsdf fdsfkljflj3.fdsfds.f3.dfs ).each do |name|
assert_nothing_raised do
- helper = Custodian::Util::Ping.new( name )
+ helper = Custodian::Util::Ping.new(name)
- assert( ! helper.is_ipv4? )
- assert( ! helper.is_ipv6? )
+ assert(! helper.is_ipv4?)
+ assert(! helper.is_ipv6?)
end
end
diff --git a/t/test-custodian-util-timespan.rb b/t/test-custodian-util-timespan.rb
index 210a532..89dfbcd 100755
--- a/t/test-custodian-util-timespan.rb
+++ b/t/test-custodian-util-timespan.rb
@@ -29,37 +29,37 @@ class TestTimeSpanUtil < Test::Unit::TestCase
def test_to_hour
for hour in 0..23
- assert_equal( hour, Custodian::Util::TimeSpan.to_hour(hour))
+ assert_equal(hour, Custodian::Util::TimeSpan.to_hour(hour))
end
#
# Invalid hours will throw exceptions
#
assert_raise ArgumentError do
- result = Custodian::Util::TimeSpan.to_hour( 0.5 )
+ result = Custodian::Util::TimeSpan.to_hour(0.5)
end
assert_raise ArgumentError do
- result = Custodian::Util::TimeSpan.to_hour( -1 )
+ result = Custodian::Util::TimeSpan.to_hour(-1)
end
assert_raise ArgumentError do
- result = Custodian::Util::TimeSpan.to_hour( 100 )
+ result = Custodian::Util::TimeSpan.to_hour(100)
end
assert_raise ArgumentError do
- result = Custodian::Util::TimeSpan.to_hour( 24 )
+ result = Custodian::Util::TimeSpan.to_hour(24)
end
assert_raise ArgumentError do
- result = Custodian::Util::TimeSpan.to_hour( 25 )
+ result = Custodian::Util::TimeSpan.to_hour(25)
end
#
# Ensure AM times work well
#
for hour in 0..11
- assert_equal( hour, Custodian::Util::TimeSpan.to_hour( "#{hour}am"))
+ assert_equal(hour, Custodian::Util::TimeSpan.to_hour("#{hour}am"))
end
for hour in 0..11
- assert_equal( 12 +hour, Custodian::Util::TimeSpan.to_hour( "#{hour}pm"))
+ assert_equal(12 +hour, Custodian::Util::TimeSpan.to_hour("#{hour}pm"))
end
end
@@ -76,15 +76,15 @@ class TestTimeSpanUtil < Test::Unit::TestCase
#
for i in 24..100
assert_raise ArgumentError do
- result = Custodian::Util::TimeSpan.inside?( i, 2 )
+ result = Custodian::Util::TimeSpan.inside?(i, 2)
end
assert_raise ArgumentError do
- result = Custodian::Util::TimeSpan.inside?( 1, i )
+ result = Custodian::Util::TimeSpan.inside?(1, i)
end
assert_raise ArgumentError do
- result = Custodian::Util::TimeSpan.inside?( 1, 2, i )
+ result = Custodian::Util::TimeSpan.inside?(1, 2, i)
end
end
@@ -94,15 +94,15 @@ class TestTimeSpanUtil < Test::Unit::TestCase
for i in 1..50
assert_raise ArgumentError do
- result = Custodian::Util::TimeSpan.inside?( 1, ( -1 * i ) )
+ result = Custodian::Util::TimeSpan.inside?(1, (-1 * i))
end
assert_raise ArgumentError do
- result = Custodian::Util::TimeSpan.inside?( ( -1 * i ), 1 )
+ result = Custodian::Util::TimeSpan.inside?((-1 * i), 1)
end
assert_raise ArgumentError do
- result = Custodian::Util::TimeSpan.inside?( 1, 1, ( -1 * i ) )
+ result = Custodian::Util::TimeSpan.inside?(1, 1, (-1 * i))
end
end
@@ -114,8 +114,8 @@ class TestTimeSpanUtil < Test::Unit::TestCase
#
def test_simple_cases
# 8am-5pm
- assert(Custodian::Util::TimeSpan.inside?( '8am', '5am', 12 ))
- assert(Custodian::Util::TimeSpan.inside?( 8, 17, 12 ))
+ assert(Custodian::Util::TimeSpan.inside?('8am', '5am', 12))
+ assert(Custodian::Util::TimeSpan.inside?(8, 17, 12))
end
@@ -125,25 +125,25 @@ class TestTimeSpanUtil < Test::Unit::TestCase
def test_midnight_cases
# 9pm-2am
- assert(Custodian::Util::TimeSpan.inside?( '9pm', '2am', 22 ))
- assert(Custodian::Util::TimeSpan.inside?( '9pm', '2am', '10pm' ))
- assert(Custodian::Util::TimeSpan.inside?( 21, 2, 22 ))
- assert(Custodian::Util::TimeSpan.inside?( 21, 2, '10pm' ))
+ assert(Custodian::Util::TimeSpan.inside?('9pm', '2am', 22))
+ assert(Custodian::Util::TimeSpan.inside?('9pm', '2am', '10pm'))
+ assert(Custodian::Util::TimeSpan.inside?(21, 2, 22))
+ assert(Custodian::Util::TimeSpan.inside?(21, 2, '10pm'))
# 10pm-3am
- assert(Custodian::Util::TimeSpan.inside?( '10pm', '3am', 22 ))
- assert(Custodian::Util::TimeSpan.inside?( 22, 3, 22 ))
- assert(Custodian::Util::TimeSpan.inside?( 22, 3, 22 ))
- assert(Custodian::Util::TimeSpan.inside?( 22, 3, '10pm' ))
+ assert(Custodian::Util::TimeSpan.inside?('10pm', '3am', 22))
+ assert(Custodian::Util::TimeSpan.inside?(22, 3, 22))
+ assert(Custodian::Util::TimeSpan.inside?(22, 3, 22))
+ assert(Custodian::Util::TimeSpan.inside?(22, 3, '10pm'))
# 11pm-5am
- assert(Custodian::Util::TimeSpan.inside?( '11pm', '5am', 23 ))
- assert(Custodian::Util::TimeSpan.inside?( 23, 5, 23 ))
- assert(Custodian::Util::TimeSpan.inside?( '11pm', '5am', '11pm' ))
+ assert(Custodian::Util::TimeSpan.inside?('11pm', '5am', 23))
+ assert(Custodian::Util::TimeSpan.inside?(23, 5, 23))
+ assert(Custodian::Util::TimeSpan.inside?('11pm', '5am', '11pm'))
# midnight-3am
- assert( Custodian::Util::TimeSpan.inside?( '0', '3am', 1 ))
- assert( Custodian::Util::TimeSpan.inside?( '0', '3am', '1am' ))
+ assert(Custodian::Util::TimeSpan.inside?('0', '3am', 1))
+ assert(Custodian::Util::TimeSpan.inside?('0', '3am', '1am'))
end
@@ -158,38 +158,38 @@ class TestTimeSpanUtil < Test::Unit::TestCase
close = '6pm'
# The hours + the middle should be inside
- assert( Custodian::Util::TimeSpan.inside?( open, close, 16 ) )
- assert( Custodian::Util::TimeSpan.inside?( open, close, '4pm' ) )
+ assert(Custodian::Util::TimeSpan.inside?(open, close, 16))
+ assert(Custodian::Util::TimeSpan.inside?(open, close, '4pm'))
- assert( Custodian::Util::TimeSpan.inside?( open, close, 17 ) )
- assert( Custodian::Util::TimeSpan.inside?( open, close, '5pm' ) )
+ assert(Custodian::Util::TimeSpan.inside?(open, close, 17))
+ assert(Custodian::Util::TimeSpan.inside?(open, close, '5pm'))
- assert( Custodian::Util::TimeSpan.inside?( open, close, 18 ) )
- assert( Custodian::Util::TimeSpan.inside?( open, close, '6pm' ) )
+ assert(Custodian::Util::TimeSpan.inside?(open, close, 18))
+ assert(Custodian::Util::TimeSpan.inside?(open, close, '6pm'))
#
# The preceeding + successive hours shouldn't be.
#
- assert( ! Custodian::Util::TimeSpan.inside?( open, close, 15 ) )
- assert( ! Custodian::Util::TimeSpan.inside?( open, close, 19 ) )
+ assert(! Custodian::Util::TimeSpan.inside?(open, close, 15))
+ assert(! Custodian::Util::TimeSpan.inside?(open, close, 19))
#
# That is true for the string-versions too
#
- assert( ! Custodian::Util::TimeSpan.inside?( open, close, '3pm' ) )
- assert( ! Custodian::Util::TimeSpan.inside?( open, close, '7pm' ) )
+ assert(! Custodian::Util::TimeSpan.inside?(open, close, '3pm'))
+ assert(! Custodian::Util::TimeSpan.inside?(open, close, '7pm'))
#
# Random hours should be outside too.
#
- assert( ! Custodian::Util::TimeSpan.inside?( open, close, 3 ) )
- assert( ! Custodian::Util::TimeSpan.inside?( open, close, '3am' ) )
- assert( ! Custodian::Util::TimeSpan.inside?( open, close, 7 ) )
- assert( ! Custodian::Util::TimeSpan.inside?( open, close, '7am' ) )
- assert( ! Custodian::Util::TimeSpan.inside?( open, close, 9 ) )
- assert( ! Custodian::Util::TimeSpan.inside?( open, close, '9am' ) )
+ assert(! Custodian::Util::TimeSpan.inside?(open, close, 3))
+ assert(! Custodian::Util::TimeSpan.inside?(open, close, '3am'))
+ assert(! Custodian::Util::TimeSpan.inside?(open, close, 7))
+ assert(! Custodian::Util::TimeSpan.inside?(open, close, '7am'))
+ assert(! Custodian::Util::TimeSpan.inside?(open, close, 9))
+ assert(! Custodian::Util::TimeSpan.inside?(open, close, '9am'))
end
@@ -202,7 +202,7 @@ class TestTimeSpanUtil < Test::Unit::TestCase
#
def test_worst
for i in 0..23
- assert( Custodian::Util::TimeSpan.inside?( 0, 23, i ) )
+ assert(Custodian::Util::TimeSpan.inside?(0, 23, i))
end
end
@@ -215,14 +215,14 @@ class TestTimeSpanUtil < Test::Unit::TestCase
def test_wrap_around
for h in 00..23
- assert_equal( 1, Custodian::Util::TimeSpan.to_hours( h,h ).size )
+ assert_equal(1, Custodian::Util::TimeSpan.to_hours(h,h).size)
end
#
# But the time-period 00-23 is a full day
#
- assert_equal( 24,
- Custodian::Util::TimeSpan.to_hours( 0,23 ).size )
+ assert_equal(24,
+ Custodian::Util::TimeSpan.to_hours(0,23).size)
end
diff --git a/t/test-http-vs-https.rb b/t/test-http-vs-https.rb
index ab44ffc..8843683 100755
--- a/t/test-http-vs-https.rb
+++ b/t/test-http-vs-https.rb
@@ -42,13 +42,13 @@ class TestTestName < Test::Unit::TestCase
test = nil
assert_nothing_raised do
- test = Custodian::TestFactory.create( 'http://example.com/ must run http.' )
+ test = Custodian::TestFactory.create('http://example.com/ must run http.')
end
- assert( test )
- assert( test.kind_of? Array )
- assert( ! test.empty? )
- assert_equal( test[0].get_type, 'http' )
+ assert(test)
+ assert(test.kind_of? Array)
+ assert(! test.empty?)
+ assert_equal(test[0].get_type, 'http')
end
@@ -59,13 +59,13 @@ class TestTestName < Test::Unit::TestCase
test = nil
assert_nothing_raised do
- test = Custodian::TestFactory.create( 'https://example.com/ must run https.' )
+ test = Custodian::TestFactory.create('https://example.com/ must run https.')
end
- assert( test )
- assert( test.kind_of? Array )
- assert( ! test.empty? )
- assert_equal( test[0].get_type, 'https' )
+ assert(test)
+ assert(test.kind_of? Array)
+ assert(! test.empty?)
+ assert_equal(test[0].get_type, 'https')
end
@@ -76,19 +76,19 @@ class TestTestName < Test::Unit::TestCase
assert_raise ArgumentError do
- Custodian::TestFactory.create( 'https://example.com/ must run http.' )
+ Custodian::TestFactory.create('https://example.com/ must run http.')
end
assert_raise ArgumentError do
- Custodian::TestFactory.create( 'http://example.com/ must run https.' )
+ Custodian::TestFactory.create('http://example.com/ must run https.')
end
assert_nothing_raised do
- Custodian::TestFactory.create( 'http://example.com/ must run http.' )
+ Custodian::TestFactory.create('http://example.com/ must run http.')
end
assert_nothing_raised do
- Custodian::TestFactory.create( 'https://example.com/ must run https.' )
+ Custodian::TestFactory.create('https://example.com/ must run https.')
end
end
diff --git a/t/test-ldap-probe.rb b/t/test-ldap-probe.rb
index 63e95a3..70b616b 100755
--- a/t/test-ldap-probe.rb
+++ b/t/test-ldap-probe.rb
@@ -29,12 +29,12 @@ class TestLDAPProbe < Test::Unit::TestCase
test = nil
assert_nothing_raised do
- test = Custodian::TestFactory.create( "auth.bytemark.co.uk must run ldap on 389 with username 'testing' with password 'bob' otherwise 'LDAP dead?'." )
+ test = Custodian::TestFactory.create("auth.bytemark.co.uk must run ldap on 389 with username 'testing' with password 'bob' otherwise 'LDAP dead?'.")
end
- assert( test.kind_of? Array )
- assert( ! test.empty? )
- assert_equal( test[0].get_type, 'ldap' )
+ assert(test.kind_of? Array)
+ assert(! test.empty?)
+ assert_equal(test[0].get_type, 'ldap')
end
@@ -57,10 +57,10 @@ class TestLDAPProbe < Test::Unit::TestCase
#
data.each do |str|
assert_raise ArgumentError do
- test = Custodian::TestFactory.create( str )
+ test = Custodian::TestFactory.create(str)
- assert( test.kind_of? Array )
- assert( ! test.empty? )
+ assert(test.kind_of? Array)
+ assert(! test.empty?)
end
end