summaryrefslogtreecommitdiff
path: root/lib/custodian
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-03-09 13:08:33 +0000
committerSteve Kemp <steve@steve.org.uk>2015-03-09 13:08:33 +0000
commit22b40326730fb7a4a8e2f5cb8d877f6a84494d02 (patch)
treec08f5ade5267c79cf3929bccc75dd4b704717500 /lib/custodian
parent5cc24f3a9a25a4214f1ee85a24960cce9f4f9516 (diff)
Avoid "Array.new" and "Hash.new"
Instead use {} + ().
Diffstat (limited to 'lib/custodian')
-rw-r--r--lib/custodian/parser.rb10
-rw-r--r--lib/custodian/protocoltest/dns.rb2
-rw-r--r--lib/custodian/protocoltest/ldap.rb2
-rw-r--r--lib/custodian/protocoltest/mx.rb2
-rw-r--r--lib/custodian/protocoltest/ping.rb2
-rw-r--r--lib/custodian/protocoltest/tcp.rb2
-rw-r--r--lib/custodian/settings.rb2
-rw-r--r--lib/custodian/testfactory.rb4
8 files changed, 13 insertions, 13 deletions
diff --git a/lib/custodian/parser.rb b/lib/custodian/parser.rb
index e73001f..0bafd47 100644
--- a/lib/custodian/parser.rb
+++ b/lib/custodian/parser.rb
@@ -53,8 +53,8 @@ module Custodian
# Constructor
#
def initialize
- @MACROS = Hash.new()
- @jobs = Array.new()
+ @MACROS = {}
+ @jobs = []
end
@@ -119,7 +119,7 @@ module Custodian
#
def define_macro( line )
name = nil
- val = Array.new
+ val = []
#
# Get the name of the macro.
@@ -212,7 +212,7 @@ module Custodian
#
def expand_macro( input )
- r = Array.new()
+ r = []
if ( input =~ /^(\S+)\s+(.*)$/ )
macro=$1.dup
@@ -320,7 +320,7 @@ module Custodian
#
# The array of objects we will return to the caller.
#
- ret = Array.new()
+ ret = []
#
# For each host in our possibly-macro-expanded list:
diff --git a/lib/custodian/protocoltest/dns.rb b/lib/custodian/protocoltest/dns.rb
index 7187a75..05c8534 100644
--- a/lib/custodian/protocoltest/dns.rb
+++ b/lib/custodian/protocoltest/dns.rb
@@ -128,7 +128,7 @@ module Custodian
#
def resolve_via( server, ltype, name, period )
- results = Array.new()
+ results = []
begin
timeout( period ) do
diff --git a/lib/custodian/protocoltest/ldap.rb b/lib/custodian/protocoltest/ldap.rb
index fd02623..56203b2 100644
--- a/lib/custodian/protocoltest/ldap.rb
+++ b/lib/custodian/protocoltest/ldap.rb
@@ -125,7 +125,7 @@ module Custodian
else
@error = "failed to bind to LDAP server '#{@host}' with username '#{@ldap_user}' and password '#{@ldap_pass}'"
return false
- end
+ .end
end
rescue LDAP::ResultError => ex
@error = "LDAP exception: #{ex} when talking to LDAP server '#{@host}' with username '#{@ldap_user}' and password '#{@ldap_pass}'"
diff --git a/lib/custodian/protocoltest/mx.rb b/lib/custodian/protocoltest/mx.rb
index c05283d..29a9183 100644
--- a/lib/custodian/protocoltest/mx.rb
+++ b/lib/custodian/protocoltest/mx.rb
@@ -63,7 +63,7 @@ module Custodian
#
# The MX-hosts
#
- mx = Array.new()
+ mx = []
#
# Lookup the MX record
diff --git a/lib/custodian/protocoltest/ping.rb b/lib/custodian/protocoltest/ping.rb
index 937a5db..ff406d5 100644
--- a/lib/custodian/protocoltest/ping.rb
+++ b/lib/custodian/protocoltest/ping.rb
@@ -102,7 +102,7 @@ module Custodian
#
# Perform the DNS lookups of the specified name.
#
- ips = Array.new()
+ ips = []
#
# Does the name look like an IP?
diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb
index dd2e52b..9ca2180 100644
--- a/lib/custodian/protocoltest/tcp.rb
+++ b/lib/custodian/protocoltest/tcp.rb
@@ -159,7 +159,7 @@ module Custodian
#
# Perform the DNS lookups of the specified name.
#
- ips = Array.new()
+ ips = []
#
# Does the name look like an IP?
diff --git a/lib/custodian/settings.rb b/lib/custodian/settings.rb
index 206e6a9..8bcf71c 100644
--- a/lib/custodian/settings.rb
+++ b/lib/custodian/settings.rb
@@ -38,7 +38,7 @@ module Custodian
def _load( file = "/etc/custodian/custodian.cfg" )
@parsed = true
- @settings = Hash.new()
+ @settings = {}
#
# The global configuration file.
diff --git a/lib/custodian/testfactory.rb b/lib/custodian/testfactory.rb
index fc007e9..03222a2 100644
--- a/lib/custodian/testfactory.rb
+++ b/lib/custodian/testfactory.rb
@@ -37,7 +37,7 @@ module Custodian
#
# The array we return.
#
- result = Array.new()
+ result = []
#
@@ -89,7 +89,7 @@ module Custodian
# Register a new test type - this must be called by our derived classes
#
def self.register_test_type name
- @@subclasses[name] ||= Array.new()
+ @@subclasses[name] ||= []
@@subclasses[name].push(self)
end