Module: Nirvana::Shell

Defined in:
lib/nirvana/shell.rb

Overview

Included into Ripl::Shell at runtime

Instance Method Summary collapse

Instance Method Details

#format_result(result) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/nirvana/shell.rb', line 29

def format_result(result)
  stdout, stderr, output = Util.capture_all { super }
  @stdout << (stdout.empty? ? output : stdout)
  @stderr << stderr
  output = Util.format_output @stdout
  output = "<div class='nirvana_warning'>#{@stderr}</div>" + output unless @stderr.to_s.empty?
  output
end

#loop_eval(str) ⇒ Object



20
21
22
23
# File 'lib/nirvana/shell.rb', line 20

def loop_eval(str)
  @stdout, @stderr, result = Util.capture_all { super(str) }
  result
end


25
26
27
# File 'lib/nirvana/shell.rb', line 25

def print_eval_error(error)
  @eval_error = html_error(error, '')
end


16
17
18
# File 'lib/nirvana/shell.rb', line 16

def print_result(result)
  @eval_error || format_result(@result)
end

#web_loop_once(input) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/nirvana/shell.rb', line 7

def web_loop_once(input)
  super
  @eval_error = nil
  @input[/^:AUTOCOMPLETE:/] ? get_completions(@input) : loop_once
rescue Exception => e
  exit if e.message[/^uncaught throw `ripl_exit'/]
  html_error(e, "Internal #{@name} error: ")
end