Exception: MissingSourceFile

Inherits:
LoadError
  • Object
show all
Defined in:
lib/active_support/core_ext/load_error.rb

Overview

:nodoc:

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, path) ⇒ MissingSourceFile

Returns a new instance of MissingSourceFile.



3
4
5
6
# File 'lib/active_support/core_ext/load_error.rb', line 3

def initialize(message, path)
  super(message)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



2
3
4
# File 'lib/active_support/core_ext/load_error.rb', line 2

def path
  @path
end

Class Method Details

.from_message(message) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/active_support/core_ext/load_error.rb', line 12

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

Instance Method Details

#is_missing?(path) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/active_support/core_ext/load_error.rb', line 8

def is_missing?(path)
  path.gsub(/\.rb$/, '') == self.path.gsub(/\.rb$/, '')
end