lamby 2.1.0 → 2.2.0

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: 9bb411b8d5961ebef380fdd6148d5349481a9f8d5ec4f935e6d3db25647b8c81
4
- data.tar.gz: 889122ece8d9d93a695f8d941f37e56e898dc20c4c3e529e07fe89b87b7f043d
3
+ metadata.gz: 9c79ddbdbe89366400b406896007cc36bac36cbe640d8485b3c33f87aaddb169
4
+ data.tar.gz: b1be59cec48ed5ce9c32b4f6275230b4cb266f1d35119706e50c93f520c58b79
5
5
  SHA512:
6
- metadata.gz: dd62c1917031b62e0364e381dd003a24e7836e852656f02f2d4c8b77f4804b3c283a7303b4eb16ed5f5165eef8c6fa0e717e46bc15e559885e29cb7a7bab383c
7
- data.tar.gz: 531a661486ef2473f83730f5bf22601429fffc52e39164bc38b473984a321ad3ce294fd21d81bef2e254746d4481af6190031470e64e1d50d55c0d995de53769
6
+ metadata.gz: ccf32a0550fa045d46af392932b57b5e3bb1e51155f6641225f06bbd89e2252635affb5733a51d753a18cd215cb0ade070d96c47c694f42eb864f9b30a597005
7
+ data.tar.gz: 796122743e00d8322364c58e34555ba4355698965aa452b389c707440d86777f2a508cb4325120b0e35105570a3b24c4b7993d28cfdc22f9c9f8e69773341ae4
@@ -3,6 +3,20 @@
3
3
 
4
4
  See this http://keepachangelog.com link for information on how we want this documented formatted.
5
5
 
6
+ ## v2.2.0
7
+
8
+ #### Changed
9
+
10
+ * Remove dependency on `activesupport` for rack-only applications.
11
+ * Remove ActiveSupport artifacts:
12
+ - Replace `strip_heredoc` with `<<~HEREDOC`.
13
+ - Remove instances of `Object#try`, replace with `&.`.
14
+ - Use `Rack::Utils.build_nested_query` in place of `Object#to_query`.
15
+ - Replace `Object#present?` with `to_s.empty?`.
16
+ - Replace `Array.wrap` with `Array[obj].compact.flatten`.
17
+ * Add a check against the `RAILS_ENV` AND `RACK_ENV` environment
18
+ variables prior to enabling debug mode.
19
+
6
20
  ## v2.1.0
7
21
 
8
22
  #### Changed
@@ -29,7 +43,7 @@ Support for new API Gateway HTTP APIs!!!
29
43
 
30
44
  #### Added
31
45
 
32
- * New reack handler for HTTP API v1 and v2.
46
+ * New rack handler for HTTP API v1 and v2.
33
47
  * Lots of backfill tests for, ALBs & REST APIs.
34
48
 
35
49
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lamby (2.1.0)
4
+ lamby (2.2.0)
5
5
  rack
6
6
 
7
7
  GEM
@@ -1,7 +1,6 @@
1
1
  require 'lamby/logger'
2
2
  require 'rack'
3
3
  require 'base64'
4
- require 'active_support/all'
5
4
  require 'lamby/version'
6
5
  require 'lamby/sam_helpers'
7
6
  require 'lamby/rack'
@@ -6,7 +6,7 @@ module Lamby
6
6
 
7
7
  def on?(event)
8
8
  params = event['multiValueQueryStringParameters'] || event['queryStringParameters']
9
- (Rails.env.development? || ENV['LAMBY_DEBUG']) && params && params['debug'] == '1'
9
+ (development? || ENV['LAMBY_DEBUG']) && params && params['debug'] == '1'
10
10
  end
11
11
 
12
12
  def call(event, context, env)
@@ -42,5 +42,12 @@ module Lamby
42
42
  HTML
43
43
  end
44
44
 
45
+ def development?
46
+ ENV
47
+ .slice('RACK_ENV', 'RAILS_ENV')
48
+ .values
49
+ .any? { |v| v.to_s.casecmp('development').zero? }
50
+ end
51
+
45
52
  end
46
53
  end
@@ -71,10 +71,20 @@ module Lamby
71
71
  value.map{ |v| "#{key}=#{v}" }.join('&')
72
72
  end.flatten.join('&')
73
73
  else
74
- event['queryStringParameters'].try(:to_query)
74
+ build_query_string
75
75
  end
76
76
  end
77
77
 
78
+ def build_query_string
79
+ return if event['queryStringParameters'].nil?
80
+
81
+ Rack::Utils.build_nested_query(
82
+ event.fetch('queryStringParameters')
83
+ )
84
+ .gsub('[', '%5B')
85
+ .gsub(']', '%5D')
86
+ end
87
+
78
88
  def base64_encoded?
