diff options
author | Ryan Fitzgerald <rwfitzge@gmail.com> | 2013-07-27 14:44:33 -0700 |
---|---|---|
committer | Ryan Fitzgerald <rwfitzge@gmail.com> | 2013-07-27 14:44:33 -0700 |
commit | 02881d024e42393a2ef1f0870768deefcdbc3e0a (patch) | |
tree | a6d9cfc3e08991b344089c789357922abee69717 /lib/method_source/code_helpers.rb | |
parent | e6b7a06d54e2d41e6cb19d029f8abd9d66f94c1e (diff) | |
download | method_source-02881d024e42393a2ef1f0870768deefcdbc3e0a.tar.gz |
Remove colons from rbx regexps, separate from generic ones
Diffstat (limited to 'lib/method_source/code_helpers.rb')
-rw-r--r-- | lib/method_source/code_helpers.rb | 23 |
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 |