Class: Lambchop::Cat
- Inherits:
-
Object
- Object
- Lambchop::Cat
- Defined in:
- lib/lambchop/cat.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cat ⇒ Object
-
#initialize(function_name, invoke_args, options = {}) ⇒ Cat
constructor
A new instance of Cat.
Constructor Details
#initialize(function_name, invoke_args, options = {}) ⇒ Cat
Returns a new instance of Cat.
6 7 8 9 10 11 12 |
# File 'lib/lambchop/cat.rb', line 6 def initialize(function_name, invoke_args, = {}) @function_name = function_name @invoke_args = invoke_args @client = [:client] || Aws::Lambda::Client.new @out = [:out] || $stdout @options = end |
Class Method Details
.cat(function_name, invoke_args, options = {}) ⇒ Object
2 3 4 |
# File 'lib/lambchop/cat.rb', line 2 def self.cat(function_name, invoke_args, = {}) self.new(function_name, invoke_args, ).cat end |
Instance Method Details
#cat ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/lambchop/cat.rb', line 14 def cat invoke_args = @invoke_args if invoke_args.kind_of?(IO) invoke_args = invoke_args.read end resp = @client.invoke( :function_name => @function_name, :payload => invoke_args, :invocation_type => Lambchop::Utils.camelize(@options[:invocation_type] || :request_response), :log_type => Lambchop::Utils.camelize(@options[:log_type] || :none) ) out = { 'status_code' => resp[:status_code], 'function_error' => resp[:function_error], 'payload' => nil } log_result = resp[:log_result] payload = resp[:payload] if log_result log_result = Base64.strict_decode64(log_result) log_result.gsub!("\t", ' ').gsub!(/\s+\n/, "\n").strip! def log_result.yaml_style() Psych::Nodes::Scalar::LITERAL end out['log_result'] = log_result end if payload out['payload'] = payload.string end @out.puts YAML.dump(out) end |