From 67fbf68705e1808107e8cea1d3ab6ad0e206f645 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Fri, 22 Apr 2016 21:48:59 +0300 Subject: Fixed up more rubocop warnings. Again these were whitespace-related. --- lib/custodian/util/bytemark.rb | 2 +- lib/custodian/util/dns.rb | 2 +- lib/custodian/util/ping.rb | 10 +++++----- lib/custodian/util/tftp.rb | 10 +++++----- lib/custodian/util/timespan.rb | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'lib/custodian') diff --git a/lib/custodian/util/bytemark.rb b/lib/custodian/util/bytemark.rb index 6e944de..c72b457 100644 --- a/lib/custodian/util/bytemark.rb +++ b/lib/custodian/util/bytemark.rb @@ -29,7 +29,7 @@ module Custodian def self.inside?(target) inside = false - if BYTEMARK_RANGES.any? { |range| range.include?(IPAddr.new(target)) } + if BYTEMARK_RANGES.any? { |range| range.include?(IPAddr.new(target)) } inside = true end diff --git a/lib/custodian/util/dns.rb b/lib/custodian/util/dns.rb index 724b3c2..dbb7158 100644 --- a/lib/custodian/util/dns.rb +++ b/lib/custodian/util/dns.rb @@ -61,7 +61,7 @@ module Custodian timeout(period) do begin Socket.getaddrinfo(hostname, 'echo').each do |a| - resolved = a[3] if a + resolved = a[3] if a end rescue SocketError resolved = nil diff --git a/lib/custodian/util/ping.rb b/lib/custodian/util/ping.rb index d563722..21836ac 100644 --- a/lib/custodian/util/ping.rb +++ b/lib/custodian/util/ping.rb @@ -26,8 +26,8 @@ module Custodian # 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 not be nil' if hostname.nil? + raise ArgumentError, 'Hostname must be a String' unless hostname.kind_of?(String) @hostname = hostname @resolved = Custodian::Util::DNS.hostname_to_ip(hostname) @@ -45,7 +45,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 @@ -57,7 +57,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 @@ -72,7 +72,7 @@ module Custodian # Return false on error. # def run_ping - if is_ipv6? + if is_ipv6? if (system("ping6 -c 1 #{@resolved} 2>/dev/null >/dev/null") == true) return true end diff --git a/lib/custodian/util/tftp.rb b/lib/custodian/util/tftp.rb index c012a82..0c9d119 100644 --- a/lib/custodian/util/tftp.rb +++ b/lib/custodian/util/tftp.rb @@ -12,14 +12,14 @@ module Custodian # # Store hostname and port # - def initialize(hostname, port=69) + def initialize(hostname, port = 69) - 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 not be nil' if hostname.nil? + raise ArgumentError, 'Hostname must be a String' unless hostname.kind_of?(String) raise ArgumentError, 'Port must be a number' unless port.to_i > 0 @hostname = hostname - @port = port.to_i + @port = port.to_i end # @@ -35,7 +35,7 @@ module Custodian FileUtils.rm_f(target) end - def fetch(file, target=nil) + def fetch(file, target = nil) # HPA's tftp client appears to have a 25s timeout that it is # not possible to change on the command line. return tftp("-m binary #{@hostname} #{@port} -c get #{file} #{target}") diff --git a/lib/custodian/util/timespan.rb b/lib/custodian/util/timespan.rb index 7de76b3..8364d02 100644 --- a/lib/custodian/util/timespan.rb +++ b/lib/custodian/util/timespan.rb @@ -17,7 +17,7 @@ module Custodian # # Handle PM times. # - if (desc.kind_of? String) && + if (desc.kind_of? String) && (desc =~ /([0-9]+)pm$/i) desc = $1.dup.to_i + 12 end @@ -25,7 +25,7 @@ module Custodian # # Handle AM times. # - if desc.kind_of? String + if desc.kind_of? String desc = desc.sub(/am$/, '') desc = desc.to_i end @@ -33,8 +33,8 @@ module Custodian # # 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) # @@ -70,7 +70,7 @@ module Custodian while (hour != p_end) valid[hour] = 1 hour += 1 - hour = 0 if hour > 23 + hour = 0 if hour > 23 end valid[p_end] = 1 @@ -92,7 +92,7 @@ module Custodian # # Default to the current hour, if not specified. # - if cur_hour.nil? + if cur_hour.nil? cur_hour = Time.now.hour end -- cgit v1.2.1