lib/console_runner.rb in console_runner-0.1.6 vs lib/console_runner.rb in console_runner-0.1.7

- old
+ new

@@ -1,15 +1,15 @@ -module ConsoleRunner +require 'file_parser' +require 'cmd_parser' +require 'runner' +require 'console_runner/version' - require 'file_parser' - require 'cmd_parser' - require 'runner' +module ConsoleRunner file_from_arg = ARGV.shift raise ConsoleRunnerError, 'Specify file to be executed' unless file_from_arg - file_path ||= File.realpath file_from_arg - raise ConsoleRunnerError, "File doesn't exist: #{file_path}" unless File.exist? file_path + file_path = File.realpath file_from_arg file_parser = FileParser.new(file_path) runnable_classes = file_parser.list_classes(:runnable) if runnable_classes.count != 1 @@ -57,10 +57,12 @@ case method_type when :class klass_obj.send(action_method.name, *method_params) when :instance - init_params = cmd_parser.init_method.params_array + init_method = cmd_parser.init_method + init_params = [] + init_params = init_method.params_array if init_method # TODO catch errors obj = klass_obj.new(*init_params) obj.send(action_method.name, *method_params) else raise ConsoleRunnerError, "Unknown method type: #{method_type}" \ No newline at end of file