Sha256: 5d95861ac07da8f07456915ca68e1343fb89fd222d6c5594de1a2de35466968b

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

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

      Application.start(configuration)

      @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

    def configuration
      Configuration.configure(argv)
    end
    # :nocov:

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.1.17 lib/vedeu/launcher.rb
vedeu-0.1.16 lib/vedeu/launcher.rb