Sha256: 682d18ca839a3b4480a6a8b170496eed59881419cecfd60c4b288794d178f64c

Contents?: true

Size: 971 Bytes

Versions: 284

Compression:

Stored size: 971 Bytes

Contents

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

Version data entries

284 entries across 251 versions & 30 rubygems

Version Path
depengine-0.0.21 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.21 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.20 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.20 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.19 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.19 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.18 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.18 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.17 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.17 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.16 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.16 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.15 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.15 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.14 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.14 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.13 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.13 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.12 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb
depengine-0.0.12 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/load_error.rb