mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
Merge pull request #1023 from chef/ssd/remove-prepare_load_path
Remove SourceReader::Inspec#prepare_load_path
This commit is contained in:
commit
9f980cff99
1 changed files with 0 additions and 23 deletions
|
@ -34,7 +34,6 @@ module SourceReaders
|
|||
|
||||
@tests = load_tests
|
||||
@libraries = load_libs
|
||||
prepare_load_paths
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -52,27 +51,5 @@ module SourceReaders
|
|||
end
|
||||
Hash[tests.map { |x| [x, @target.read(x)] }]
|
||||
end
|
||||
|
||||
# Ensure each test directory exists on the $LOAD_PATH. This
|
||||
# will ensure traditional RSpec-isms like `require 'spec_helper'`
|
||||
# continue to work. The method outlined here is only meant to be temporary!
|
||||
def prepare_load_paths
|
||||
t = @target
|
||||
t = @target.parent unless @target.parent.nil?
|
||||
unless t.is_a?(Fetchers::Local)
|
||||
return # no need to mess with load-paths if this is not on disk
|
||||
end
|
||||
|
||||
rel_dirs = (@libraries.keys + @tests.keys)
|
||||
.map { |x| File.dirname(x) }.uniq
|
||||
|
||||
abs_dirs = rel_dirs.map { |x| @target.abs_path(x) }
|
||||
.find_all { |x| File.directory?(x) }
|
||||
.map { |x| File.expand_path(x) }
|
||||
|
||||
abs_dirs.each do |dir|
|
||||
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue