summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-06 09:47:49 -0800
committerTim Smith <tsmith@chef.io>2018-03-06 09:47:49 -0800
commit2392f541f2d580bbc9fe69324961f10a19865af4 (patch)
tree680fe7837760ba27921f33b072422a9df4dac112
parent3627eb769d3dd25098cf0cb34a4090c2e2e0b0df (diff)
downloadohai-2392f541f2d580bbc9fe69324961f10a19865af4.tar.gz
Chefstyle fixes
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/init_package.rb2
-rw-r--r--lib/ohai/plugins/linux/block_device.rb8
-rw-r--r--lib/ohai/plugins/linux/lsb.rb4
-rw-r--r--lib/ohai/plugins/linux/machineid.rb8
-rw-r--r--lib/ohai/plugins/ruby.rb2
-rw-r--r--lib/ohai/plugins/solaris2/platform.rb2
-rw-r--r--lib/ohai/plugins/ssh_host_key.rb12
-rw-r--r--spec/functional/plugins/root_group_spec.rb2
-rw-r--r--spec/unit/plugins/aix/network_spec.rb2
-rw-r--r--spec/unit/plugins/aix/virtualization_spec.rb6
-rw-r--r--spec/unit/plugins/init_package_spec.rb2
-rw-r--r--spec/unit/plugins/linux/block_device_spec.rb4
-rw-r--r--spec/unit/plugins/linux/lsb_spec.rb10
-rw-r--r--spec/unit/plugins/linux/machineid_spec.rb10
-rw-r--r--spec/unit/plugins/ruby_spec.rb2
-rw-r--r--spec/unit/plugins/solaris2/platform_spec.rb4
-rw-r--r--spec/unit/plugins/ssh_host_keys_spec.rb16
17 files changed, 48 insertions, 48 deletions
diff --git a/lib/ohai/plugins/init_package.rb b/lib/ohai/plugins/init_package.rb
index 1bf54ce1..e3162cf0 100644
--- a/lib/ohai/plugins/init_package.rb
+++ b/lib/ohai/plugins/init_package.rb
@@ -20,6 +20,6 @@ Ohai.plugin(:InitPackage) do
provides "init_package"
collect_data(:linux) do
- init_package File.exists?("/proc/1/comm") ? File.open("/proc/1/comm").gets.chomp : "init"
+ init_package File.exist?("/proc/1/comm") ? File.open("/proc/1/comm").gets.chomp : "init"
end
end
diff --git a/lib/ohai/plugins/linux/block_device.rb b/lib/ohai/plugins/linux/block_device.rb
index 709d03e4..e0133189 100644
--- a/lib/ohai/plugins/linux/block_device.rb
+++ b/lib/ohai/plugins/linux/block_device.rb
@@ -20,23 +20,23 @@ Ohai.plugin(:BlockDevice) do
provides "block_device"
collect_data(:linux) do
- if File.exists?("/sys/block")
+ if File.exist?("/sys/block")
block = Mash.new
Dir["/sys/block/*"].each do |block_device_dir|
dir = File.basename(block_device_dir)
block[dir] = Mash.new
%w{size removable}.each do |check|
- if File.exists?("/sys/block/#{dir}/#{check}")
+ if File.exist?("/sys/block/#{dir}/#{check}")
File.open("/sys/block/#{dir}/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
end
end
%w{model rev state timeout vendor queue_depth}.each do |check|
- if File.exists?("/sys/block/#{dir}/device/#{check}")
+ if File.exist?("/sys/block/#{dir}/device/#{check}")
File.open("/sys/block/#{dir}/device/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
end
end
%w{rotational physical_block_size logical_block_size}.each do |check|
- if File.exists?("/sys/block/#{dir}/queue/#{check}")
+ if File.exist?("/sys/block/#{dir}/queue/#{check}")
File.open("/sys/block/#{dir}/queue/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
end
end
diff --git a/lib/ohai/plugins/linux/lsb.rb b/lib/ohai/plugins/linux/lsb.rb
index 018ef1ec..cee56f29 100644
--- a/lib/ohai/plugins/linux/lsb.rb
+++ b/lib/ohai/plugins/linux/lsb.rb
@@ -22,7 +22,7 @@ Ohai.plugin(:LSB) do
collect_data(:linux) do
lsb Mash.new
- if File.exists?("/usr/bin/lsb_release")
+ if File.exist?("/usr/bin/lsb_release")
# From package redhat-lsb on Fedora/Redhat, lsb-release on Debian/Ubuntu
so = shell_out("lsb_release -a")
so.stdout.lines do |line|
@@ -39,7 +39,7 @@ Ohai.plugin(:LSB) do
lsb[:id] = line
end
end
- elsif File.exists?("/etc/lsb-release")
+ elsif File.exist?("/etc/lsb-release")
# Old, non-standard Debian support
File.open("/etc/lsb-release").each do |line|
case line
diff --git a/lib/ohai/plugins/linux/machineid.rb b/lib/ohai/plugins/linux/machineid.rb
index b946c418..56b22227 100644
--- a/lib/ohai/plugins/linux/machineid.rb
+++ b/lib/ohai/plugins/linux/machineid.rb
@@ -22,10 +22,10 @@ Ohai.plugin(:Machineid) do
collect_data(:linux) do
mid = nil
- if File.exists?("/etc/machine-id")
- mid = File.read("/etc/machine-id").chomp
- elsif File.exists?("/var/lib/dbus/machine-id")
- mid = File.read("/var/lib/dbus/machine-id").chomp
+ if ::File.exist?("/etc/machine-id")
+ mid = ::File.read("/etc/machine-id").chomp
+ elsif ::File.exist?("/var/lib/dbus/machine-id")
+ mid = ::File.read("/var/lib/dbus/machine-id").chomp
end
if mid
diff --git a/lib/ohai/plugins/ruby.rb b/lib/ohai/plugins/ruby.rb
index 8a036031..292862eb 100644
--- a/lib/ohai/plugins/ruby.rb
+++ b/lib/ohai/plugins/ruby.rb
@@ -67,7 +67,7 @@ Ohai.plugin(:Ruby) do
run_ruby("require 'rubygems'; puts ::Gem.default_exec_format % 'gem'"),
"gem",
].map { |bin| ::File.join(bin_dir, bin) }
- gem_binary = gem_binaries.find { |bin| ::File.exists? bin }
+ gem_binary = gem_binaries.find { |bin| ::File.exist? bin }
if gem_binary
languages[:ruby][:gems_dir] = run_ruby "puts %x{#{ruby_bin} #{gem_binary} env gemdir}.chomp!"
languages[:ruby][:gem_bin] = gem_binary
diff --git a/lib/ohai/plugins/solaris2/platform.rb b/lib/ohai/plugins/solaris2/platform.rb
index 9aa88fb9..b31b8f68 100644
--- a/lib/ohai/plugins/solaris2/platform.rb
+++ b/lib/ohai/plugins/solaris2/platform.rb
@@ -20,7 +20,7 @@ Ohai.plugin(:Platform) do
provides "platform", "platform_version", "platform_build", "platform_family"
collect_data(:solaris2) do
- if File.exists?("/sbin/uname")
+ if File.exist?("/sbin/uname")
uname_exec = "/sbin/uname"
else
uname_exec = "uname"
diff --git a/lib/ohai/plugins/ssh_host_key.rb b/lib/ohai/plugins/ssh_host_key.rb
index 44b9b44c..78c67f5f 100644
--- a/lib/ohai/plugins/ssh_host_key.rb
+++ b/lib/ohai/plugins/ssh_host_key.rb
@@ -38,9 +38,9 @@ Ohai.plugin(:SSHHostKey) do
collect_data do
keys[:ssh] = Mash.new
- sshd_config = if File.exists?("/etc/ssh/sshd_config")
+ sshd_config = if File.exist?("/etc/ssh/sshd_config")
"/etc/ssh/sshd_config"
- elsif File.exists?("/etc/sshd_config")
+ elsif File.exist?("/etc/sshd_config")
# Darwin
"/etc/sshd_config"
else
@@ -62,21 +62,21 @@ Ohai.plugin(:SSHHostKey) do
end
end
- if keys[:ssh][:host_dsa_public].nil? && File.exists?("/etc/ssh/ssh_host_dsa_key.pub")
+ if keys[:ssh][:host_dsa_public].nil? && File.exist?("/etc/ssh/ssh_host_dsa_key.pub")
keys[:ssh][:host_dsa_public] = IO.read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
end
- if keys[:ssh][:host_rsa_public].nil? && File.exists?("/etc/ssh/ssh_host_rsa_key.pub")
+ if keys[:ssh][:host_rsa_public].nil? && File.exist?("/etc/ssh/ssh_host_rsa_key.pub")
keys[:ssh][:host_rsa_public] = IO.read("/etc/ssh/ssh_host_rsa_key.pub").split[1]
end
- if keys[:ssh][:host_ecdsa_public].nil? && File.exists?("/etc/ssh/ssh_host_ecdsa_key.pub")
+ if keys[:ssh][:host_ecdsa_public].nil? && File.exist?("/etc/ssh/ssh_host_ecdsa_key.pub")
content = IO.read("/etc/ssh/ssh_host_ecdsa_key.pub")
keys[:ssh][:host_ecdsa_public] = content.split[1]
keys[:ssh][:host_ecdsa_type] = content.split[0]
end
- if keys[:ssh][:host_ed25519_public].nil? && File.exists?("/etc/ssh/ssh_host_ed25519_key.pub")
+ if keys[:ssh][:host_ed25519_public].nil? && File.exist?("/etc/ssh/ssh_host_ed25519_key.pub")
keys[:ssh][:host_ed25519_public] = IO.read("/etc/ssh/ssh_host_ed25519_key.pub").split[1]
end
end
diff --git a/spec/functional/plugins/root_group_spec.rb b/spec/functional/plugins/root_group_spec.rb
index 153f0c09..28af5ff9 100644
--- a/spec/functional/plugins/root_group_spec.rb
+++ b/spec/functional/plugins/root_group_spec.rb
@@ -26,7 +26,7 @@ describe Ohai::System, "root_group plugin" do
describe "windows platform", :windows_only do
let (:wmi) { wmi = WmiLite::Wmi.new }
- it 'should return the system\'s administrators (root) group' do
+ it "should return the system's administrators (root) group" do
# Notethat the Win32_Group WMI provider can be slow if your
# system is domain-joined and has hundreds of thousands of
# groups in Active Directory -- not a typical test scenario, but
diff --git a/spec/unit/plugins/aix/network_spec.rb b/spec/unit/plugins/aix/network_spec.rb
index 5890c6d1..c3f675eb 100644
--- a/spec/unit/plugins/aix/network_spec.rb
+++ b/spec/unit/plugins/aix/network_spec.rb
@@ -113,7 +113,7 @@ ARP_AN
@plugin.run
end
- it 'for \'macaddress\'' do
+ it "for 'macaddress'" do
expect(@plugin[:macaddress]).to eq("BE:42:80:00:B0:05")
end
end
diff --git a/spec/unit/plugins/aix/virtualization_spec.rb b/spec/unit/plugins/aix/virtualization_spec.rb
index 37c9c595..6e8fda7c 100644
--- a/spec/unit/plugins/aix/virtualization_spec.rb
+++ b/spec/unit/plugins/aix/virtualization_spec.rb
@@ -272,12 +272,12 @@ LSWPAR_L
end
context "when collecting WPAR info" do
- it 'finds the WPAR\'s hostname correctly' do
+ it "finds the WPAR's hostname correctly" do
expect(wpar1[:hostname]).to eq("applejack-pony-541ba3.ponyville.com")
expect(wpar2[:hostname]).to eq("fluttershy-pony-5c969f.ponyville.com")
end
- it 'finds the WPAR\'s IP correctly' do
+ it "finds the WPAR's IP correctly" do
expect(wpar1[:address]).to eq("192.168.0.231")
expect(wpar2[:address]).to eq("192.168.0.18")
end
@@ -289,7 +289,7 @@ LSWPAR_L
end
end
- context 'when WPARs don\'t exist on the LPAR' do
+ context "when WPARs don't exist on the LPAR" do
before do
allow(plugin).to receive(:shell_out).with("lswpar -L").and_return(mock_shell_out(0, "", nil))
plugin.run
diff --git a/spec/unit/plugins/init_package_spec.rb b/spec/unit/plugins/init_package_spec.rb
index 7966963d..58966307 100644
--- a/spec/unit/plugins/init_package_spec.rb
+++ b/spec/unit/plugins/init_package_spec.rb
@@ -31,7 +31,7 @@ describe Ohai::System, "Init package" do
let(:proc_1_file) { double(proc_1_file_path, :gets => proc1_content) }
before(:each) do
- allow(File).to receive(:exists?).with(proc_1_file_path).and_return(proc1_exists)
+ allow(File).to receive(:exist?).with(proc_1_file_path).and_return(proc1_exists)
allow(File).to receive(:open).with(proc_1_file_path).and_return(proc_1_file)
end
diff --git a/spec/unit/plugins/linux/block_device_spec.rb b/spec/unit/plugins/linux/block_device_spec.rb
index bbad8b59..57d2929f 100644
--- a/spec/unit/plugins/linux/block_device_spec.rb
+++ b/spec/unit/plugins/linux/block_device_spec.rb
@@ -45,7 +45,7 @@ describe Ohai::System, "Linux Block Device Plugin" do
@plugin = get_plugin("linux/block_device")
allow(@plugin).to receive(:collect_os).and_return(:linux)
- allow(File).to receive(:exists?).with("/sys/block").and_return(true)
+ allow(File).to receive(:exist?).with("/sys/block").and_return(true)
allow(Dir).to receive(:[]).with("/sys/block/*") do
DISKS.collect { |disk, _files| "/sys/block/#{disk}" }
end
@@ -55,7 +55,7 @@ describe Ohai::System, "Linux Block Device Plugin" do
allow(File).to receive(:open).with(Regexp.new("#{disk}.*#{check}")).and_yield(file_double(value))
end
- allow(File).to receive(:exists?).with(Regexp.new(disk)) do |arg|
+ allow(File).to receive(:exist?).with(Regexp.new(disk)) do |arg|
filepath = arg.split("/")
checks[filepath.last].nil? ? false : true
end
diff --git a/spec/unit/plugins/linux/lsb_spec.rb b/spec/unit/plugins/linux/lsb_spec.rb
index ab976d4b..b5ab74a4 100644
--- a/spec/unit/plugins/linux/lsb_spec.rb
+++ b/spec/unit/plugins/linux/lsb_spec.rb
@@ -35,8 +35,8 @@ describe Ohai::System, "Linux lsb plugin" do
and_yield("DISTRIB_CODENAME=hardy").
and_yield('DISTRIB_DESCRIPTION="Ubuntu 8.04"')
allow(File).to receive(:open).with("/etc/lsb-release").and_return(@double_file)
- allow(File).to receive(:exists?).with("/usr/bin/lsb_release").and_return(false)
- allow(File).to receive(:exists?).with("/etc/lsb-release").and_return(true)
+ allow(File).to receive(:exist?).with("/usr/bin/lsb_release").and_return(false)
+ allow(File).to receive(:exist?).with("/etc/lsb-release").and_return(true)
end
it "should set lsb[:id]" do
@@ -62,7 +62,7 @@ describe Ohai::System, "Linux lsb plugin" do
describe "on systems with /usr/bin/lsb_release" do
before(:each) do
- allow(File).to receive(:exists?).with("/usr/bin/lsb_release").and_return(true)
+ allow(File).to receive(:exist?).with("/usr/bin/lsb_release").and_return(true)
@stdin = double("STDIN", { :close => true })
@pid = 10
@@ -140,8 +140,8 @@ LSB_RELEASE
end
it "should not set any lsb values if /etc/lsb-release or /usr/bin/lsb_release do not exist " do
- allow(File).to receive(:exists?).with("/etc/lsb-release").and_return(false)
- allow(File).to receive(:exists?).with("/usr/bin/lsb_release").and_return(false)
+ allow(File).to receive(:exist?).with("/etc/lsb-release").and_return(false)
+ allow(File).to receive(:exist?).with("/usr/bin/lsb_release").and_return(false)
expect(@plugin.attribute?(:lsb)).to be(false)
end
end
diff --git a/spec/unit/plugins/linux/machineid_spec.rb b/spec/unit/plugins/linux/machineid_spec.rb
index 6e0243bc..3c601ac2 100644
--- a/spec/unit/plugins/linux/machineid_spec.rb
+++ b/spec/unit/plugins/linux/machineid_spec.rb
@@ -28,8 +28,8 @@ describe Ohai::System, "Machine id plugin" do
it "should read /etc/machine-id if available" do
machine_id = "6f702523e2fc7499eb1dc68e5314dacf"
- allow(File).to receive(:exists?).with("/etc/machine-id").and_return(true)
- allow(File).to receive(:read).with("/etc/machine-id").and_return(machine_id)
+ allow(::File).to receive(:exist?).with("/etc/machine-id").and_return(true)
+ allow(::File).to receive(:read).with("/etc/machine-id").and_return(machine_id)
plugin.run
expect(plugin[:machine_id]).to eq(machine_id)
end
@@ -37,9 +37,9 @@ describe Ohai::System, "Machine id plugin" do
it "should read /var/lib/dbus/machine-id if available" do
machine_id = "6f702523e2fc7499eb1dc68e5314dacf"
- allow(File).to receive(:exists?).with("/etc/machine-id").and_return(false)
- allow(File).to receive(:exists?).with("/var/lib/dbus/machine-id").and_return(true)
- allow(File).to receive(:read).with("/var/lib/dbus/machine-id").and_return(machine_id)
+ allow(::File).to receive(:exist?).with("/etc/machine-id").and_return(false)
+ allow(::File).to receive(:exist?).with("/var/lib/dbus/machine-id").and_return(true)
+ allow(::File).to receive(:read).with("/var/lib/dbus/machine-id").and_return(machine_id)
plugin.run
expect(plugin[:machine_id]).to eq(machine_id)
end
diff --git a/spec/unit/plugins/ruby_spec.rb b/spec/unit/plugins/ruby_spec.rb
index b0404132..4fa62fef 100644
--- a/spec/unit/plugins/ruby_spec.rb
+++ b/spec/unit/plugins/ruby_spec.rb
@@ -49,7 +49,7 @@ describe Ohai::System, "plugin ruby" do
:gems_dir => `#{ruby_bin} #{::RbConfig::CONFIG["bindir"]}/gem env gemdir`.chomp,
:gem_bin => [ ::Gem.default_exec_format % "gem", "gem" ].map do |bin|
"#{::RbConfig::CONFIG['bindir']}/#{bin}"
- end.find { |bin| ::File.exists? bin },
+ end.find { |bin| ::File.exist? bin },
:ruby_bin => ruby_bin,
}.each do |attribute, value|
it "should have #{attribute} set to #{value.inspect}" do
diff --git a/spec/unit/plugins/solaris2/platform_spec.rb b/spec/unit/plugins/solaris2/platform_spec.rb
index f2394609..13b4120c 100644
--- a/spec/unit/plugins/solaris2/platform_spec.rb
+++ b/spec/unit/plugins/solaris2/platform_spec.rb
@@ -41,7 +41,7 @@ Origin# = 1
NumCPU = 16
UNAME_X
- allow(File).to receive(:exists?).with("/sbin/uname").and_return(true)
+ allow(File).to receive(:exist?).with("/sbin/uname").and_return(true)
allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
@release = StringIO.new(" SmartOS 20120130T201844Z x86_64\n")
@@ -81,7 +81,7 @@ Origin# = 1
NumCPU = 1
UNAME_X
- allow(File).to receive(:exists?).with("/sbin/uname").and_return(true)
+ allow(File).to receive(:exist?).with("/sbin/uname").and_return(true)
allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
@release = StringIO.new(" Oracle Solaris 11.1 X86\n")
diff --git a/spec/unit/plugins/ssh_host_keys_spec.rb b/spec/unit/plugins/ssh_host_keys_spec.rb
index cf8de1ac..b2ddb663 100644
--- a/spec/unit/plugins/ssh_host_keys_spec.rb
+++ b/spec/unit/plugins/ssh_host_keys_spec.rb
@@ -24,13 +24,13 @@ describe Ohai::System, "ssh_host_key plugin" do
@plugin = get_plugin("ssh_host_key")
@plugin[:keys] = Mash.new
- allow(File).to receive(:exists?).with("/etc/ssh/sshd_config").and_return(true)
+ allow(File).to receive(:exist?).with("/etc/ssh/sshd_config").and_return(true)
allow(File).to receive(:open).with("/etc/ssh/sshd_config").and_yield(sshd_config_file)
- allow(File).to receive(:exists?).and_return(true)
- allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(true)
- allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(true)
- allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(true)
- allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_ed25519_key.pub").and_return(true)
+ allow(File).to receive(:exist?).and_return(true)
+ allow(File).to receive(:exist?).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(true)
+ allow(File).to receive(:exist?).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(true)
+ allow(File).to receive(:exist?).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(true)
+ allow(File).to receive(:exist?).with("/etc/ssh/ssh_host_ed25519_key.pub").and_return(true)
# Ensure we can still use IO.read
io_read = IO.method(:read)
@@ -104,8 +104,8 @@ EOS
nil
end
before do
- allow(File).to receive(:exists?).with("/etc/ssh/sshd_config").and_return(false)
- allow(File).to receive(:exists?).with("/etc/sshd_config").and_return(false)
+ allow(File).to receive(:exist?).with("/etc/ssh/sshd_config").and_return(false)
+ allow(File).to receive(:exist?).with("/etc/sshd_config").and_return(false)
end
it_behaves_like "loads keys"