jets 1.9.28 → 1.9.29

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: 56af9d1af06caefd6d27aee0d4f3bf53fb4b3365a3612bf6bb7b70c841e12ff5
4
- data.tar.gz: 6d64131cf5a0e9606a7698c846d9eb6110558f8a869ed09e1b0fda4dc192ecbb
3
+ metadata.gz: 79e4c2c7bfc0d49e93f4f16272d4d4208e59d408a29ec26be8ff904ccebe1d2f
4
+ data.tar.gz: bca0a08b1917fee8fad565dc6cc5bd59774388f737a3377f0961e4fed8cbc549
5
5
  SHA512:
6
- metadata.gz: 253a2700d3e187c657fbf0c3fbfbdaac1a592dc2d9b851873f4bc33652ffbe23f5bfab3479ca44ffd45b65265532b2ba3dd22b24e2f98b17f7048aeaa7bd945c
7
- data.tar.gz: 2267b30bdb7c481c4f91fa482dac924f5820b567ad8540942b54a2948288426f3bf23f83bf3714d20f8ffbeef8a231533f81293ed1c720b27c53b7c3f2ffd2f8
6
+ metadata.gz: a6c2b17a8da82d9e6056950d5d0b97a83b3da6db4e10d3e4f5ca35917de4e69654e06fa336c792037bcb93d88314ed6a611aa726ecef537ef544e69876198de2
7
+ data.tar.gz: 98d1cb7545111c8c2c763ee216cf5ac5faf550e73ecb7f26472ffb9e292342e9ef8b993355658eb45fa193a1f42ba99c3db604c73f574b5134c71797a97f5770
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
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
+ ## [1.9.29]
7
+ - #303 API Gateway: Do not generate resource names longer than 62 characters
8
+ - #304 Add skip\_before\_action and skip\_after\_action method callbacks
9
+
6
10
  ## [1.9.28]
7
11
  - #302 improve jets call guesser, do a simple detection at the start
8
12
 
@@ -16,6 +16,10 @@ class Jets::Controller
16
16
  self.before_actions = [[meth, options]] + self.before_actions
17
17
  end
18
18
 
19
+ def skip_before_action(meth)
20
+ self.before_actions = self.before_actions.reject { |el| el.first.to_s == meth.to_s }
21
+ end
22
+
19
23
  alias_method :append_before_action, :before_action
20
24
 
21
25
  def after_action(meth, options={})
@@ -26,6 +30,10 @@ class Jets::Controller
26
30
  self.after_actions = [[meth, options]] + self.after_actions
27
31
  end
28
32
 
33
+ def skip_after_action(meth)
34
+ self.after_actions = self.after_actions.reject { |el| el.first.to_s == meth.to_s }
35
+ end
36
+
29
37
  alias_method :append_after_action, :after_action
30
38
  end
31
39
  end # included
data/lib/jets/resource.rb CHANGED
@@ -21,7 +21,20 @@ class Jets::Resource
21
21
  id = template.keys.first
22
22
  # replace possible {namespace} in the logical id
23
23
  id = replacer.replace_value(id)
24
- Jets::Camelizer.camelize(id)
24
+ id = Jets::Camelizer.camelize(id)
25
+
26
+ Jets::Resource.truncate_id(id)
27
+ end
28
+
29
+ def self.truncate_id(id)
30
+ # Api Gateway resource name has a limit of 64 characters.
31
+ # Yet it throws not found when ID is longer than 62 characters and I don't know why.
32
+ # To keep it safe, let's stick to the 62 characters limit.
33
+ if id.size > 62
34
+ "#{id[0..55]}#{Digest::MD5.hexdigest(id)[0..5]}"
35
+ else
36
+ id
37
+ end
25
38
  end
26
39
 
27
40
  def type
@@ -81,7 +81,7 @@ module Jets::Resource::ApiGateway
81
81
  def resource_id
82
82
  @route.path == '' ?
83
83
  "RootResourceId" :
84
- "#{resource_logical_id.camelize}ApiResource"
84
+ Jets::Resource.truncate_id("#{resource_logical_id.camelize}ApiResource")
85
85
  end
86
86
 
87
87
  # Example: Posts
@@ -28,7 +28,7 @@ module Jets::Resource::ApiGateway
28
28
  if @path == ''
29
29
  "RootResourceId"
30
30
  else
31
- "#{path_logical_id(@path)}ApiResource"
31
+ Jets::Resource.truncate_id "#{path_logical_id(@path)}ApiResource"
32
32
  end
33
33
  end
34
34
 
@@ -41,7 +41,7 @@ module Jets::Resource::ApiGateway
41
41
  if @path.include?('/') # posts/:id or posts/:id/edit
42
42
  parent_path = @path.split('/')[0..-2].join('/')
43
43
  parent_logical_id = path_logical_id(parent_path)
44
- "!Ref #{parent_logical_id}ApiResource"
44
+ "!Ref " + Jets::Resource.truncate_id("#{parent_logical_id}ApiResource")
45
45
  else
46
46
  "!GetAtt #{RestApi.logical_id(@internal)}.RootResourceId"
47
47
  end
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "1.9.28"
2
+ VERSION = "1.9.29"
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: 1.9.28
4
+ version: 1.9.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-08 00:00:00.000000000 Z
11
+ date: 2019-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer