summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-08-12 14:34:47 -0700
committerTim Smith <tsmith84@gmail.com>2020-08-12 14:34:47 -0700
commit0a2f993c69dc4d5644067bf8ae6f6bb078bf522b (patch)
tree831047783d2ed214bbf11921db94364f4c9adcd3 /lib/chef/provider
parent53dcbe99d02e4514ff19ca55add795686b2dfc13 (diff)
downloadchef-require_optimization.tar.gz
Optimize requires for non-omnibus installsrequire_optimization
Only require external libraries if we need to. Also use require_relative everywhere we can. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/ifconfig.rb2
-rw-r--r--lib/chef/provider/package/snap.rb2
-rw-r--r--lib/chef/provider/route.rb2
3 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb
index f8d84507a3..fbff49468a 100644
--- a/lib/chef/provider/ifconfig.rb
+++ b/lib/chef/provider/ifconfig.rb
@@ -20,7 +20,7 @@ require_relative "../log"
require_relative "../provider"
require_relative "../resource/file"
require_relative "../exceptions"
-require "erb"
+require "erb" unless defined?(Erb)
class Chef
class Provider
diff --git a/lib/chef/provider/package/snap.rb b/lib/chef/provider/package/snap.rb
index 77b33d5c7f..de723c5eb5 100644
--- a/lib/chef/provider/package/snap.rb
+++ b/lib/chef/provider/package/snap.rb
@@ -20,7 +20,7 @@ require_relative "../package"
require_relative "../../resource/snap_package"
require_relative "../../mixin/shell_out"
require "socket" unless defined?(Socket)
-require "json"
+require "json" unless defined?(JSON)
class Chef
class Provider
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb
index b6687bfb1f..afb1fd5a88 100644
--- a/lib/chef/provider/route.rb
+++ b/lib/chef/provider/route.rb
@@ -19,7 +19,7 @@
require_relative "../log"
require_relative "../provider"
-require "ipaddr"
+require "ipaddr" unless defined?(IPAddr)
class Chef
class Provider