79
89
  event['isBase64Encoded']
80
90
  end
@@ -11,7 +11,7 @@ module Lamby
11
11
 
12
12
  def response(handler)
13
13
  hhdrs = handler.headers
14
- multivalue_headers = hhdrs.transform_values { |v| Array.wrap(v) } if multi_value?
14
+ multivalue_headers = hhdrs.transform_values { |v| Array[v].compact.flatten } if multi_value?
15
15
  status_description = "#{handler.status} #{::Rack::Utils::HTTP_STATUS_CODES[handler.status]}"
16
16
  base64_encode = hhdrs['Content-Transfer-Encoding'] == 'binary' || hhdrs['X-Lamby-Base64'] == '1'
17
17
  body = Base64.strict_encode64(handler.body) if base64_encode
@@ -38,8 +38,8 @@ module Lamby
38
38
 
39
39
  def env_headers
40
40
  super.tap do |hdrs|
41
- if event['cookies'].present?
42
- hdrs[HTTP_COOKIE] = event['cookies'].join('; ')
41
+ if cookies.any?
42
+ hdrs[HTTP_COOKIE] = cookies.join('; ')
43
43
  end
44
44
  end
45
45
  end
@@ -48,6 +48,10 @@ module Lamby
48
48
  event.dig('requestContext', 'http', 'method') || event['httpMethod']
49
49
  end
50
50
 
51
+ def cookies
52
+ event['cookies'] || []
53
+ end
54
+
51
55
  # Using custom domain names with v1.0 yields a good `path` parameter sans
52
56
  # stage. However, v2.0 and others do not. So we are just going to remove stage
53
57
  # no matter waht from other places for both.
@@ -19,9 +19,10 @@ module Lamby
19
19
  parts = path.from(1).split('/')
20
20
  env = parts.pop
21
21
  path = "/#{parts.join('/')}"
22
- new(path).get!.params.detect do |p|
22
+ param = new(path).get!.params.detect do |p|
23
23
  p.env == env
24
- end.try(:value)
24
+ end
25
+ param&.value
25
26
  end
26
27
 
27
28
  end
@@ -44,7 +45,7 @@ module Lamby
44
45
 
45
46
  def get!
46
47
  get_all!
47
- get_history! if label.present?
48
+ get_history! unless label.to_s.empty?
48
49
  self
49
50
  end
50
51
 
@@ -98,7 +99,7 @@ module Lamby
98
99
  with_decryption: true,
99
100
  max_results: MAX_RESULTS
100
101
  }.tap { |options|
101
- token = @all_response.try(:next_token)
102
+ token = @all_response&.next_token
102
103
  options[:next_token] = token if token
103
104
  }
104
105
  end
@@ -137,7 +138,7 @@ module Lamby
137
138
  with_decryption: true,
138
139
  max_results: MAX_RESULTS
139
140
  }.tap { |options|
140
- token = @hist_response.try(:next_token)
141
+ token = @hist_response&.next_token
141
142
  options[:next_token] = token if token
142
143
  }
143
144
  end
@@ -10,7 +10,7 @@ gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
10
10
 
11
11
  say 'Adding to .gitignore...'
12
12
  FileUtils.touch app_file('.gitignore')
13
- append_to_file app_file('.gitignore'), <<-GITIGNORE.strip_heredoc
13
+ append_to_file app_file('.gitignore'), <<~GITIGNORE
14
14
  # Lamby
15
15
  /.aws-sam
16
16
  GITIGNORE
@@ -10,7 +10,7 @@ gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
10
10
 
11
11
  say 'Adding to .gitignore...'
12
12
  FileUtils.touch app_file('.gitignore')
13
- append_to_file app_file('.gitignore'), <<-GITIGNORE.strip_heredoc
13
+ append_to_file app_file('.gitignore'), <<~GITIGNORE
14
14
  # Lamby
15
15
  /.aws-sam
16
16
  GITIGNORE
@@ -10,7 +10,7 @@ gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
10
10
 
11
11
  say 'Adding to .gitignore...'
12
12
  FileUtils.touch app_file('.gitignore')
13
- append_to_file app_file('.gitignore'), <<-GITIGNORE.strip_heredoc
13
+ append_to_file app_file('.gitignore'), <<~GITIGNORE
14
14
  # Lamby
15
15
  /.aws-sam
16
16
  GITIGNORE
@@ -1,3 +1,3 @@
1
1
  module Lamby
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lamby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-22 00:00:00.000000000 Z
11
+ date: 2020-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack