cfn_camelizer 0.2.0 → 0.3.0

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: 0b0cd8e062370249b69133dbaa32cd9eb657979aa9733c02275870716fa5f922
4
- data.tar.gz: fe9c7f16c88669c70e3dfea74a01ae2d3e203446c889b484e2e59f1a3b730165
3
+ metadata.gz: 0765e9ad5840366f4dc60588ef01230d6fd8197d6f8581d8723f0f0c6385e655
4
+ data.tar.gz: 5af541989f281e5946e8393befa56b3a81d50859b7378f96f37ac802265bfb7d
5
5
  SHA512:
6
- metadata.gz: a4808d4fb0c64835a29756ca7e8891bfacdade186f748af9d82c0b78735463946aad18b81591d3dad172f6363a869d3e1cbb1fc1eeca135e54e8b86b815ae292
7
- data.tar.gz: 7162c8cf4be952e8236a876ba7ade1b32be47644b1b58c7ea2ca791482e7dc7c56f2a2c084d8adfeba1777d5ea21353f2c6322b1e97faeef376a62b2e17634e6
6
+ metadata.gz: ac32f48489ea365ec19857a3af978a6e21180a1afd479dcaaec96d18611349a5627137ccf648b89f1a8c14cb5a880d91b9f5a0a77b45808839f207ea352e07a0
7
+ data.tar.gz: b9e45d897be5f2fe349ebe578cdeb662594b1b66f3dc69ad592348f65031c31cc68960f288c47362a5c813bf42c51afd57a9bcf6dde3003fc543053b459522bd
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.3.0]
7
+ - camelizer.yml: scope camelizing rules more finely with resource_keys rule
8
+ - add NotificationTargetARN
9
+ - add AWS::Events::Rule RoleArn
10
+ - add VpcZoneIdentifier
11
+ - add ScalableTarget
12
+
6
13
  ## [0.2.0]
7
14
  - add AWS special key
8
15
 
data/lib/camelizer.yml CHANGED
@@ -1,13 +1,34 @@
1
1
  ---
2
2
  special_keys:
3
3
  Aws: AWS
4
- DbSubnetGroupDescription: DBSubnetGroupDescription
5
- DbSubnetGroupName: DBSubnetGroupName
6
- DeadLetterTargetArn: deadLetterTargetArn
7
- MaxReceiveCount: maxReceiveCount
8
- RoleArn: RoleARN
9
- TemplateUrl: TemplateURL
10
- Ttl: TTL
4
+ # Very fine grain control, since these map rules are scoped to specific resources
5
+ # After the special_keys map for backwards compatibility.
6
+ resource_keys: # specific to resource types
7
+ AWS::ApplicationAutoScaling::ScalableTarget:
8
+ RoleArn: RoleARN
9
+ AWS::AutoScaling::AutoScalingGroup:
10
+ ServiceLinkedRoleArn: ServiceLinkedRoleARN
11
+ TargetGroupArns: TargetGroupARNs
12
+ VpcZoneIdentifier: VPCZoneIdentifier
13
+ AWS::AutoScaling::LifecycleHook:
14
+ NotificationTargetArn: NotificationTargetARN
15
+ RoleArn: RoleARN
16
+ AWS::CloudFormation::Stack:
17
+ NotificationArns: NotificationARNs
18
+ TemplateUrl: TemplateURL
19
+ AWS::Events::Rule:
20
+ RoleARN: RoleArn
21
+ AWS::Route53::RecordSet:
22
+ Ttl: TTL
23
+ AWS::RDS::DBSubnetGroup:
24
+ DbSubnetGroupDescription: DBSubnetGroupDescription
25
+ DbSubnetGroupName: DBSubnetGroupName
26
+ AWS::SQS::Queue:
27
+ DeadLetterTargetArn: deadLetterTargetArn # under RedrivePolicy
28
+ MaxReceiveCount: maxReceiveCount # under RedrivePolicy
29
+ AutoScaling::LaunchConfiguration:
30
+ ClassicLinkVpcId: ClassicLinkVPCId
31
+ ClassicLinkVpcSecurityGroups: ClassicLinkVPCSecurityGroups
11
32
  passthrough_parent_keys:
12
33
  - Fn::Sub # https://amzn.to/2HKwxri
13
34
  - ResponseParameters # API Gateway MethodResponse https://amzn.to/2HKw0Wk
data/lib/cfn_camelizer.rb CHANGED
@@ -9,14 +9,18 @@ class CfnCamelizer
9
9
  class << self
10
10
  extend Memoist
11
11
 
12
- def transform(value, parent_keys=[])
12
+ def transform(value, parent_keys=[], resource_type=nil)
13
13
  case value
14
14
  when Array
15
- value.map { |v| transform(v, parent_keys) }
15
+ value.map { |v| transform(v, parent_keys, resource_type) }
16
16
  when Hash
17
+ if value.keys.include?(:type)
18
+ resource_type ||= value[:type]
19
+ end
20
+
17
21
  initializer = value.map do |k, v|
18
- new_key = camelize_key(k, parent_keys)
19
- [new_key, transform(v, parent_keys+[new_key])]
22
+ new_key = camelize_key(k, parent_keys, resource_type)
23
+ [new_key, transform(v, parent_keys+[new_key], resource_type)]
20
24
  end
21
25
  Hash[initializer]
22
26
  else
@@ -24,7 +28,7 @@ class CfnCamelizer
24
28
  end
25
29
  end
26
30
 
27
- def camelize_key(k, parent_keys=[])
31
+ def camelize_key(k, parent_keys=[], resource_type=nil)
28
32
  k = k.to_s
29
33
 
30
34
  if passthrough?(k, parent_keys)
@@ -35,7 +39,7 @@ class CfnCamelizer
35
39
  # Any keys at 2nd level under EventPattern will be pascalized
36
40
  pascalize(k)
37
41
  else
38
- camelize(k)
42
+ camelize(k, resource_type)
39
43
  end
40
44
  end
41
45
 
@@ -46,11 +50,12 @@ class CfnCamelizer
46
50
  !intersection.empty? || k.include?('-') || k.include?('/')
47
51
  end
48
52
 
49
- def camelize(value)
53
+ def camelize(value, resource_type=nil)
50
54
  return value if value.is_a?(Integer)
51
55
 
52
56
  value = value.to_s.camelize
53
- special_map[value] || value
57
+ v = special_map[value] || value # after the special_keys map
58
+ resource_map(resource_type)[v] || v
54
59
  end
55
60
 
56
61
  def pascalize(value)
@@ -65,6 +70,10 @@ class CfnCamelizer
65
70
  camelizer_yaml["special_keys"]
66
71
  end
67
72
 
73
+ def resource_map(resource_type)
74
+ camelizer_yaml["resource_keys"][resource_type] || {}
75
+ end
76
+
68
77
  def camelizer_yaml
69
78
  # default
70
79
  path = File.expand_path("camelizer.yml", File.dirname(__FILE__))
@@ -1,3 +1,3 @@
1
1
  class CfnCamelizer
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfn_camelizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
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-03-31 00:00:00.000000000 Z
11
+ date: 2019-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  - !ruby/object:Gem::Version
135
135
  version: '0'
136
136
  requirements: []
137
- rubygems_version: 3.0.2
137
+ rubygems_version: 3.0.3
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: Cfn Camelizer