Exception: LoadError

Inherits:
Exception show all
Defined in:
lib/active_support/core_ext/load_error.rb

Constant Summary collapse

REGEXPS =
[
  /^no such file to load -- (.+)$/i,
  /^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
  /^Missing API definition file in (.+)$/i,
  /^cannot load such file -- (.+)$/i,
]

Instance Method Summary collapse

Methods inherited from Exception

#as_json

Instance Method Details

#is_missing?(location) ⇒ Boolean

Returns true if the given path name (except perhaps for the “.rb” extension) is the missing file which caused the exception to be raised.

Returns:

  • (Boolean)


26
27
28
# File 'lib/active_support/core_ext/load_error.rb', line 26

def is_missing?(location)
  location.sub(/\.rb$/, ''.freeze) == path.sub(/\.rb$/, ''.freeze)
end

#pathObject

Returns the path which was unable to be loaded.



14
15
16
17
18
19
20
21
# File 'lib/active_support/core_ext/load_error.rb', line 14

def path
  @path ||= begin
    REGEXPS.find do |regex|
      message =~ regex
    end
    $1
  end
end