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.
@@ -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
- raise e unless e.message =~ /no such file.*#{Regexp.escape(class_file_name)}/
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
- raise_without_self NameError, \
47
- "something wrong with '#{const}' referenced from '#{original_namespace}' scope!"
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
- raise_without_self NameError, \
53
- "class name '#{class_name}' doesn't correspond to file name '#{class_file_name}'!"
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 raise_without_self exception, message
137
- raise exception, message, caller.select{|path| path !~ /\/lib\/class_loader\//}
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: class_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: