Skip to content

Commit

Permalink
Optimize our requires
Browse files Browse the repository at this point in the history
Avoid requiring things that are already defined. Rubygems is very slow at traversing the filesystem.

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 committed Aug 21, 2020
1 parent 244c1d4 commit 91e24db
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rescue LoadError
end

begin
require "yard"
require "yard" unless defined?(YARD)
YARD::Rake::YardocTask.new(:docs)
rescue LoadError
puts "yard is not available. bundle install first to make sure all dependencies are installed."
Expand Down
2 changes: 1 addition & 1 deletion lib/mixlib/log/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# limitations under the License.

require "logger"
require "time"
require "time" unless defined?(Time)

module Mixlib
module Log
Expand Down
4 changes: 2 additions & 2 deletions spec/mixlib/log/child_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# limitations under the License.
#

require "tempfile"
require "stringio"
require "tempfile" unless defined?(Tempfile)
require "stringio" unless defined?(StringIO)
require "spec_helper"

RSpec.describe Mixlib::Log::Child do
Expand Down
2 changes: 1 addition & 1 deletion spec/mixlib/log/formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# limitations under the License.
#

require "time"
require "time" unless defined?(Time)
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))

RSpec.describe Mixlib::Log::Formatter do
Expand Down
4 changes: 2 additions & 2 deletions spec/mixlib/log_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# limitations under the License.
#

require "tempfile"
require "stringio"
require "tempfile" unless defined?(Tempfile)
require "stringio" unless defined?(StringIO)
require "spec_helper"

class LoggerLike
Expand Down

0 comments on commit 91e24db

Please sign in to comment.