diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-10-31 17:11:19 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-10-31 17:11:19 -0700 |
commit | df9a9efc901162a3db6ee1dd787ccbd53eabdf77 (patch) | |
tree | 930bd31f4c10f1f0683a2412dcb31eded9455711 | |
parent | c42d57d03c795771ecc04cad3eb4118ae773818a (diff) | |
download | ohai-df9a9efc901162a3db6ee1dd787ccbd53eabdf77.tar.gz |
Use an array vs. appending a string in Ruby
This is actually slightly faster too
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/ruby.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/ohai/plugins/ruby.rb b/lib/ohai/plugins/ruby.rb index d83d8f72..10279182 100644 --- a/lib/ohai/plugins/ruby.rb +++ b/lib/ohai/plugins/ruby.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # Author:: Adam Jacob (<adam@chef.io>) # Copyright:: Copyright (c) Chef Software Inc. @@ -48,13 +49,13 @@ Ohai.plugin(:Ruby) do } # Create a query string from above hash - env_string = "" + env_string = [] values.each_key do |v| env_string << "#{v}=\#{#{values[v]}}," end # Query the system ruby - result = run_ruby "require 'rubygems'; puts %Q(#{env_string})" + result = run_ruby "require 'rubygems'; puts %Q(#{env_string.join})" # Parse results to plugin hash result.split(",").each do |entry| |