Sha256: 278d3facb615b4f00fd15c71a52a4934d5c553f5dea7a0442eaa0c1ecb5078db

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

module Vedeu
  class Launcher

    # :nocov:
    # @param argv [Array]
    # @param stdin []
    # @param stdout []
    # @param stderr []
    # @param kernel []
    # @return [Launcher]
    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

    # @return []
    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

    private

    attr_reader :argv

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.1.18 lib/vedeu/launcher.rb