Sha256: c283c83e9c9d7bdeda03b59459f17f6b7ad4988855515a5c5fc501ab3e5530bc
Contents?: true
Size: 1.7 KB
Versions: 8
Compression:
Stored size: 1.7 KB
Contents
module Vedeu # This class ensures that STDIN, STDOUT and STDERR point to the correct # places. It also handles the initial configuration of the application, # the starting of the application, the handling of uncaught exceptions and # finally the exiting of the application with the correct exit code. # # @api public class Launcher attr_reader :exit_code # @see Vedeu::Launcher#initialize def self.execute!(argv = [], stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) new(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel).execute! end # @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 Vedeu.log("Exiting gracefully.") $stdin, $stdout, $stderr = STDIN, STDOUT, STDERR @kernel.exit(exit_code) end private attr_reader :argv end # Launcher end # Vedeu
Version data entries
8 entries across 8 versions & 1 rubygems