From 537596bbfed43d08a0bfcbe6b685a026e60c9a09 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Wed, 15 May 2019 10:33:04 -0700 Subject: [PATCH] Apply require speedups to ohai Same kinds of fixes from chef core with require_relative and idempotency checks. Signed-off-by: Lamont Granquist --- lib/ohai.rb | 8 +++--- lib/ohai/application.rb | 6 ++--- lib/ohai/config.rb | 4 +-- lib/ohai/dsl.rb | 4 +-- lib/ohai/dsl/plugin.rb | 10 +++---- lib/ohai/hints.rb | 2 +- lib/ohai/loader.rb | 8 +++--- lib/ohai/mixin/azure_metadata.rb | 2 +- lib/ohai/mixin/command.rb | 6 ++--- lib/ohai/mixin/do_metadata.rb | 2 +- lib/ohai/mixin/ec2_metadata.rb | 2 +- lib/ohai/mixin/gce_metadata.rb | 2 +- lib/ohai/mixin/http_helper.rb | 2 +- lib/ohai/mixin/scaleway_metadata.rb | 2 +- lib/ohai/mixin/softlayer_metadata.rb | 2 +- lib/ohai/plugin_config.rb | 2 +- lib/ohai/plugins/azure.rb | 4 +-- lib/ohai/plugins/bsd/virtualization.rb | 2 +- lib/ohai/plugins/digital_ocean.rb | 4 +-- lib/ohai/plugins/dmi.rb | 2 +- lib/ohai/plugins/ec2.rb | 4 +-- lib/ohai/plugins/eucalyptus.rb | 4 +-- lib/ohai/plugins/gce.rb | 4 +-- lib/ohai/plugins/hostname.rb | 4 +-- lib/ohai/plugins/kernel.rb | 2 +- lib/ohai/plugins/linux/fips.rb | 2 +- lib/ohai/plugins/linux/virtualization.rb | 2 +- lib/ohai/plugins/network.rb | 2 +- lib/ohai/plugins/openstack.rb | 4 +-- lib/ohai/plugins/os.rb | 2 +- lib/ohai/plugins/packages.rb | 2 +- lib/ohai/plugins/passwd.rb | 2 +- lib/ohai/plugins/scaleway.rb | 4 +-- lib/ohai/plugins/scsi.rb | 2 +- lib/ohai/plugins/softlayer.rb | 2 +- lib/ohai/plugins/solaris2/dmi.rb | 2 +- lib/ohai/plugins/solaris2/virtualization.rb | 2 +- lib/ohai/plugins/uptime.rb | 2 +- lib/ohai/plugins/windows/fips.rb | 2 +- lib/ohai/plugins/windows/virtualization.rb | 2 +- lib/ohai/provides_map.rb | 8 +++--- lib/ohai/runner.rb | 2 +- lib/ohai/system.rb | 30 ++++++++++----------- lib/ohai/util/win32.rb | 2 +- 44 files changed, 85 insertions(+), 85 deletions(-) diff --git a/lib/ohai.rb b/lib/ohai.rb index 83724d97d..be34833ce 100644 --- a/lib/ohai.rb +++ b/lib/ohai.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require "ohai/version" -require "ohai/config" -require "ohai/system" -require "ohai/exception" +require_relative "ohai/version" +require_relative "ohai/config" +require_relative "ohai/system" +require_relative "ohai/exception" diff --git a/lib/ohai/application.rb b/lib/ohai/application.rb index b1455cabf..a469fc565 100644 --- a/lib/ohai/application.rb +++ b/lib/ohai/application.rb @@ -17,9 +17,9 @@ require "chef-config/path_helper" require "chef-config/workstation_config_loader" -require "ohai" -require "ohai/log" -require "mixlib/cli" +require_relative "../ohai" +require_relative "log" +require "mixlib/cli" unless defined?(Mixlib::CLI) require "benchmark" # The Application class is what is called by the Ohai CLI binary. It handles: diff --git a/lib/ohai/config.rb b/lib/ohai/config.rb index 6029a26f4..66790d989 100644 --- a/lib/ohai/config.rb +++ b/lib/ohai/config.rb @@ -18,8 +18,8 @@ # require "chef-config/config" -require "ohai/exception" -require "ohai/plugin_config" +require_relative "exception" +require_relative "plugin_config" module Ohai Config = ChefConfig::Config diff --git a/lib/ohai/dsl.rb b/lib/ohai/dsl.rb index 7ee6645a7..a899a7f43 100644 --- a/lib/ohai/dsl.rb +++ b/lib/ohai/dsl.rb @@ -17,5 +17,5 @@ # limitations under the License. # -require "ohai/dsl/plugin" -require "ohai/dsl/plugin/versionvii" +require_relative "dsl/plugin" +require_relative "dsl/plugin/versionvii" diff --git a/lib/ohai/dsl/plugin.rb b/lib/ohai/dsl/plugin.rb index b102edc08..0abb160d5 100644 --- a/lib/ohai/dsl/plugin.rb +++ b/lib/ohai/dsl/plugin.rb @@ -18,11 +18,11 @@ # limitations under the License. # -require "ohai/mixin/os" -require "ohai/mixin/command" -require "ohai/mixin/seconds_to_human" -require "ohai/hints" -require "ohai/util/file_helper" +require_relative "../mixin/os" +require_relative "../mixin/command" +require_relative "../mixin/seconds_to_human" +require_relative "../hints" +require_relative "../util/file_helper" module Ohai diff --git a/lib/ohai/hints.rb b/lib/ohai/hints.rb index ffa02a432..c1ec22a35 100644 --- a/lib/ohai/hints.rb +++ b/lib/ohai/hints.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require "ffi_yajl" +require "ffi_yajl" unless defined?(FFI_Yajl) module Ohai # Ohai hints are json files on disk that give ohai a hint to things that are often diff --git a/lib/ohai/loader.rb b/lib/ohai/loader.rb index 663d1d4e0..733aab570 100644 --- a/lib/ohai/loader.rb +++ b/lib/ohai/loader.rb @@ -17,10 +17,10 @@ # require "chef-config/path_helper" -require "ohai/log" -require "ohai/mash" -require "ohai/dsl" -require "pathname" +require_relative "log" +require_relative "mash" +require_relative "dsl" +require "pathname" unless defined?(Pathname) module Ohai diff --git a/lib/ohai/mixin/azure_metadata.rb b/lib/ohai/mixin/azure_metadata.rb index 1087fcb83..783ef8a90 100644 --- a/lib/ohai/mixin/azure_metadata.rb +++ b/lib/ohai/mixin/azure_metadata.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require "net/http" +require "net/http" unless defined?(Net::HTTP) module Ohai module Mixin diff --git a/lib/ohai/mixin/command.rb b/lib/ohai/mixin/command.rb index eb4844b53..f791c7f17 100644 --- a/lib/ohai/mixin/command.rb +++ b/lib/ohai/mixin/command.rb @@ -17,9 +17,9 @@ # limitations under the License. # -require "ohai/exception" -require "ohai/log" -require "mixlib/shellout" +require_relative "../exception" +require_relative "../log" +require "mixlib/shellout" unless defined?(Mixlib::ShellOut) module Ohai module Mixin diff --git a/lib/ohai/mixin/do_metadata.rb b/lib/ohai/mixin/do_metadata.rb index b41b80b87..10d850caa 100644 --- a/lib/ohai/mixin/do_metadata.rb +++ b/lib/ohai/mixin/do_metadata.rb @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require "net/http" +require "net/http" unless defined?(Net::HTTP) module Ohai module Mixin diff --git a/lib/ohai/mixin/ec2_metadata.rb b/lib/ohai/mixin/ec2_metadata.rb index 4c878e72b..d050c473f 100644 --- a/lib/ohai/mixin/ec2_metadata.rb +++ b/lib/ohai/mixin/ec2_metadata.rb @@ -17,7 +17,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require "net/http" +require "net/http" unless defined?(Net::HTTP) module Ohai module Mixin diff --git a/lib/ohai/mixin/gce_metadata.rb b/lib/ohai/mixin/gce_metadata.rb index 929928c7c..6200cab67 100644 --- a/lib/ohai/mixin/gce_metadata.rb +++ b/lib/ohai/mixin/gce_metadata.rb @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require "net/http" +require "net/http" unless defined?(Net::HTTP) module Ohai module Mixin diff --git a/lib/ohai/mixin/http_helper.rb b/lib/ohai/mixin/http_helper.rb index 28a99b795..007476e66 100644 --- a/lib/ohai/mixin/http_helper.rb +++ b/lib/ohai/mixin/http_helper.rb @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require "socket" +require "socket" unless defined?(Socket) module Ohai module Mixin diff --git a/lib/ohai/mixin/scaleway_metadata.rb b/lib/ohai/mixin/scaleway_metadata.rb index eb281035d..ab88559fe 100644 --- a/lib/ohai/mixin/scaleway_metadata.rb +++ b/lib/ohai/mixin/scaleway_metadata.rb @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require "net/http" +require "net/http" unless defined?(Net::HTTP) module Ohai module Mixin diff --git a/lib/ohai/mixin/softlayer_metadata.rb b/lib/ohai/mixin/softlayer_metadata.rb index cc2b25f69..d2270380d 100644 --- a/lib/ohai/mixin/softlayer_metadata.rb +++ b/lib/ohai/mixin/softlayer_metadata.rb @@ -18,7 +18,7 @@ # limitations under the License. require "net/https" -require "uri" +require "uri" unless defined?(URI) # https://softlayer.github.io/reference/services/SoftLayer_Resource_Metadata/ module ::Ohai::Mixin::SoftlayerMetadata diff --git a/lib/ohai/plugin_config.rb b/lib/ohai/plugin_config.rb index b757af217..73c6e4320 100644 --- a/lib/ohai/plugin_config.rb +++ b/lib/ohai/plugin_config.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require "ohai/exception" +require_relative "exception" module Ohai class PluginConfig < Hash diff --git a/lib/ohai/plugins/azure.rb b/lib/ohai/plugins/azure.rb index 781a55a78..d0a12567f 100644 --- a/lib/ohai/plugins/azure.rb +++ b/lib/ohai/plugins/azure.rb @@ -15,8 +15,8 @@ # Ohai.plugin(:Azure) do - require "ohai/mixin/azure_metadata" - require "ohai/mixin/http_helper" + require_relative "../mixin/azure_metadata" + require_relative "../mixin/http_helper" include Ohai::Mixin::AzureMetadata include Ohai::Mixin::HttpHelper diff --git a/lib/ohai/plugins/bsd/virtualization.rb b/lib/ohai/plugins/bsd/virtualization.rb index 9635070fd..2e2c3a76a 100644 --- a/lib/ohai/plugins/bsd/virtualization.rb +++ b/lib/ohai/plugins/bsd/virtualization.rb @@ -20,7 +20,7 @@ Ohai.plugin(:Virtualization) do provides "virtualization" depends "dmi" - require "ohai/mixin/dmi_decode" + require_relative "../../mixin/dmi_decode" include Ohai::Mixin::DmiDecode collect_data(:freebsd, :openbsd, :netbsd, :dragonflybsd) do diff --git a/lib/ohai/plugins/digital_ocean.rb b/lib/ohai/plugins/digital_ocean.rb index 8e6b3028d..4ee39e2f4 100644 --- a/lib/ohai/plugins/digital_ocean.rb +++ b/lib/ohai/plugins/digital_ocean.rb @@ -16,8 +16,8 @@ # limitations under the License. Ohai.plugin(:DigitalOcean) do - require "ohai/mixin/do_metadata" - require "ohai/mixin/http_helper" + require_relative "../mixin/do_metadata" + require_relative "../mixin/http_helper" include Ohai::Mixin::DOMetadata include Ohai::Mixin::HttpHelper diff --git a/lib/ohai/plugins/dmi.rb b/lib/ohai/plugins/dmi.rb index 10fe46c37..7c3e5f4ba 100644 --- a/lib/ohai/plugins/dmi.rb +++ b/lib/ohai/plugins/dmi.rb @@ -22,7 +22,7 @@ # dmidecode does not return data without access to /dev/mem (or its equivalent) collect_data do - require "ohai/common/dmi" + require_relative "../common/dmi" dmi Mash.new # all output lines should fall within one of these patterns diff --git a/lib/ohai/plugins/ec2.rb b/lib/ohai/plugins/ec2.rb index 8df09c3f0..bd75588ee 100644 --- a/lib/ohai/plugins/ec2.rb +++ b/lib/ohai/plugins/ec2.rb @@ -26,8 +26,8 @@ # 4. Kernel data mentioned Amazon. This catches Windows HVM & paravirt instances Ohai.plugin(:EC2) do - require "ohai/mixin/ec2_metadata" - require "ohai/mixin/http_helper" + require_relative "../mixin/ec2_metadata" + require_relative "../mixin/http_helper" require "base64" include Ohai::Mixin::Ec2Metadata diff --git a/lib/ohai/plugins/eucalyptus.rb b/lib/ohai/plugins/eucalyptus.rb index 810491947..2b34bf6df 100644 --- a/lib/ohai/plugins/eucalyptus.rb +++ b/lib/ohai/plugins/eucalyptus.rb @@ -19,8 +19,8 @@ Ohai.plugin(:Eucalyptus) do # eucalyptus metadata service is compatible with the ec2 service calls - require "ohai/mixin/ec2_metadata" - require "ohai/mixin/http_helper" + require_relative "../mixin/ec2_metadata" + require_relative "../mixin/http_helper" include Ohai::Mixin::Ec2Metadata include Ohai::Mixin::HttpHelper diff --git a/lib/ohai/plugins/gce.rb b/lib/ohai/plugins/gce.rb index b38cf7fcb..974adaff5 100644 --- a/lib/ohai/plugins/gce.rb +++ b/lib/ohai/plugins/gce.rb @@ -15,8 +15,8 @@ # limitations under the License. Ohai.plugin(:GCE) do - require "ohai/mixin/gce_metadata" - require "ohai/mixin/http_helper" + require_relative "../mixin/gce_metadata" + require_relative "../mixin/http_helper" include Ohai::Mixin::GCEMetadata include Ohai::Mixin::HttpHelper diff --git a/lib/ohai/plugins/hostname.rb b/lib/ohai/plugins/hostname.rb index f333bf4ad..911a7d9b3 100644 --- a/lib/ohai/plugins/hostname.rb +++ b/lib/ohai/plugins/hostname.rb @@ -26,7 +26,7 @@ # Ohai.plugin(:Hostname) do - require "socket" + require "socket" unless defined?(Socket) require "ipaddr" provides "domain", "hostname", "fqdn", "machinename" @@ -161,7 +161,7 @@ def collect_hostname collect_data(:windows) do require "wmi-lite/wmi" - require "socket" + require "socket" unless defined?(Socket) wmi = WmiLite::Wmi.new host = wmi.first_of("Win32_ComputerSystem") diff --git a/lib/ohai/plugins/kernel.rb b/lib/ohai/plugins/kernel.rb index b3964c4cb..204af4788 100644 --- a/lib/ohai/plugins/kernel.rb +++ b/lib/ohai/plugins/kernel.rb @@ -247,7 +247,7 @@ def blacklisted_wmi_name?(name) end collect_data(:windows) do - require "win32ole" + require "win32ole" unless defined?(WIN32OLE) require "wmi-lite/wmi" WIN32OLE.codepage = WIN32OLE::CP_UTF8 diff --git a/lib/ohai/plugins/linux/fips.rb b/lib/ohai/plugins/linux/fips.rb index 70d5e1424..2f90ea94b 100644 --- a/lib/ohai/plugins/linux/fips.rb +++ b/lib/ohai/plugins/linux/fips.rb @@ -28,7 +28,7 @@ collect_data(:linux) do fips Mash.new - require "openssl" + require "openssl" unless defined?(OpenSSL) if defined?(OpenSSL.fips_mode) && OpenSSL.fips_mode && !$FIPS_TEST_MODE fips["kernel"] = { "enabled" => true } else diff --git a/lib/ohai/plugins/linux/virtualization.rb b/lib/ohai/plugins/linux/virtualization.rb index fdc4b197b..e99997ebb 100644 --- a/lib/ohai/plugins/linux/virtualization.rb +++ b/lib/ohai/plugins/linux/virtualization.rb @@ -19,7 +19,7 @@ Ohai.plugin(:Virtualization) do provides "virtualization" depends "dmi" - require "ohai/mixin/dmi_decode" + require_relative "../../mixin/dmi_decode" include Ohai::Mixin::DmiDecode def lxc_version_exists? diff --git a/lib/ohai/plugins/network.rb b/lib/ohai/plugins/network.rb index 88c72226b..9b9811dc2 100644 --- a/lib/ohai/plugins/network.rb +++ b/lib/ohai/plugins/network.rb @@ -18,7 +18,7 @@ Ohai.plugin(:NetworkAddresses) do require "ipaddress" - require "ohai/mixin/network_constants" + require_relative "../mixin/network_constants" include Ohai::Mixin::NetworkConstants provides "ipaddress", "ip6address", "macaddress" diff --git a/lib/ohai/plugins/openstack.rb b/lib/ohai/plugins/openstack.rb index 22d4db571..cd2731da8 100644 --- a/lib/ohai/plugins/openstack.rb +++ b/lib/ohai/plugins/openstack.rb @@ -17,8 +17,8 @@ # limitations under the License. Ohai.plugin(:Openstack) do - require "ohai/mixin/ec2_metadata" - require "ohai/mixin/http_helper" + require_relative "../mixin/ec2_metadata" + require_relative "../mixin/http_helper" include Ohai::Mixin::Ec2Metadata include Ohai::Mixin::HttpHelper diff --git a/lib/ohai/plugins/os.rb b/lib/ohai/plugins/os.rb index 5955f73fa..d46e70af2 100644 --- a/lib/ohai/plugins/os.rb +++ b/lib/ohai/plugins/os.rb @@ -20,7 +20,7 @@ # Ohai.plugin(:OS) do - require "ohai/mixin/os" + require_relative "../mixin/os" provides "os", "os_version" depends "kernel" diff --git a/lib/ohai/plugins/packages.rb b/lib/ohai/plugins/packages.rb index f7054a150..56ab252bc 100644 --- a/lib/ohai/plugins/packages.rb +++ b/lib/ohai/plugins/packages.rb @@ -104,7 +104,7 @@ def collect_programs_from_registry_key(key_path) end collect_data(:windows) do - require "win32/registry" + require "win32/registry" unless defined?(Win32::Registry) packages Mash.new collect_programs_from_registry_key('Software\Microsoft\Windows\CurrentVersion\Uninstall') # on 64 bit systems, 32 bit programs are stored here diff --git a/lib/ohai/plugins/passwd.rb b/lib/ohai/plugins/passwd.rb index 70a304635..5519adc63 100644 --- a/lib/ohai/plugins/passwd.rb +++ b/lib/ohai/plugins/passwd.rb @@ -1,6 +1,6 @@ Ohai.plugin(:Passwd) do - require "etc" + require "etc" unless defined?(Etc) provides "etc", "current_user" optional true diff --git a/lib/ohai/plugins/scaleway.rb b/lib/ohai/plugins/scaleway.rb index e1cb8a873..2b83acf3a 100644 --- a/lib/ohai/plugins/scaleway.rb +++ b/lib/ohai/plugins/scaleway.rb @@ -15,8 +15,8 @@ # limitations under the License. Ohai.plugin(:Scaleway) do - require "ohai/mixin/scaleway_metadata" - require "ohai/mixin/http_helper" + require_relative "../mixin/scaleway_metadata" + require_relative "../mixin/http_helper" include Ohai::Mixin::ScalewayMetadata include Ohai::Mixin::HttpHelper diff --git a/lib/ohai/plugins/scsi.rb b/lib/ohai/plugins/scsi.rb index 13081867a..0dfc80f92 100644 --- a/lib/ohai/plugins/scsi.rb +++ b/lib/ohai/plugins/scsi.rb @@ -21,7 +21,7 @@ provides "scsi" optional true - require "mixlib/shellout" + require "mixlib/shellout" unless defined?(Mixlib::ShellOut) collect_data(:linux) do devices = Mash.new diff --git a/lib/ohai/plugins/softlayer.rb b/lib/ohai/plugins/softlayer.rb index 0f025c9c2..34b2c343c 100644 --- a/lib/ohai/plugins/softlayer.rb +++ b/lib/ohai/plugins/softlayer.rb @@ -19,7 +19,7 @@ # limitations under the License. Ohai.plugin(:Softlayer) do - require "ohai/mixin/softlayer_metadata" + require_relative "../mixin/softlayer_metadata" include ::Ohai::Mixin::SoftlayerMetadata provides "softlayer" diff --git a/lib/ohai/plugins/solaris2/dmi.rb b/lib/ohai/plugins/solaris2/dmi.rb index 51f5fb05e..ecbc6f2dc 100644 --- a/lib/ohai/plugins/solaris2/dmi.rb +++ b/lib/ohai/plugins/solaris2/dmi.rb @@ -20,7 +20,7 @@ provides "dmi" collect_data(:solaris2) do - require "ohai/common/dmi" + require_relative "../../common/dmi" # if we already have a "dmi" with keys (presumably from dmidecode), don't try smbios # note that a single key just means dmidecode exited with its version diff --git a/lib/ohai/plugins/solaris2/virtualization.rb b/lib/ohai/plugins/solaris2/virtualization.rb index d0187e87e..3b3473f48 100644 --- a/lib/ohai/plugins/solaris2/virtualization.rb +++ b/lib/ohai/plugins/solaris2/virtualization.rb @@ -19,7 +19,7 @@ # Ohai.plugin(:Virtualization) do - require "ohai/mixin/dmi_decode" + require_relative "../../mixin/dmi_decode" include Ohai::Mixin::DmiDecode provides "virtualization" depends "dmi" diff --git a/lib/ohai/plugins/uptime.rb b/lib/ohai/plugins/uptime.rb index a2294fb3a..5883f13ce 100644 --- a/lib/ohai/plugins/uptime.rb +++ b/lib/ohai/plugins/uptime.rb @@ -25,7 +25,7 @@ # Ohai.plugin(:Uptime) do - require "ohai/mixin/seconds_to_human" + require_relative "../mixin/seconds_to_human" provides "uptime", "uptime_seconds" provides "idletime", "idletime_seconds" # linux only diff --git a/lib/ohai/plugins/windows/fips.rb b/lib/ohai/plugins/windows/fips.rb index 085c7f2c4..27d36f2dd 100644 --- a/lib/ohai/plugins/windows/fips.rb +++ b/lib/ohai/plugins/windows/fips.rb @@ -28,7 +28,7 @@ collect_data(:windows) do fips Mash.new - require "openssl" + require "openssl" unless defined?(OpenSSL) if defined?(OpenSSL.fips_mode) && OpenSSL.fips_mode && !$FIPS_TEST_MODE fips["kernel"] = { "enabled" => true } else diff --git a/lib/ohai/plugins/windows/virtualization.rb b/lib/ohai/plugins/windows/virtualization.rb index b60aff8b6..3a4e5532e 100644 --- a/lib/ohai/plugins/windows/virtualization.rb +++ b/lib/ohai/plugins/windows/virtualization.rb @@ -20,7 +20,7 @@ Ohai.plugin(:Virtualization) do provides "virtualization" - require "ohai/mixin/dmi_decode" + require_relative "../../mixin/dmi_decode" include Ohai::Mixin::DmiDecode collect_data(:windows) do diff --git a/lib/ohai/provides_map.rb b/lib/ohai/provides_map.rb index 0aba19393..d803d2985 100644 --- a/lib/ohai/provides_map.rb +++ b/lib/ohai/provides_map.rb @@ -17,10 +17,10 @@ # limitations under the License. # -require "ohai/mash" -require "ohai/exception" -require "ohai/mixin/os" -require "ohai/dsl" +require_relative "mash" +require_relative "exception" +require_relative "mixin/os" +require_relative "dsl" module Ohai class ProvidesMap diff --git a/lib/ohai/runner.rb b/lib/ohai/runner.rb index f11d936ab..cc7766183 100644 --- a/lib/ohai/runner.rb +++ b/lib/ohai/runner.rb @@ -17,7 +17,7 @@ # limitations under the License # -require "ohai/dsl" +require_relative "dsl" require "benchmark" module Ohai diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb index a19e19ca6..b075c8140 100644 --- a/lib/ohai/system.rb +++ b/lib/ohai/system.rb @@ -16,21 +16,21 @@ # limitations under the License. # -require "ohai/version" -require "ohai/loader" -require "ohai/log" -require "ohai/mash" -require "ohai/runner" -require "ohai/dsl" -require "ohai/mixin/command" -require "ohai/mixin/os" -require "ohai/mixin/string" -require "ohai/mixin/constant_helper" -require "ohai/provides_map" -require "ohai/hints" -require "mixlib/shellout" -require "ohai/config" -require "ffi_yajl" +require_relative "version" +require_relative "loader" +require_relative "log" +require_relative "mash" +require_relative "runner" +require_relative "dsl" +require_relative "mixin/command" +require_relative "mixin/os" +require_relative "mixin/string" +require_relative "mixin/constant_helper" +require_relative "provides_map" +require_relative "hints" +require "mixlib/shellout" unless defined?(Mixlib::ShellOut) +require_relative "config" +require "ffi_yajl" unless defined?(FFI_Yajl) module Ohai # The class used by Ohai::Application and Chef to actually collect data diff --git a/lib/ohai/util/win32.rb b/lib/ohai/util/win32.rb index 5cf638d07..5d5ab156b 100644 --- a/lib/ohai/util/win32.rb +++ b/lib/ohai/util/win32.rb @@ -21,7 +21,7 @@ module Util module Win32 if RUBY_PLATFORM =~ /mswin|mingw|windows/ - require "ffi" + require "ffi" unless defined?(FFI) extend FFI::Library