Cleanup ruby code via rubocop

This commit will add code cleanup as corrected
and alerted by rubocop. It also adds rules to
execute rubocop on Travis.
This commit is contained in:
Will Meek
2017-11-17 16:40:06 +00:00
parent 692b490438
commit dec5136e11
18 changed files with 714 additions and 1087 deletions

View File

@@ -21,10 +21,10 @@ Facter.add(:java_version) do
# Additionally, facter versions prior to 2.0.1 only support
# positive matches, so this needs to be done manually in setcode.
setcode do
unless [ 'darwin' ].include? Facter.value(:operatingsystem).downcase
unless ['darwin'].include? Facter.value(:operatingsystem).downcase
version = nil
if Facter::Util::Resolution.which('java')
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $~[1] if /^.+ version \"(.+)\"$/ =~ line }
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $LAST_MATCH_INFO[1] if %r{^.+ version \"(.+)\"$} =~ line }
end
version
end
@@ -32,12 +32,12 @@ Facter.add(:java_version) do
end
Facter.add(:java_version) do
confine :operatingsystem => 'Darwin'
confine operatingsystem: 'Darwin'
has_weight 100
setcode do
unless /Unable to find any JVMs matching version/ =~ Facter::Util::Resolution.exec('/usr/libexec/java_home --failfast 2>&1')
unless %r{Unable to find any JVMs matching version} =~ Facter::Util::Resolution.exec('/usr/libexec/java_home --failfast 2>&1')
version = nil
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $~[1] if /^.+ version \"(.+)\"$/ =~ line }
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $LAST_MATCH_INFO[1] if %r{^.+ version \"(.+)\"$} =~ line }
version
end
end