convection 0.3.3.pre.beta.1 → 0.4.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
  SHA1:
3
- metadata.gz: 92bb70d18fb3687340fc65242ff82a60e85b8fd0
4
- data.tar.gz: 8f337a4df378596d37ebac562f5f8934c55a8342
3
+ metadata.gz: 52f9ff70289c904424ca0729efbb738275ae4ac9
4
+ data.tar.gz: c1a29763fc7d8d3bb533391070e8d8afa90a6a5c
5
5
  SHA512:
6
- metadata.gz: c75506899cc2c95d0f43c47d16a69d01860211ab7181120f5a986821815e7d6241b8a5e08629fa12d593272923b731408dd782e69b7627bbdb571bd7c8d19cd9
7
- data.tar.gz: 0b7dc45590327bd36dc8468342dd146a58fb12ca024f4bcf316c0d0b649dcbf18ceefada272c86b90c3e971a961c4a85dd219225ca0aba65542a494343012a75
6
+ metadata.gz: 192a854ef9284ce12e6d4ad993745fb95c57549ffc1271c96c016f601863ff814a735b2062435d6b89814949665a30ef833c02103d5c466c30a5df26c5af5077
7
+ data.tar.gz: 5c7f9be96c5649c0833f2e7d059fc08497377fd8d26ea7477ff98fdd5a21432ee68e58ae4e5685cbc30a34e2af29de25c02b65d9d3da9622a715d32e4d5c7c75
@@ -254,7 +254,7 @@ module Convection
254
254
  # template has any changes compared to the current template (in
255
255
  # CloudFormation).
256
256
  def resource_changes?
257
- ours = { 'Resources' => @template.all_resources.map(&:render) }
257
+ ours = { 'Resources' => @template.resources.map(&:render) }
258
258
  thiers = { 'Resources' => @current_template['Resources'] }
259
259
 
260
260
  ours.diff(thiers).any?
@@ -24,12 +24,6 @@ module Convection
24
24
  resources[rname] = resource
25
25
  end
26
26
  end
27
-
28
- def attach_resource_collection(name, klass)
29
- define_method(name) do |rname, &block|
30
- resource_collections[rname] = klass.new(rname, self, &block)
31
- end
32
- end
33
27
  end
34
28
  end
35
29
 
@@ -193,7 +187,6 @@ module Convection
193
187
  attr_reader :parameters
194
188
  attr_reader :mappings
195
189
  attr_reader :conditions
196
- attr_reader :resource_collections
197
190
  attr_reader :resources
198
191
  attr_reader :outputs
199
192
 
@@ -214,7 +207,6 @@ module Convection
214
207
  @mappings = Collection.new
215
208
  @conditions = Collection.new
216
209
  @resources = Collection.new
217
- @resource_collections = Collection.new
218
210
  @outputs = Collection.new
219
211
  @metadata = Collection.new
220
212
  end
@@ -225,11 +217,6 @@ module Convection
225
217
 
226
218
  def execute
227
219
  instance_exec(&@definition)
228
-
229
- resource_collections.each do |_, group|
230
- group.run_definition
231
- group.execute
232
- end
233
220
  end
234
221
 
235
222
  def render(stack_ = nil)
@@ -244,18 +231,12 @@ module Convection
244
231
  'Parameters' => parameters.map(&:render),
245
232
  'Mappings' => mappings.map(&:render),
246
233
  'Conditions' => conditions.map(&:render),
247
- 'Resources' => all_resources.map(&:render),
234
+ 'Resources' => resources.map(&:render),
248
235
  'Outputs' => outputs.map(&:render),
249
236
  'Metadata' => metadata.map(&:render)
250
237
  }
251
238
  end
252
239
 
253
- def all_resources
254
- resource_collections.reduce(resources) do |result, (_name, resource_collection)|
255
- result.merge(resource_collection.resources)
256
- end
257
- end
258
-
259
240
  def diff(other, stack_ = nil)
260
241
  render(stack_).diff(other).map { |diff| Diff.new(diff[0], *diff[1]) }
261
242
  end
@@ -372,6 +353,5 @@ require_relative 'template/condition'
372
353
  require_relative 'template/resource'
373
354
  require_relative 'template/resource_property'
374
355
  require_relative 'template/resource_attribute'
375
- require_relative 'template/resource_collection'
376
356
  require_relative 'template/output'
377
357
  require_relative 'template/metadata'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3.pre.beta.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Manero
@@ -203,7 +203,6 @@ files:
203
203
  - lib/convection/model/template/resource/aws_sqs_queue_policy.rb
204
204
  - lib/convection/model/template/resource_attribute.rb
205
205
  - lib/convection/model/template/resource_attribute/update_policy.rb
206
- - lib/convection/model/template/resource_collection.rb
207
206
  - lib/convection/model/template/resource_property.rb
208
207
  - lib/convection/model/template/resource_property/aws_cloudfront_cachebehavior.rb
209
208
  - lib/convection/model/template/resource_property/aws_cloudfront_customerrorresponse.rb
