cfndsl 0.16.2 → 0.16.3

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: ada6bc0f4f3501974e843197f7566aefa9568735b87a4bf666a1d28e7d4585a1
4
- data.tar.gz: c493f6da406cee7b39ad37d8baa27fdb36eedcb604fa2090fbfe4e6dd4724112
3
+ metadata.gz: 1dda569f61cd962d5edcf67c2732fc4ddd80259b21e3bd5858fe0a1d1065d51e
4
+ data.tar.gz: bf43293eef2e64331159bf403c8b9d13f5fb2bca54821b82aaae7b35770e97aa
5
5
  SHA512:
6
- metadata.gz: 49303f6b20c5aa260473bc631cc661a0ea0552df6e2232cdedca52cb5e77ff1cf66906b080ff6ee94f90ada4a1bcdf3ea0dc7ca56b9c5d05bf8f6f271038bd60
7
- data.tar.gz: de6d8e43c775700c64f56d70a5473ea0d05a6a3f715f027dcba4ff6f932ccb4adb6d80d93d3da9abdfffe57bcc3bd54f19a49196b31047d02a9028700584a734
6
+ metadata.gz: 79b518eff156a5fabf5d2035a63299fca23c05dcafe48781f86c0896b38c14e0de8690508be9405599bb74115b427dac88b965660fcf7dee155f5c4f49f493eb
7
+ data.tar.gz: 5655ab233f107f9ebed98ab42cd88d566236acad019bd004eae8c5a086b688d63c79bfe0ff7ffc3a405cae42c0345d3f36c474a6ee26dcda5d3a60292b25b8f0
@@ -1,7 +1,20 @@
1
1
  # Change Log
2
2
 
