diff options
author | Tim Smith <tsmith84@gmail.com> | 2016-04-22 09:13:41 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2016-04-22 09:13:41 -0700 |
commit | 3a1f1b1a81116392c1ebbef975a9e59dea9a827a (patch) | |
tree | 8ce7e796f94993c5380409edd8794c2bb98a8472 | |
parent | 3cfd06e9067fece7d12d37020e387fa04b2456df (diff) | |
download | ohai-3a1f1b1a81116392c1ebbef975a9e59dea9a827a.tar.gz |
Reduce nested Ifs
-rw-r--r-- | lib/ohai/plugins/elixir.rb | 8 | ||||
-rw-r--r-- | lib/ohai/plugins/go.rb | 10 | ||||
-rw-r--r-- | lib/ohai/plugins/groovy.rb | 12 |
3 files changed, 12 insertions, 18 deletions
diff --git a/lib/ohai/plugins/elixir.rb b/lib/ohai/plugins/elixir.rb index 75fd081b..0dc6b1c3 100644 --- a/lib/ohai/plugins/elixir.rb +++ b/lib/ohai/plugins/elixir.rb @@ -24,12 +24,10 @@ Ohai.plugin(:Elixir) do # Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace] # # Elixir 1.2.4 - if so.exitstatus == 0 + if so.exitstatus == 0 && so.stdout =~ /^Elixir (\S*)/ elixir = Mash.new - if so.stdout =~ /^Elixir (\S*)/ - elixir[:version] = $1 - languages[:elixir] = elixir - end + elixir[:version] = $1 + languages[:elixir] = elixir end rescue Ohai::Exceptions::Exec Ohai::Log.debug('Elixir plugin: Could not shell_out "elixir -v". Skipping plugin') diff --git a/lib/ohai/plugins/go.rb b/lib/ohai/plugins/go.rb index 788ad5ef..3748531b 100644 --- a/lib/ohai/plugins/go.rb +++ b/lib/ohai/plugins/go.rb @@ -22,12 +22,10 @@ Ohai.plugin(:Go) do so = shell_out("go version") # Sample output: # go version go1.6.1 darwin/amd64 - if so.exitstatus == 0 - if so.stdout =~ /go(\S+)/ - go = Mash.new - go[:version] = $1 - languages[:go] = go - end + if so.exitstatus == 0 && so.stdout =~ /go(\S+)/ + go = Mash.new + go[:version] = $1 + languages[:go] = go end rescue Ohai::Exceptions::Exec Ohai::Log.debug('Go plugin: Could not shell_out "go version". Skipping plugin') diff --git a/lib/ohai/plugins/groovy.rb b/lib/ohai/plugins/groovy.rb index 60d07138..7edbb67c 100644 --- a/lib/ohai/plugins/groovy.rb +++ b/lib/ohai/plugins/groovy.rb @@ -25,13 +25,11 @@ Ohai.plugin(:Groovy) do so = shell_out("groovy -v") # Sample output: # Groovy Version: 2.4.6 JVM: 1.8.0_60 Vendor: Oracle Corporation OS: Mac OS X - if so.exitstatus == 0 - if so.stdout =~ /Groovy Version: (\S+).*JVM: (\S+)/ - groovy = Mash.new - groovy[:version] = $1 - groovy[:jvm] = $2 - languages[:groovy] = groovy - end + if so.exitstatus == 0 && so.stdout =~ /Groovy Version: (\S+).*JVM: (\S+)/ + groovy = Mash.new + groovy[:version] = $1 + groovy[:jvm] = $2 + languages[:groovy] = groovy end rescue Ohai::Exceptions::Exec Ohai::Log.debug('Groovy plugin: Could not shell_out "groovy -v". Skipping plugin') |