summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-11-17 18:35:44 -0800
committerTim Smith <tsmith84@gmail.com>2020-11-17 18:35:44 -0800
commit2767003dd26ed1a690b9e552c075e3c8c692ce39 (patch)
tree0e81e5b793aa5fac39115740a29ad87d4eef22df
parentce379c3ac1f1e8a0567fbe054ccdf1c6d40cb9cf (diff)
downloadohai-2767003dd26ed1a690b9e552c075e3c8c692ce39.tar.gz
Simplify all our splits
As Pete pointed out there's no need to split on whitespace when that's the default Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/cpu.rb8
-rw-r--r--lib/ohai/plugins/darwin/network.rb2
-rw-r--r--lib/ohai/plugins/joyent.rb4
-rw-r--r--lib/ohai/plugins/linux/network.rb2
-rw-r--r--lib/ohai/plugins/packages.rb2
-rw-r--r--lib/ohai/plugins/uptime.rb2
6 files changed, 10 insertions, 10 deletions
diff --git a/lib/ohai/plugins/cpu.rb b/lib/ohai/plugins/cpu.rb
index 66aa1260..80eaa31d 100644
--- a/lib/ohai/plugins/cpu.rb
+++ b/lib/ohai/plugins/cpu.rb
@@ -85,15 +85,15 @@ Ohai.plugin(:CPU) do
when /cache size\s+:\s(.+)/
cpuinfo[current_cpu]["cache_size"] = $1
when /flags\s+:\s(.+)/
- cpuinfo[current_cpu]["flags"] = $1.split(" ")
+ cpuinfo[current_cpu]["flags"] = $1.split
when /BogoMIPS\s+:\s(.+)/
cpuinfo[current_cpu]["bogomips"] = $1
when /Features\s+:\s(.+)/
- cpuinfo[current_cpu]["features"] = $1.split(" ")
+ cpuinfo[current_cpu]["features"] = $1.split
when /bogomips per cpu:\s(.+)/
cpuinfo["bogomips_per_cpu"] = $1
when /features\s+:\s(.+)/
- cpuinfo["features"] = $1.split(" ")
+ cpuinfo["features"] = $1.split
when /processor\s(\d):\s(.+)/
current_cpu = $1
cpu_number += 1
@@ -278,7 +278,7 @@ Ohai.plugin(:CPU) do
when /^machdep.cpu.stepping: (.*)$/
cpu[:stepping] = Regexp.last_match[1].to_i
when /^machdep.cpu.features: (.*)$/
- cpu[:flags] = Regexp.last_match[1].downcase.split(" ")
+ cpu[:flags] = Regexp.last_match[1].downcase.split
end
end
end
diff --git a/lib/ohai/plugins/darwin/network.rb b/lib/ohai/plugins/darwin/network.rb
index ddbd59ff..2d3e2a12 100644
--- a/lib/ohai/plugins/darwin/network.rb
+++ b/lib/ohai/plugins/darwin/network.rb
@@ -27,7 +27,7 @@ Ohai.plugin(:Network) do
def parse_media(media_string)
media = {}
- line_array = media_string.split(" ")
+ line_array = media_string.split
0.upto(line_array.length - 1) do |i|
unless line_array[i].eql?("none")
diff --git a/lib/ohai/plugins/joyent.rb b/lib/ohai/plugins/joyent.rb
index 84a7c313..d68ec548 100644
--- a/lib/ohai/plugins/joyent.rb
+++ b/lib/ohai/plugins/joyent.rb
@@ -61,11 +61,11 @@ Ohai.plugin(:Joyent) do
collect_product_file.each do |line|
case line
when /^Image/
- sm_image = line.split(" ")
+ sm_image = line.split
joyent[:sm_image_id] = sm_image[1]
joyent[:sm_image_ver] = sm_image[2]
when /^Base Image/
- sm_baseimage = line.split(" ")
+ sm_baseimage = line.split
joyent[:sm_baseimage_id] = sm_baseimage[2]
joyent[:sm_baseimage_ver] = sm_baseimage[3]
end
diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb
index 874114c8..01f4af47 100644
--- a/lib/ohai/plugins/linux/network.rb
+++ b/lib/ohai/plugins/linux/network.rb
@@ -466,7 +466,7 @@ Ohai.plugin(:Network) do
iface[cint][:addresses] ||= Mash.new
tmp_addr = $1
tags = $4 || ""
- tags = tags.split(" ")
+ tags = tags.split
iface[cint][:addresses][tmp_addr] = {
"family" => "inet6",
diff --git a/lib/ohai/plugins/packages.rb b/lib/ohai/plugins/packages.rb
index 7ab0e0aa..e9ce2b3d 100644
--- a/lib/ohai/plugins/packages.rb
+++ b/lib/ohai/plugins/packages.rb
@@ -164,7 +164,7 @@ Ohai.plugin(:Packages) do
# Output format is
# name version
so.stdout.lines do |pkg|
- name, version = pkg.split(" ")
+ name, version = pkg.split
packages[name] = { "version" => version }
end
end
diff --git a/lib/ohai/plugins/uptime.rb b/lib/ohai/plugins/uptime.rb
index 708feadf..bd6952d1 100644
--- a/lib/ohai/plugins/uptime.rb
+++ b/lib/ohai/plugins/uptime.rb
@@ -55,7 +55,7 @@ Ohai.plugin(:Uptime) do
end
collect_data(:linux) do
- uptime, idletime = file_open("/proc/uptime").gets.split(" ")
+ uptime, idletime = file_open("/proc/uptime").gets.split
uptime_seconds uptime.to_i
uptime seconds_to_human(uptime.to_i)
idletime_seconds idletime.to_i