lib/ruby_lambda/execute.rb in ruby_lambda-0.3.2 vs lib/ruby_lambda/execute.rb in ruby_lambda-0.4.0

- old
+ new

@@ -6,13 +6,11 @@ @current_directory = current_directory @shell = Thor::Base.shell.new @options = options end - def run(mute: false) - @mute = mute - + def run begin if @options.has_key?('handler') lambda_function, lambda_handler = @options['handler'].split('.') elsif @options.has_key?('config') @@ -25,17 +23,13 @@ event = JSON.parse(File.read("#{@current_directory}/event.json")) context = LambdaContext.new() - if mute - send(:"#{lambda_handler}", event: event, context: context) - else - ap send(:"#{lambda_handler}", event: event, context: context), options = { :indent => -2 } - end + ap send(:"#{lambda_handler}", event: event, context: context), options = { :indent => -2 } rescue LoadError - @shell.say('Handler file or function, can not be found', :red) unless @mute + @shell.say('Handler file or function, can not be found', :red) exit 1 end end @@ -47,24 +41,24 @@ config_data['handler'].split('.') rescue Errno::ENOENT no_config_file_message = 'Config file missing, create a config.yml file or use the -c / --config flag to use a different config file. Alternativly you can use the -H flag to pass the name of the handler that should be executed' - @shell.say(no_config_file_message, :red) unless @mute + @shell.say(no_config_file_message, :red) exit 1 rescue RubyLambda::ExecuteError - @shell.say('Invalid config file', :red) unless @mute + @shell.say('Invalid config file', :red) exit 1 end end def check_for_handler(lambda_function, lambda_handler) if lambda_handler.nil? || lambda_handler.nil? no_defined_handler_message = 'No config or handler function defined, create a config.yml file or use the -c / --config flag to use a different config file. Alternativly you can use the -H flag to pass the name of the handler that should be executed' - @shell.say(no_defined_handler_message, :red) unless @mute + @shell.say(no_defined_handler_message, :red) exit 1 end end end