class Codewars::Runner
Public Class Methods
new(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
click to toggle source
# File lib/codewars/runner.rb, line 5 def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) init_pry @argv = argv @stdin = stdin @stdout = stdout @stderr = stderr @kernel = kernel end
Public Instance Methods
execute!()
click to toggle source
# File lib/codewars/runner.rb, line 14 def execute! exit_code = run_cli @kernel.exit(exit_code) end
Private Instance Methods
init_pry()
click to toggle source
# File lib/codewars/runner.rb, line 21 def init_pry require 'pry' Pry.config.output = STDOUT # without this Pry does't work properly rescue LoadError nil end
run_cli()
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/codewars/runner.rb, line 29 def run_cli exit_code = begin $stderr = @stderr $stdin = @stdin $stdout = @stdout Codewars::CLI.start(@argv) 0 rescue StandardError => e b = e.backtrace @stderr.puts("#{b.shift}: #{e.message} (#{e.class})") @stderr.puts(b.map { |s| "\tfrom #{s}" }.join("\n")) 1 rescue SystemExit => e e.status ensure $stderr = STDERR $stdin = STDIN $stdout = STDOUT end @kernel.exit(exit_code) end