Class: Vedeu::Launcher

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/launcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Launcher

Returns a new instance of Launcher.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/vedeu/launcher.rb', line 3

def initialize(argv, stdin  = STDIN,
                     stdout = STDOUT,
                     stderr = STDERR,
                     kernel = Kernel)
  @argv      = argv
  @stdin     = stdin
  @stdout    = stdout
  @stderr    = stderr
  @kernel    = kernel
  @exit_code = 1
end

Instance Method Details

#execute!Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vedeu/launcher.rb', line 15

def execute!
  $stdin, $stdout, $stderr = @stdin, @stdout, @stderr

  Application.start(configuration)

  @exit_code = 0
# rescue Vedeu::API::InvalidHeight, Vedeu::API::InvalidWidth
#   Vedeu.error("Cannot run this application.\n " \
#               "Your terminal window is too small.")

rescue StandardError => uncaught_exception
  puts uncaught_exception.message
  puts uncaught_exception.backtrace.join("\n")

ensure
  $stdin, $stdout, $stderr = STDIN, STDOUT, STDERR
  @kernel.exit(@exit_code)

end