Module: Ripl::MultiLine::LiveError
- Defined in:
- lib/ripl/multi_line/live_error.rb
Constant Summary collapse
- VERSION =
"0.2.0"
- ERROR_MESSAGES =
{ :ruby => [ [[:literal, :string], /unterminated string meets end of file/], [[:literal, :regexp], /unterminated regexp meets end of file/], [[:literal, :array], /syntax error, unexpected end-of-input, expecting '\]'/], [[:literal, :hash], /syntax error, unexpected end-of-input, expecting '\}'/], # does not work for ranges or {5=> [[:statement], /syntax error, unexpected end-of-input/], ], :ruby19 => [ [[:literal, :string], /unterminated string meets end of file/], [[:literal, :regexp], /unterminated regexp meets end of file/], [[:literal, :array], /syntax error, unexpected \$end, expecting '\]'/], [[:literal, :hash], /syntax error, unexpected \$end, expecting '\}'/], # does not work for ranges or {5=> [[:statement], /syntax error, unexpected \$end/], ], :jruby => [ [[:literal, :string], /unterminated string meets end of file/], [[:literal, :regexp], /unterminated regexp meets end of file/], # array or hash cannot be detected [[:statement], /syntax error, unexpected end-of-file/], ], :rbx => [ [[:literal, :string], /unterminated [a-z]+ meets end of file/], # no extra message for regexes [[:literal], /expecting '\\n' or ';'/], # TODO: better rbx regexes or rbx bug report [[:literal, :hash], /expecting '\}'/], # [:literal, /expecting '\]'/], # [:literal, /expecting '\)'/], [[:statement], /syntax error, unexpected \$end/], [[:statement], /missing 'end'/], # for i in [2,3,4] do; ], }
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.ruby_engine ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/ripl/multi_line/live_error.rb', line 20 def self.ruby_engine return @ruby_engine if defined? @ruby_engine @ruby_engine = defined?(RUBY_ENGINE) && RUBY_ENGINE.downcase.to_sym @ruby_engine = :ruby if !ERROR_MESSAGES.keys.include?(ruby_engine) # 1.8 is same as 1.9 @ruby_engine = :ruby19 if ruby_engine == :ruby && RUBY_VERSION <= "2.0" @ruby_engine end |
Instance Method Details
#eval_input(input) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/ripl/multi_line/live_error.rb', line 68 def eval_input(input) if input =~ /;\s*\Z/ # force multi line with ; handle_multiline(:forced) elsif input =~ /^=begin(\s.*)?$/ && !@buffer @ignore_mode = true # MAYBE: change prompt elsif !@ignore_mode super end end |
#print_result(result) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/ripl/multi_line/live_error.rb', line 78 def print_result(result) if @ignore_mode && @input == '=end' @ignore_mode = false elsif !@ignore_mode super end end |