lib/load_tracer.rb in load_tracer-0.4.0 vs lib/load_tracer.rb in load_tracer-0.6.0
- old
+ new
@@ -1,6 +1,5 @@
-require 'binding_of_caller'
require 'load_tracer/formatter/default'
require 'load_tracer/formatter/dot'
require 'load_tracer/formatter/json'
require 'load_tracer/static_checker'
require 'load_tracer/version'
@@ -25,11 +24,13 @@
def require(feature)
__original_require__(feature)
end
def require_relative(relative_feature)
- binding.of_caller(1).eval("__original_require_relative__('#{relative_feature}')")
+ bl = caller_locations[0]
+ fpath = File.expand_path(relative_feature, File.dirname(bl.absolute_path))
+ __original_require__(fpath)
end
def load(file, priv = false)
__original_load__(file, priv)
end
@@ -55,10 +56,12 @@
def trace(format: nil)
@dependencies = Hash.new { |hash, key| hash[key] = [] }
@reverse_dependencies = Hash.new { |hash, key| hash[key] = [] }
@load_checked_features = Hash.new
@not_found_features = []
+ bl = caller_locations[1]
+ @exclude_files << bl.absolute_path
tracer.enable { yield }
report(format: format, dependencies: @dependencies, reverse_dependencies: @reverse_dependencies)
end
@@ -74,12 +77,12 @@
if bl.absolute_path.nil?
bl = find_caller_of_internal_library(feature)
end
- next if @exclude_files.include?(File.basename(bl.absolute_path))
+ next if @exclude_files.include?(bl.absolute_path)
- path = find_path(feature) || find_path(File.expand_path(feature, File.dirname(bl.path)))
+ path = find_path(feature) || find_path(File.expand_path(feature, File.dirname(bl.absolute_path)))
if path.nil?
@not_found_features << feature
next
end