@@ -253,7 +252,6 @@ files:
253
252
  - spec/convection/model/template/resource/rds_security_groups_spec.rb
254
253
  - spec/convection/model/template/resource/vpc_endpoints_spec.rb
255
254
  - spec/convection/model/template/resource_attribute/update_policies_spec.rb
256
- - spec/convection/model/template/resource_collection_spec.rb
257
255
  - spec/convection/model/template/template_spec.rb
258
256
  - spec/convection/model/template/validate_bytesize_spec.rb
259
257
  - spec/convection/model/template/validate_description_spec.rb
@@ -281,12 +279,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
279
  version: '0'
282
280
  required_rubygems_version: !ruby/object:Gem::Requirement
283
281
  requirements:
284
- - - ">"
282
+ - - ">="
285
283
  - !ruby/object:Gem::Version
286
- version: 1.3.1
284
+ version: '0'
287
285
  requirements: []
288
286
  rubyforge_project:
289
- rubygems_version: 2.4.8
287
+ rubygems_version: 2.4.3
290
288
  signing_key:
291
289
  specification_version: 4
292
290
  summary: A fully generic, modular DSL for AWS CloudFormation
@@ -317,7 +315,6 @@ test_files:
317
315
  - spec/convection/model/template/resource/rds_security_groups_spec.rb
318
316
  - spec/convection/model/template/resource/vpc_endpoints_spec.rb
319
317
  - spec/convection/model/template/resource_attribute/update_policies_spec.rb
320
- - spec/convection/model/template/resource_collection_spec.rb
321
318
  - spec/convection/model/template/template_spec.rb
322
319
  - spec/convection/model/template/validate_bytesize_spec.rb
323
320
  - spec/convection/model/template/validate_description_spec.rb
@@ -1,48 +0,0 @@
1
- require 'forwardable'
2
- require_relative './resource'
3
- require_relative '../mixin/conditional'
4
-
5
- module Convection
6
- module Model
7
- class Template
8
- # A collection of different {Convection::Model::Template::Resource}s.
9
- class ResourceCollection
10
- extend Forwardable
11
- include DSL::Helpers
12
- include DSL::Template::Resource
13
- include Mixin::Conditional
14
-
15
- attr_reader :name
16
- attr_reader :parent
17
- attr_reader :template
18
-
19
- def_delegator :@template, :stack
20
-
21
- class << self
22
- def attach_to_dsl(dsl_name)
23
- DSL::Template::Resource.attach_resource_collection(dsl_name, self)
24
- end
25
- end
26
-
27
- def initialize(name, parent, &definition)
28
- @definition = definition
29
- @name = name
30
- @parent = parent
31
- @template = parent.template
32
- end
33
-
34
- # @note This method is in place to be overriden by subclasses.
35
- def execute
36
- end
37
-
38
- def run_definition
39
- instance_exec(&@definition) if @definition
40
- end
41
-
42
- def resources
43
- @resources ||= Convection::Model::Collection.new
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class Convection::Model::Template
4
- describe ResourceCollection do
5
- class WebService < Convection::Model::Template::ResourceCollection
6
- attach_to_dsl(:web_service)
7
-
8
- attribute :use_elastic_load_balancing
9
-
10
- def execute
11
- web_service = self # Expose this instance to nested template methods.
12
-
13
- ec2_instance "#{name}WebService"
14
-
15
- elb "#{name}LoadBalancer" do
16
- tag 'Description', "Load balancer for the #{web_service.name} web service."
17
- end if use_elastic_load_balancing
18
- end
19
- end
20
-
21
- let(:use_elb_value) { nil }
22
- let(:template) do
23
- outer_scope = self
24
- Convection.template do
25
- description 'ResourceCollection Test Template'
26
-
27
- # A lone resource for testing merging of resources and nested resources.
28
- ec2_instance 'LoneResource1'
29
-
30
- web_service 'ExampleDotOrg' do
31
- use_elastic_load_balancing outer_scope.use_elb_value
32
- end
33
- end
34
- end
35
-
36
- subject do
37
- template_json
38
- .fetch('Resources')
39
- end
40
-
41
- context 'when the use_elastic_load_balancing attribute is set' do
42
- let(:use_elb_value) { true }
43
-
44
- it { is_expected.to have_key('LoneResource1') }
45
- it { is_expected.to have_key('ExampleDotOrgWebService') }
46
- it { is_expected.to have_key('ExampleDotOrgLoadBalancer') }
47
- end
48
-
49
- context 'when the use_elastic_load_balancing attribute is not set' do
50
- let(:use_elb_value) { false }
51
-
52
- it { is_expected.to have_key('LoneResource1') }
53
- it { is_expected.to have_key('ExampleDotOrgWebService') }
54
- it { is_expected.to_not have_key('ExampleDotOrgLoadBalancer') }
55
- end
56
-
57
- private
58
-
59
- def template_json
60
- JSON.parse(template.to_json)
61
- end
62
- end
63
- end