jets 3.0.17 → 3.0.18

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: a03ac914d64e082dd8973795f04e9e4ebd3878b0eb04663e97ef368eecc19eb3
4
- data.tar.gz: 56fe08319ec68002c7990d140dd26e90cdd7ff13b503702bf94dcddb60e12e4a
3
+ metadata.gz: 30209fb06ab88c5a593d26b7d20bf15f1164b5915a40f23ea8f61b2f7538361a
4
+ data.tar.gz: 5c68efddc6c6b6c183c2191f23f5729c094247031ff88c3d0d73db2ea1e992e2
5
5
  SHA512:
6
- metadata.gz: 9bdcb8d9549179d4adf082abaa0b7353b758b4168019dc43a5208e427186462875bc2e843378461747b756f976d2b62ee175714a7081455ddacb532b4f1b6e2f
7
- data.tar.gz: 5d79ca553952a1413abf1ac4a143f6b905bf1067662c4642e598932ff5ee15b135334d57fbb3530171e63f8322c9e46dc60e6349c1d2e3c06b1416ce386a2821
6
+ metadata.gz: 843dac414dc95a7aefc8ff4e02df7dc652319fdffefb1b61ce44043955021d6f438cc0877eb814e5b160220a17744b349120484a8633da18744158360e68ded1
7
+ data.tar.gz: 2b5b0dfb86f76f09d9bcc9f2a167a7af0cd260fde702fd4c6b7dc5db4f7af9d949a04fd77d2fb2e54ce0f3681a606064c249f7e6944d565d4d6a38b8c41afb9d
data/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [3.0.18] - 2021-10-20
7
+ - [#596](https://github.com/boltops-tools/jets/pull/596) Serialize job data correctly
8
+ - [#598](https://github.com/boltops-tools/jets/pull/598) fixing issues when mounting
9
+ - [#599](https://github.com/boltops-tools/jets/pull/599) pin to zeitwerk 2.4.x
10
+ - [#600](https://github.com/boltops-tools/jets/pull/600) method override also on the lambda function side
11
+
6
12
  ## [3.0.17] - 2021-09-15
7
13
  - [#593](https://github.com/boltops-tools/jets/pull/593) Fix deploy for new projects. Added rescue block back into lib/jets/commands/deploy.rb
8
14
 
data/jets.gemspec CHANGED
@@ -61,7 +61,7 @@ Gem::Specification.new do |spec|
61
61
  spec.add_dependency "shotgun"
62
62
  spec.add_dependency "text-table"
63
63
  spec.add_dependency "thor"
64
- spec.add_dependency "zeitwerk"
64
+ spec.add_dependency "zeitwerk", "~> 2.4.0"
65
65
 
66
66
  spec.add_development_dependency "bundler"
67
67
  spec.add_development_dependency "byebug"
@@ -43,7 +43,7 @@ class Jets::Controller
43
43
  # Most of the time, you want process! instead of dispatch!
44
44
  #
45
45
  def process!
46
- adapter = Jets::Controller::Rack::Adapter.new(event, context, meth)
46
+ adapter = Jets::Controller::Rack::Adapter.new(event, context)
47
47
  adapter.rack_vars(
48
48
  'jets.controller' => self,
49
49
  'lambda.context' => context,
@@ -75,6 +75,8 @@ class Jets::Controller
75
75
  # dispatch! is useful for megamode or mounted applications
76
76
  #
77
77
  def dispatch!
78
+ method_override!
79
+
78
80
  t1 = Time.now
79
81
  log_start
80
82
 
@@ -99,12 +101,30 @@ class Jets::Controller
99
101
  triplet # status, headers, body
100
102
  end
101
103
 
104
+ # Override @meth when POST with _method=delete
105
+ # By the time processing reaches dispatch which calls method_override!
106
+ # The Rack::MethodOverride middleware has overriden env['REQUEST_METHOD'] with DELETE
107
+ # and set env['rack.methodoverride.original_method']
108
+ def method_override!
109
+ env = request.env
110
+ if env['rack.methodoverride.original_method'] && env['REQUEST_METHOD'] == 'DELETE'
111
+ @original_meth = @meth
112
+ @meth = "delete"
113
+ end
114
+ end
115
+
116
+ def processing_log
117
+ processing = "Processing #{self.class.name}##{@meth}"
118
+ processing << " (original method #{@original_meth})" if @original_meth
119
+ processing
120
+ end
121
+
102
122
  # Documented interface method, careful not to rename
103
123
  def log_start
104
124
  # JSON.dump makes logging look pretty in CloudWatch logs because it keeps it on 1 line
105
125
  ip = request.ip
106
126
  Jets.logger.info "Started #{@event['httpMethod']} \"#{@event['path']}\" for #{ip} at #{Time.now}"
107
- Jets.logger.info "Processing #{self.class.name}##{@meth}"
127
+ Jets.logger.info processing_log
108
128
  Jets.logger.info " Event: #{event_log}"
109
129
  Jets.logger.info " Parameters: #{JSON.dump(filtered_parameters.to_h)}"
110
130
  end
@@ -5,13 +5,13 @@ module Jets::Controller::Rack
5
5
  extend Memoist
6
6
 
7
7
  # Returns back API Gateway response hash structure
8
- def self.process(event, context, meth)
9
- adapter = new(event, context, meth)
8
+ def self.process(event, context)
9
+ adapter = new(event, context)
10
10
  adapter.process
11
11
  end
12
12
 
13
- def initialize(event, context, meth)
14
- @event, @context, @meth = event, context, meth
13
+ def initialize(event, context)
14
+ @event, @context = event, context
15
15
  end
16
16
 
17
17
  # 1. Convert API Gateway event event to Rack env
@@ -27,12 +27,12 @@ module Jets::Controller::Rack
27
27
  def path_with_base_path
28
28
  resource = @event['resource']
29
29
  pathParameters = @event['pathParameters']
30
-
30
+
31
31
  if(!pathParameters.nil? and !resource.nil?)
32
32
  resource = pathParameters.reduce(resource) {|resource, parameter|
33
33
  key, value = parameter
34
- key = key.eql?("catchall") ? "{#{key}+}" : "{#{key}}"
35
- resource = resource.gsub(key, value)
34
+ resource = resource.gsub("{#{key}+}", value)
35
+ resource = resource.gsub("{#{key}}", value)
36
36
  resource
37
37
  }
38
38
  end
@@ -64,7 +64,9 @@ module Jets::Controller::Rack
64
64
  end
65
65
 
66
66
  def content_type
67
- headers['Content-Type'] || Jets::Controller::DEFAULT_CONTENT_TYPE
67
+ # Rack (local) uses Content-Type and APIGW (remote) uses content-type
68
+ # Rack::MethodOverride relys on content-type to detect content type properly.
69
+ headers['Content-Type'] || headers['content-type'] || Jets::Controller::DEFAULT_CONTENT_TYPE
68
70
  end
69
71
 
70
72
  def content_length
data/lib/jets/job/base.rb CHANGED
@@ -26,13 +26,13 @@ module Jets::Job
26
26
  end
27
27
 
28
28
  def perform_now(meth, event={}, context={})
29
- new(event, context, meth).send(meth)
29
+ new(event.try(:to_unsafe_h), context, meth).send(meth)
30
30
  end
31
31
 
32
32
  def perform_later(meth, event={}, context={})
33
33
  if on_lambda?
34
34
  function_name = "#{self.to_s.underscore}-#{meth}"
35
- call = Jets::Commands::Call.new(function_name, JSON.dump(event), invocation_type: "Event")
35
+ call = Jets::Commands::Call.new(function_name, JSON.dump(event.try(:to_unsafe_h)), invocation_type: "Event")
36
36
  call.run
37
37
  else
38
38
  puts "INFO: Not on AWS Lambda. In local mode perform_later executes the job with perform_now instead."
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "3.0.17"
2
+ VERSION = "3.0.18"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.17
4
+ version: 3.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-15 00:00:00.000000000 Z
11
+ date: 2021-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -490,16 +490,16 @@ dependencies:
490
490
  name: zeitwerk
491
491
  requirement: !ruby/object:Gem::Requirement
492
492
  requirements:
493
- - - ">="
493
+ - - "~>"
494
494
  - !ruby/object:Gem::Version
495
- version: '0'
495
+ version: 2.4.0
496
496
  type: :runtime
497
497
  prerelease: false
498
498
  version_requirements: !ruby/object:Gem::Requirement
499
499
  requirements:
500
- - - ">="
500
+ - - "~>"
501
501
  - !ruby/object:Gem::Version
502
- version: '0'
502
+ version: 2.4.0
503
503
  - !ruby/object:Gem::Dependency
504
504
  name: bundler
505
505
  requirement: !ruby/object:Gem::Requirement