3
- ## [0.16.2](https://github.com/cfndsl/cfndsl/tree/0.16.2) (2017-12-08)
4
- [Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.16.1...0.16.2)
3
+ ## [0.16.3](https://github.com/cfndsl/cfndsl/tree/0.16.3) (2018-03-20)
4
+ [Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.16.2...0.16.3)
5
+
6
+ **Closed issues:**
7
+
8
+ - Schedule Event Rule creates an invalid JSON on FnGetAtt Arn. [\#344](https://github.com/cfndsl/cfndsl/issues/344)
9
+
10
+ **Merged pull requests:**
11
+
12
+ - add Fn::Cidr [\#364](https://github.com/cfndsl/cfndsl/pull/364) ([gergnz](https://github.com/gergnz))
13
+ - fixes for rubocop [\#363](https://github.com/cfndsl/cfndsl/pull/363) ([gergnz](https://github.com/gergnz))
14
+ - 0.x changes to 1.0.0.pre [\#361](https://github.com/cfndsl/cfndsl/pull/361) ([gergnz](https://github.com/gergnz))
15
+
16
+ ## [v0.16.2](https://github.com/cfndsl/cfndsl/tree/v0.16.2) (2017-12-07)
17
+ [Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.16.1...v0.16.2)
5
18
 
6
19
  **Closed issues:**
7
20
 
data/Rakefile CHANGED
@@ -35,9 +35,7 @@ task :bump, :type do |_, args|
35
35
 
36
36
  raise unless types.include?(type)
37
37
 
38
- if `git rev-parse --abbrev-ref HEAD`.strip != 'master'
39
- raise "Looks like you're trying to create a release in a branch, you can only create one in 'master'"
40
- end
38
+ raise "Looks like you're trying to create a release in a branch, you can only create one in 'master'" if `git rev-parse --abbrev-ref HEAD`.strip != 'master'
41
39
 
42
40
  version_segments = CfnDsl::VERSION.split('.').map(&:to_i)
43
41
 
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'cfndsl/version'
4
4
 
@@ -27,16 +27,16 @@ module CfnDsl
27
27
  @parameters = self.class.defaults.clone
28
28
  end
29
29
 
30
- def set_param(k, v)
31
- parameters[k.to_sym] = v
30
+ def set_param(key, val)
31
+ parameters[key.to_sym] = val
32
32
  end
33
33
 
34
- def merge_param(x)
35
- parameters.deep_merge!(x)
34
+ def merge_param(xray)
35
+ parameters.deep_merge!(xray)
36
36
  end
37
37
 
38
- def get_param(k)
39
- parameters[k.to_sym]
38
+ def get_param(key)
39
+ parameters[key.to_sym]
40
40
  end
41
41
  alias [] get_param
42
42
 
@@ -5,8 +5,8 @@ module CfnDsl
5
5
  @value
6
6
  end
7
7
 
8
- def to_json(*a)
9
- as_json.to_json(*a)
8
+ def to_json(*args)
9
+ as_json.to_json(*args)
10
10
  end
11
11
  end
12
12
  end
@@ -43,9 +43,7 @@ module CfnDsl
43
43
 
44
44
  # Equivalent to the CloudFormation template built in function Fn::And
45
45
  def FnAnd(array)
46
- if !array || array.count < 2 || array.count > 10
47
- raise 'The array passed to Fn::And must have at least 2 elements and no more than 10'
48
- end
46
+ raise 'The array passed to Fn::And must have at least 2 elements and no more than 10' if !array || array.count < 2 || array.count > 10
49
47
  Fn.new('And', array)
50
48
  end
51
49
 
@@ -70,9 +68,7 @@ module CfnDsl
70
68
 
71
69
  # Equivalent to the CloudFormation template built in function Fn::Or
72
70
  def FnOr(array)
73
- if !array || array.count < 2 || array.count > 10
74
- raise 'The array passed to Fn::Or must have at least 2 elements and no more than 10'
75
- end
71
+ raise 'The array passed to Fn::Or must have at least 2 elements and no more than 10' if !array || array.count < 2 || array.count > 10
76
72
  Fn.new('Or', array)
77
73
  end
78
74
 
@@ -145,6 +141,11 @@ module CfnDsl
145
141
  end
146
142
  Fn.new('Join', ['', array])
147
143
  end
144
+
145
+ # Equivalent to the CloudFormation template built in function Fn::Cidr
146
+ def FnCidr(ipblock, count, sizemask)
147
+ Fn.new('Cidr', [ipblock, count, sizemask])
148
+ end
148
149
  # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
149
150
  end
150
151
 
@@ -187,8 +188,8 @@ module CfnDsl
187
188
  hash
188
189
  end
189
190
 
190
- def to_json(*a)
191
- as_json.to_json(*a)
191
+ def to_json(*args)
192
+ as_json.to_json(*args)
192
193
  end
193
194
 
194
195
  def ref_children
@@ -214,8 +215,8 @@ module CfnDsl
214
215
  hash
215
216
  end
216
217
 
217
- def to_json(*a)
218
- as_json.to_json(*a)
218
+ def to_json(*args)
219
+ as_json.to_json(*args)
219
220
  end
220
221
 
221
222
  def references
@@ -11,7 +11,7 @@ module CfnDsl
11
11
  dsl_attr_setter :AWSTemplateFormatVersion, :Description, :Metadata, :Transform
12
12
  dsl_content_object :Condition, :Parameter, :Output, :Resource, :Mapping
13
13
 
14
- GlobalRefs = {
14
+ GLOBAL_REFS = {
15
15
  'AWS::NotificationARNs' => 1,
16
16
  'AWS::Region' => 1,
17
17
  'AWS::StackId' => 1,
@@ -117,13 +117,11 @@ module CfnDsl
117
117
  ref = ref.to_s
118
118
  origin = origin.to_s if origin
119
119
 
120
- return true if GlobalRefs.key?(ref)
120
+ return true if GLOBAL_REFS.key?(ref)
121
121
 
122
122
  return true if @Parameters && @Parameters.key?(ref)
123
123
 
124
- if @Resources.key?(ref)
125
- return !origin || !@_resource_refs || !@_resource_refs[ref] || !@_resource_refs[ref].key?(origin)
126
- end
124
+ return !origin || !@_resource_refs || !@_resource_refs[ref] || !@_resource_refs[ref].key?(origin) if @Resources.key?(ref)
127
125
 
128
126
  false
129
127
  end
@@ -43,6 +43,7 @@ module CfnDsl
43
43
  }
44
44
  }
45
45
  end
46
+ # rubocop:enable Metrics/MethodLength
46
47
 
47
48
  # Missing/malformed types from the resource specification
48
49
  def self.types
@@ -2,7 +2,7 @@ module CfnDsl
2
2
  # Helper module for bridging the gap between a static types file included in the repo
3
3
  # and dynamically generating the types directly from the AWS specification
4
4
  module Specification
5
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity
5
+ # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
6
6
  def self.extract_resources(spec)
7
7
  spec.each_with_object({}) do |(resource_name, resource_info), resources|
8
8
  properties = resource_info['Properties'].each_with_object({}) do |(property_name, property_info), extracted|
@@ -36,7 +36,9 @@ module CfnDsl
36
36
  resources
37
37
  end
38
38
  end
39
+ # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity
39
40
 
41
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity
40
42
  def self.extract_types(spec)
41
43
  primitive_types = {
42
44
  'String' => 'String',
@@ -78,10 +80,11 @@ module CfnDsl
78
80
  types
79
81
  end
80
82
  end
83
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity
81
84
 
82
85
  def self.determine_spec_file
83
86
  return CfnDsl.specification_file if File.exist? CfnDsl.specification_file
84
- File.expand_path('../aws/resource_specification.json', __FILE__)
87
+ File.expand_path('aws/resource_specification.json', __dir__)
85
88
  end
86
89
 
87
90
  def self.extract_from_resource_spec!
@@ -1,3 +1,3 @@
1
1
  module CfnDsl
2
- VERSION = '0.16.2'.freeze
2
+ VERSION = '0.16.3'.freeze
3
3
  end
@@ -146,9 +146,7 @@ module DeepMerge
146
146
  if array_split_char
147
147
  puts "#{di} split/join on source: #{source.inspect}" if merge_debug
148
148
  source = source.join(array_split_char).split(array_split_char)
149
- if dest.is_a?(Array)
150
- dest = dest.join(array_split_char).split(array_split_char)
151
- end
149
+ dest = dest.join(array_split_char).split(array_split_char) if dest.is_a?(Array)
152
150
  end
153
151
  # if there's a naked knockout_prefix in source, that means we are to truncate dest
154
152
  if knockout_prefix && source.index(knockout_prefix)
@@ -242,3 +240,5 @@ module DeepMerge
242
240
  obj
243
241
  end
244
242
  end
243
+ # rubocop:enable Metrics/AbcSize, Metrics/BlockNesting, Metrics/CyclomaticComplexity, Metrics/MethodLength
244
+ # rubocop:enable Metrics/ModuleLength, Metrics/PerceivedComplexity, Style/IfInsideElse, Style/Semicolon
@@ -248,5 +248,12 @@ describe CfnDsl::CloudFormationTemplate do
248
248
  expect(func.to_json).to eq('{"Fn::Join":["",["123",{"Ref":"Test"},"456"]]}')
249
249
  end
250
250
  end
251
+
252
+ context 'FnCidr', 'Array' do
253
+ it 'formats correctly' do
254
+ func = subject.FnCidr('10.0.0.0', '256', '8')
255
+ expect(func.to_json).to eq('{"Fn::Cidr":["10.0.0.0","256","8"]}')
256
+ end
257
+ end
251
258
  end
252
259
  end
@@ -10,12 +10,12 @@ if ENV['CFNDSL_COV']
10
10
  end
11
11
 
12
12
  require 'cfndsl/globals'
13
- CfnDsl.specification_file File.expand_path('../../lib/cfndsl/aws/resource_specification.json', __FILE__)
13
+ CfnDsl.specification_file File.expand_path('../lib/cfndsl/aws/resource_specification.json', __dir__)
14
14
  # use local fixture for tests
15
15
  require 'cfndsl'
16
16
  require 'cfnlego'
17
17
 
18
- bindir = File.expand_path('../../bin', __FILE__)
18
+ bindir = File.expand_path('../bin', __dir__)
19
19
  ENV['PATH'] = [ENV['PATH'], bindir].join(':')
20
20
 
21
- Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
21
+ Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f }
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  # This is a somewhat temporary test class to compare functionality
4
4
  # between the AWS, OS and new ways of defining types
5
5
  RSpec.describe 'Type Definitions' do
6
- aws_spec = YAML.load_file File.expand_path('../../lib/cfndsl/aws/types.yaml', __FILE__)
7
- os_spec = YAML.load_file File.expand_path('../../lib/cfndsl/os/types.yaml', __FILE__)
6
+ aws_spec = YAML.load_file File.expand_path('../lib/cfndsl/aws/types.yaml', __dir__)
7
+ os_spec = YAML.load_file File.expand_path('../lib/cfndsl/os/types.yaml', __dir__)
8
8
  new_spec = CfnDsl::Specification.extract_from_resource_spec!
9
9
 
10
10
  { 'AWS' => aws_spec, 'OS' => os_spec, 'New' => new_spec }.each_pair do |cloud, specdef|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfndsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.2
4
+ version: 0.16.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-12-07 00:00:00.000000000 Z
14
+ date: 2018-03-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  version: '0'
151
151
  requirements: []
152
152
  rubyforge_project:
153
- rubygems_version: 2.7.3
153
+ rubygems_version: 2.7.6
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: AWS Cloudformation DSL