rack-shelf 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b938a108e6359907bc7bec04a69ddae9e81207a8c5c7aded0d189359ef9a29ec
4
- data.tar.gz: 454922f5c0b22591dafccf73850b29aaef98909e46b4ad749298f7481d26e437
3
+ metadata.gz: 323f902f23ecc366ae24ff2e45bdb535f373f70f2680f9cc820d29bf995fe99c
4
+ data.tar.gz: 58d4e685bcff2ddd3dae1d521471e3aebf849f341e5f41857d05e99927dc75be
5
5
  SHA512:
6
- metadata.gz: 63d4c509ea364e4ae94923f939eb051f107abee03145714d0a3cfad11512d18321d7b465763df0c27926f17db2480f1291574edd54a9f53c0faedb15334e1f49
7
- data.tar.gz: 8e5aa94d9a2f057e25547b1652d4aba7043fa4684b3d034aa66cde63ca324c991a9ca19425943b176eb5b7ef882eb95128dfba9fb6caa07afa0c4943196595ca
6
+ metadata.gz: 0d6df0f5dede5de920329a16572c306e67ff2047b16684d1d25d555dbe78bc1dcfc0e648311c04a013ada4123e07c85d495ad7047039b8fc39c879a1f8bb1557
7
+ data.tar.gz: 1f742898ce21e0a78bf3f14f12a54cc6d81b4d6bbcf6058f12392b6d41a06d6cc3a9bd944ed49c3c85c45154e0e53fe9af20510b46a7e9413cf263daca155992
data/README.md CHANGED
@@ -20,7 +20,7 @@ gem 'rack-shelf'
20
20
  or gemspec:
21
21
 
22
22
  ```ruby
23
- s.add_dependency 'rack-shelf'
23
+ spec.add_dependency 'rack-shelf'
24
24
  ```
25
25
 
26
26
  Usage
@@ -33,7 +33,7 @@ require 'rack/shelf'
33
33
 
34
34
  class App
35
35
  def call
36
- [200, {}, 'Hello world!']
36
+ [200, {}, ['Hello world!']]
37
37
  end
38
38
  end
39
39
 
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'environment_builder'
4
+ require_relative 'lambda_context'
4
5
 
5
6
  module Rack
6
7
  module Shelf
7
8
  # Converts AWS API Gateway events given to Lambda
8
9
  # to Rack environment instances.
9
10
  class APIGateway
11
+ include LambdaContext
12
+
10
13
  # Produces a Rack compatible environment instance
11
14
  # from a Lambda event and context.
12
15
  # @param event [Hash] Event from the Lambda handler.
@@ -32,6 +35,7 @@ module Rack
32
35
  build_common
33
36
  build_headers
34
37
  build_body
38
+ build_lambda_context
35
39
 
36
40
  builder.build
37
41
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rack
4
+ module Shelf
5
+ # Mix-in for populating a Rack environment with Lambda context information.
6
+ module LambdaContext
7
+ # Prefix used for all environment keys.
8
+ PREFIX = 'aws.lambda'
9
+
10
+ # Adds the AWS Lambda context information to the Rack environment.
11
+ # @return [void]
12
+ def build_lambda_context # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
13
+ @builder.application(PREFIX, 'function_name', @context.function_name)
14
+ @builder.application(PREFIX, 'function_version', @context.function_version)
15
+ @builder.application(PREFIX, 'invoked_function_arn', @context.invoked_function_arn)
16
+ @builder.application(PREFIX, 'memory_limit_in_mb', @context.memory_limit_in_mb)
17
+ @builder.application(PREFIX, 'aws_request_id', @context.aws_request_id)
18
+ @builder.application(PREFIX, 'log_group_name', @context.log_group_name)
19
+ @builder.application(PREFIX, 'log_stream_name', @context.log_stream_name)
20
+ @builder.application(PREFIX, 'deadline_ms', @context.deadline_ms)
21
+ @builder.application(PREFIX, 'identity', @context.identity)
22
+ @builder.application(PREFIX, 'client_context', @context.client_context)
23
+ @builder.application(PREFIX, 'remaining_time_in_millis', lambda {
24
+ @context.get_remaining_time_in_millis
25
+ })
26
+ end
27
+ end
28
+ end
29
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  module Shelf
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-shelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Miller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-22 00:00:00.000000000 Z
11
+ date: 2020-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -53,6 +53,7 @@ files:
53
53
  - lib/rack/shelf/api_gateway.rb
54
54
  - lib/rack/shelf/base64_response_adapter.rb
55
55
  - lib/rack/shelf/environment_builder.rb
56
+ - lib/rack/shelf/lambda_context.rb
56
57
  - lib/rack/shelf/response_adapter.rb
57
58
  - lib/rack/shelf/version.rb
58
59
  homepage: https://gitlab.com/arctic-fox/rack-shelf
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubygems_version: 3.0.3
78
+ rubygems_version: 3.1.2
78
79
  signing_key:
79
80
  specification_version: 4
80
81
  summary: Adapts AWS Lambda event sources to Rack environments.