Froze rails gems
[depot.git] / vendor / rails / activesupport / lib / active_support / core_ext / load_error.rb
1 class MissingSourceFile < LoadError #:nodoc:
2 attr_reader :path
3 def initialize(message, path)
4 super(message)
5 @path = path
6 end
7
8 def is_missing?(path)
9 path.gsub(/\.rb$/, '') == self.path.gsub(/\.rb$/, '')
10 end
11
12 def self.from_message(message)
13 REGEXPS.each do |regexp, capture|
14 match = regexp.match(message)
15 return MissingSourceFile.new(message, match[capture]) unless match.nil?
16 end
17 nil
18 end
19
20 REGEXPS = [
21 [/^no such file to load -- (.+)$/i, 1],
22 [/^Missing \w+ (file\s*)?([^\s]+.rb)$/i, 2],
23 [/^Missing API definition file in (.+)$/i, 1]
24 ] unless defined?(REGEXPS)
25 end
26
27 module ActiveSupport #:nodoc:
28 module CoreExtensions #:nodoc:
29 module LoadErrorExtensions #:nodoc:
30 module LoadErrorClassMethods #:nodoc:
31 def new(*args)
32 (self == LoadError && MissingSourceFile.from_message(args.first)) || super
33 end
34 end
35 ::LoadError.extend(LoadErrorClassMethods)
36 end
37 end
38 end