Sha256: 413de7e5c742f2a0f8738c72d2987269ca346a1e2c8c894326d24419976e3344

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'vedeu/application'
require 'vedeu/configuration'

module Vedeu
  class 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

    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

    private

    attr_reader :argv

    def configuration
      Configuration.configure(argv)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.1.9 lib/vedeu/launcher.rb
vedeu-0.1.8 lib/vedeu/launcher.rb