summaryrefslogtreecommitdiff
path: root/spec/run_oc_pedant.rb
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-08-19 22:58:00 -0700
committerTim Smith <tsmith84@gmail.com>2020-08-19 22:58:00 -0700
commit7cd521c4eca28cf24a1ae15f77d983db2be2e6a0 (patch)
tree770a7a5416f000ef96c5c2e16d12359054b37347 /spec/run_oc_pedant.rb
parent7e2d8e6a1b23cf459becfaaf0525a930bb2bd9e3 (diff)
downloadchef-zero-7cd521c4eca28cf24a1ae15f77d983db2be2e6a0.tar.gz
Optimize our requires
Avoid requiring things that are already defined. Rubygems is very slow at traversing the filesystem. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec/run_oc_pedant.rb')
-rw-r--r--spec/run_oc_pedant.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/spec/run_oc_pedant.rb b/spec/run_oc_pedant.rb
index b1760b6..13cfa5a 100644
--- a/spec/run_oc_pedant.rb
+++ b/spec/run_oc_pedant.rb
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-require "json"
+require "json" unless defined?(JSON)
require "bundler"
require "bundler/setup"
@@ -93,7 +93,7 @@ begin
tmpdir = nil
server =
if ENV["FILE_STORE"]
- require "tmpdir"
+ require "tmpdir" unless defined?(Dir.mktmpdir)
require "chef_zero/data_store/raw_file_store"
tmpdir = Dir.mktmpdir
data_store = ChefZero::DataStore::RawFileStore.new(tmpdir, true)
@@ -102,7 +102,7 @@ begin
start_chef_server(data_store: data_store)
elsif ENV["CHEF_FS"]
- require "tmpdir"
+ require "tmpdir" unless defined?(Dir.mktmpdir)
tmpdir = Dir.mktmpdir
start_cheffs_server(tmpdir)