Class: Vedeu::Launcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

:nocov:

Parameters:

  • argv (Array)
  • stdin (defaults to: STDIN)
  • stdout (defaults to: STDOUT)
  • stderr (defaults to: STDERR)
  • kernel (defaults to: Kernel)


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vedeu/launcher.rb', line 11

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 Attribute Details

#argvObject (readonly, private)

Returns the value of attribute argv.



44
45
46
# File 'lib/vedeu/launcher.rb', line 44

def argv
  @argv
end

Instance Method Details

#execute!Object

Returns [].

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vedeu/launcher.rb', line 24

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

  Configuration.configure(argv)

  Application.start

  @exit_code = 0
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