diff options
author | Tim Smith <tsmith@chef.io> | 2019-06-13 13:29:06 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2019-06-13 13:29:06 -0700 |
commit | 195cffd2a6292d1a8b62d06ea0f3a1f8f74ff4a2 (patch) | |
tree | 8443ae9808d4bc0358e6929f455695c519150773 | |
parent | c8a1bd56386ba960dd41f5a7187ab9d084c83970 (diff) | |
download | ohai-195cffd2a6292d1a8b62d06ea0f3a1f8f74ff4a2.tar.gz |
Use delete_prefix / delete_suffix instead of a regex
Simpler and probably faster.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/virtualbox.rb | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/lib/ohai/plugins/virtualbox.rb b/lib/ohai/plugins/virtualbox.rb index d28814ce..8d158108 100644 --- a/lib/ohai/plugins/virtualbox.rb +++ b/lib/ohai/plugins/virtualbox.rb @@ -61,27 +61,12 @@ Ohai.plugin(:Virtualbox) do left, right = line.split("=") # remove enclosing quotes, if needed - key = - case left - when /^"(.*)"$/ - Regexp.last_match(1) - else - left - end + key = left.delete_prefix('"').delete_suffix('"') # skip the name attribute since that is the parent key next if left == "name" - # remove enclosing quotes, if needed - value = - case right - when /^"(.*)"$/ - Regexp.last_match(1) - else - right - end - - vm[key.downcase] = value + vm[key.downcase] = right.delete_prefix('"').delete_suffix('"') end end vm |