module MethodSource::CodeHelpers::IncompleteExpression

An exception matcher that matches only subsets of SyntaxErrors that can be fixed by adding more input to the buffer.

Public Class Methods

===(ex) click to toggle source
# File lib/method_source/code_helpers.rb, line 125
def self.===(ex)
  return false unless SyntaxError === ex
  case ex.message
  when %runexpected (\$end|end-of-file|END_OF_FILE)/, # mri, jruby, ironruby
    %rembedded document meets end of file/, # =begin
    %runterminated (quoted string|string|regexp) meets end of file/, # "quoted string" is ironruby
    %rmissing 'end' for/, %r: expecting '[})\]]'$/, %rcan't find string ".*" anywhere before EOF/, %r: expecting keyword_end/, %rexpecting kWHEN/ # rbx
    true
  else
    false
  end
end