summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Fitzgerald <rwfitzge@gmail.com>2013-07-27 14:44:33 -0700
committerRyan Fitzgerald <rwfitzge@gmail.com>2013-07-27 14:44:33 -0700
commit02881d024e42393a2ef1f0870768deefcdbc3e0a (patch)
treea6d9cfc3e08991b344089c789357922abee69717
parente6b7a06d54e2d41e6cb19d029f8abd9d66f94c1e (diff)
downloadmethod_source-02881d024e42393a2ef1f0870768deefcdbc3e0a.tar.gz
Remove colons from rbx regexps, separate from generic ones
-rw-r--r--lib/method_source/code_helpers.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/method_source/code_helpers.rb b/lib/method_source/code_helpers.rb
index 3b567b0..d555f5a 100644
--- a/lib/method_source/code_helpers.rb
+++ b/lib/method_source/code_helpers.rb
@@ -122,18 +122,33 @@ module MethodSource
# An exception matcher that matches only subsets of SyntaxErrors that can be
# fixed by adding more input to the buffer.
module IncompleteExpression
+ GENERIC_REGEXPS = [
+ /unexpected (\$end|end-of-file|end-of-input|END_OF_FILE)/, # mri, jruby, ruby-2.0, ironruby
+ /embedded document meets end of file/, # =begin
+ /unterminated (quoted string|string|regexp) meets end of file/ # "quoted string" is ironruby
+ ]
+
+ RBX_REGEXPS = [
+ /missing 'end' for/, /expecting '[})\]]'(?:$|:)/,
+ /can't find string ".*" anywhere before EOF/, /expecting keyword_end/,
+ /expecting kWHEN/
+ ]
+
def self.===(ex)
return false unless SyntaxError === ex
case ex.message
- when /unexpected (\$end|end-of-file|end-of-input|END_OF_FILE)/, # mri, jruby, ruby-2.0, ironruby
- /embedded document meets end of file/, # =begin
- /unterminated (quoted string|string|regexp) meets end of file/, # "quoted string" is ironruby
- /missing 'end' for/, /: expecting '[})\]]'$/, /can't find string ".*" anywhere before EOF/, /: expecting keyword_end/, /expecting kWHEN/ # rbx
+ when *GENERIC_REGEXPS
true
+ when *RBX_REGEXPS
+ rbx?
else
false
end
end
+
+ def self.rbx?
+ RbConfig::CONFIG['ruby_install_name'] == 'rbx'
+ end
end
end
end