lamby 2.0.0 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18326760740ee9c10fd57da1a1d2400b0a09127a65ad908e1c298473983c3c45
4
- data.tar.gz: 379e871079160326aa6e55aed63f3822b8e2f3aa0bf3c4fedf89fdf309ae01f7
3
+ metadata.gz: 149e90cb77c4ba7fa86e278f1b5faff11e271eec286de22564f423c7510b9b41
4
+ data.tar.gz: 804d1d2df7a4ed8f61b3d7fdde9ee8d3c73c9902d5b846ced5f39b4680b3f672
5
5
  SHA512:
6
- metadata.gz: a19f7f5295ccf44518f18c1d22b0a3cdf1ecea9b3ffe882ec6fb7434b296dec1ec66215f9b6d28877f70f01968036196ca23ea0086c75c3eb185af98b7699ef4
7
- data.tar.gz: 6c509a8044e195c7b66fd923358ab2b5b2253a8138629bebea4bf17035eb44a995f55723fef5bc92b972169533c235a9afebe471267b6531ea18dc78d3f1ba60
6
+ metadata.gz: '0911fda5872e2ea6b74c0fc0d358da8c641f89ebaf59c7ea143c62fb80baa35f5e0e301d21b4222535b42bdb0c3bad3d028083355321e0b8178d0b4e18b9c6c0'
7
+ data.tar.gz: 7d827e35e4c19f714ddfb30182d00d51b944513c9ccf667782218be2429eb397f27c0cfdc2737b00aa2c992075061c8e5b3e7fdad59be2efb9097542156311cf
@@ -1,7 +1,46 @@
1
+ <!-- -*- mode: markdown -*- -->
1
2
  # Keep A Changelog!
2
3
 
3
4
  See this http://keepachangelog.com link for information on how we want this documented formatted.
4
5
 
6
+ ## v2.2.2
7
+
8
+ #### Changed
9
+
10
+ * More ActiveSupport removal. Better ENV.to_h.
11
+
12
+ ## v2.2.1
13
+
14
+ #### Changed
15
+
16
+ * More ActiveSupport removal from SsmParameterStore.
17
+
18
+ ## v2.2.0
19
+
20
+ #### Changed
21
+
22
+ * Remove dependency on `activesupport` for rack-only applications.
23
+ * Remove ActiveSupport artifacts:
24
+ - Replace `strip_heredoc` with `<<~HEREDOC`.
25
+ - Remove instances of `Object#try`, replace with `&.`.
26
+ - Use `Rack::Utils.build_nested_query` in place of `Object#to_query`.
27
+ - Replace `Object#present?` with `to_s.empty?`.
28
+ - Replace `Array.wrap` with `Array[obj].compact.flatten`.
29
+ * Add a check against the `RAILS_ENV` AND `RACK_ENV` environment
30
+ variables prior to enabling debug mode.
31
+
32
+ ## v2.1.0
33
+
34
+ #### Changed
35
+
36
+ * Only load the railtie if `Rails` is defined.
37
+
38
+ ## v2.0.1
39
+
40
+ #### Changed
41
+
42
+ * Remove Rails runtime dep. Only rack is needed.
43
+
5
44
  ## v2.0.0
6
45
 
7
46
  Support for new API Gateway HTTP APIs!!!
@@ -16,7 +55,7 @@ Support for new API Gateway HTTP APIs!!!
16
55
 
17
56
  #### Added
18
57
 
19
- * New reack handler for HTTP API v1 and v2.
58
+ * New rack handler for HTTP API v1 and v2.
20
59
  * Lots of backfill tests for, ALBs & REST APIs.
21
60
 
22
61
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
3
  gemspec
4
+
5
+ gem 'rails'
@@ -1,9 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lamby (2.0.0)
4
+ lamby (2.2.2)
5
5
  rack
6
- rails
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
@@ -163,6 +162,7 @@ DEPENDENCIES
163
162
  minitest-focus
164
163
  mocha
165
164
  pry
165
+ rails
166
166
  rake
167
167
 
168
168
  BUNDLED WITH
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
  spec.add_dependency 'rack'
22
- spec.add_dependency 'rails'
23
22
  spec.add_development_dependency 'aws-sdk-ssm'
24
23
  spec.add_development_dependency 'bundler'
25
24
  spec.add_development_dependency 'rake'
@@ -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'
@@ -10,8 +9,11 @@ require 'lamby/rack_rest'
10
9
  require 'lamby/rack_http'
11
10
  require 'lamby/debug'
12
11
  require 'lamby/handler'
13
- require 'rails/railtie'
14
- require 'lamby/railtie'
12
+
13
+ if defined?(Rails)
14
+ require 'rails/railtie'
15
+ require 'lamby/railtie'
16
+ end
15
17
 
16
18
  module Lamby
17
19
 
@@ -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.to_h
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.
@@ -16,12 +16,13 @@ module Lamby
16
16
  end
17
17
 
18
18
  def get!(path)
19
- parts = path.from(1).split('/')
19
+ parts = path[1..-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.0.0'
2
+ VERSION = '2.2.2'
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.0.0
4
+ version: 2.2.2
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-04-07 00:00:00.000000000 Z
11
+ date: 2020-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rails
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: aws-sdk-ssm
43
29
  requirement: !ruby/object:Gem::Requirement