class_loader 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/class_loader/class_loader.rb +9 -7
- metadata +1 -1
@@ -35,7 +35,9 @@ module ClassLoader
|
|
35
35
|
rescue LoadError => e
|
36
36
|
# Not the best way - hardcoding error messages, but it's the fastest way
|
37
37
|
# to check existence of file & load it.
|
38
|
-
|
38
|
+
unless e.message =~ /no such file.*#{Regexp.escape(class_file_name)}/
|
39
|
+
raise e.class, e.message, filter_backtrace(e.backtrace)
|
40
|
+
end
|
39
41
|
false
|
40
42
|
end
|
41
43
|
|
@@ -43,14 +45,14 @@ module ClassLoader
|
|
43
45
|
# Checking that class hasn't been loaded previously, sometimes it may be caused by
|
44
46
|
# weird class definition code.
|
45
47
|
if loaded_classes.include? class_name
|
46
|
-
|
47
|
-
|
48
|
+
msg = "something wrong with '#{const}' referenced from '#{original_namespace}' scope!"
|
49
|
+
raise NameError, msg, filter_backtrace(caller)
|
48
50
|
end
|
49
51
|
|
50
52
|
# Checking that class defined in correct namespace, not the another one.
|
51
53
|
unless namespace ? namespace.const_defined?(const, false) : Object.const_defined?(const, false)
|
52
|
-
|
53
|
-
|
54
|
+
msg = "class name '#{class_name}' doesn't correspond to file name '#{class_file_name}'!"
|
55
|
+
raise NameError, msg, filter_backtrace(caller)
|
54
56
|
end
|
55
57
|
|
56
58
|
# Getting the class itself.
|
@@ -133,8 +135,8 @@ module ClassLoader
|
|
133
135
|
end
|
134
136
|
end
|
135
137
|
|
136
|
-
def
|
137
|
-
|
138
|
+
def filter_backtrace backtrace
|
139
|
+
backtrace.reject{|path| path.include?("/lib/class_loader") or path.include?('monitor.rb')}
|
138
140
|
end
|
139
141
|
end
|
140
142
|
end
|