X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=vendor%2Frails%2Factivesupport%2Flib%2Factive_support%2Fcore_ext%2Fload_error.rb;fp=vendor%2Frails%2Factivesupport%2Flib%2Factive_support%2Fcore_ext%2Fload_error.rb;h=6165e95443ef7672fb7c93ea74dd7cbbb0494c0e;hb=437aa336c44c74a30aeea16a06743c32747ed661;hp=0000000000000000000000000000000000000000;hpb=97a0772b06264134cfe38e7494f9427efe0840a0;p=feedcatcher.git

diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb b/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb
new file mode 100644
index 0000000..6165e95
--- /dev/null
+++ b/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb
@@ -0,0 +1,38 @@
+class MissingSourceFile < LoadError #:nodoc:
+  attr_reader :path
+  def initialize(message, path)
+    super(message)
+    @path = path
+  end
+
+  def is_missing?(path)
+    path.gsub(/\.rb$/, '') == self.path.gsub(/\.rb$/, '')
+  end
+
+  def self.from_message(message)
+    REGEXPS.each do |regexp, capture|
+      match = regexp.match(message)
+      return MissingSourceFile.new(message, match[capture]) unless match.nil?
+    end
+    nil
+  end
+
+  REGEXPS = [
+    [/^no such file to load -- (.+)$/i, 1],
+    [/^Missing \w+ (file\s*)?([^\s]+.rb)$/i, 2],
+    [/^Missing API definition file in (.+)$/i, 1]
+  ] unless defined?(REGEXPS)
+end
+
+module ActiveSupport #:nodoc:
+  module CoreExtensions #:nodoc:
+    module LoadErrorExtensions #:nodoc:
+      module LoadErrorClassMethods #:nodoc:
+        def new(*args)
+          (self == LoadError && MissingSourceFile.from_message(args.first)) || super
+        end
+      end
+      ::LoadError.extend(LoadErrorClassMethods)
+    end
+  end
+end