class Bricolage::SQSMock::Message
Attributes
message_id[R]
receipt_handle[R]
Public Class Methods
new(message_id: nil, receipt_handle: nil, body: nil)
click to toggle source
# File lib/bricolage/sqsmock.rb, line 172 def initialize(message_id: nil, receipt_handle: nil, body: nil) @message_id = message_id @receipt_handle = receipt_handle @body = body @body_json = { Records: [body] }.to_json end
new_seq()
click to toggle source
# File lib/bricolage/sqsmock.rb, line 158 def Message.new_seq @seq += 1 @seq end
s3_object_created_event(url)
click to toggle source
# File lib/bricolage/sqsmock.rb, line 132 def Message.s3_object_created_event(url) raise "is not a S3 URL: #{url.inspect}" unless %r<\As3://\w> =~ url bucket, key = url.sub(%r<s3://>, '').split('/', 2) with_body({ eventVersion: '2.0', eventSource: 'aws:s3', awsRegion: 'ap-northeast-1', eventTime: Time.now.iso8601, eventName: 'ObjectCreated:Put', s3: { s3SchemaVersion: '1.0', configurationId: 'TestConfig', bucket: { name: bucket, arn: "arn:aws:s3:::#{bucket}" }, object: { key: key, size: 1024 } } }) end
with_body(body)
click to toggle source
# File lib/bricolage/sqsmock.rb, line 163 def Message.with_body(body) seq = new_seq new( message_id: "sqs-message-id-#{seq}", receipt_handle: "sqs-receipt-handle-#{seq}", body: body ) end
Public Instance Methods
body()
click to toggle source
# File lib/bricolage/sqsmock.rb, line 182 def body @body_json end
body_object()
click to toggle source
for debug
# File lib/bricolage/sqsmock.rb, line 187 def body_object @body end