terraform-synthesizer 0.0.15 → 0.0.16

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: a1ef503dbcd7c796cda35e508798623fe1ba26202138df278dc56df6ffcc305a
4
- data.tar.gz: 64b3bbb65508243e2294eb11ab67474e7741c3e2023ef56a64a36fd06a4cb6d9
3
+ metadata.gz: 7e742e74bfa241477d03973992c8791cf8ffe68930b58b4eed82598c084a4e57
4
+ data.tar.gz: d26630d09fc22a704a3935403c83f71e7e420921a329bcd8a623e599ffc8c57b
5
5
  SHA512:
6
- metadata.gz: 4542a100e11a81e55128c86b28849e0b106a38e33bc44a166c965be43290c7e4b27fd4d45985899b603639a708a22e06d82683912052daab3df299b3583a5bad
7
- data.tar.gz: 2458e557e8e0ea60ec7782e4ab027ebe32fb8d8b16f08c8de53b7c35b357dfb952ce39501f96ce5cea3fb317e76639ac0c8a3f2b14c5a80e2ac811f1deed3550
6
+ metadata.gz: c6cf1088cada6405cc839674f0e0a29e6d917359a3e022a79ca65f049e47633d843d3dba6e297b3e66864bdd2827fec3a5a8d1756cb7c906ff629f97bdf0900f
7
+ data.tar.gz: 58c0632dbce69a7cd498b6fc49ab305997bf750ab02defe56aee9fd65d690da81ee441025251591cc0fa09a364507959bfdcaff108e083becd682578689f87b7
@@ -1,3 +1,3 @@
1
1
  module TerraformSynthesizer
2
- VERSION = %(0.0.15).freeze
2
+ VERSION = %(0.0.16).freeze
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require %(abstract-synthesizer)
2
2
 
3
3
  class TerraformSynthesizer < AbstractSynthesizer
4
- KEYS = %i[
4
+ RESOURCE_KEYS = %i[
5
5
  terraform
6
6
  resource
7
7
  variable
@@ -9,28 +9,50 @@ class TerraformSynthesizer < AbstractSynthesizer
9
9
  data
10
10
  ].freeze
11
11
 
12
+ # if there are additional block keys
13
+ # add them here and they should be processed
14
+ # accordingly
15
+ BLOCK_KEYS = %i[locals].freeze
16
+
17
+ ##############################################################################
18
+ # notes:
19
+ #
20
+ # locals are processed as a direct block like
21
+ # locals do
22
+ # key value
23
+ # end
24
+ # while resources are processed as resource like blocks
25
+ # resource :aws_vpc, :virtual_name do
26
+ # key value
27
+ # end
28
+ ##############################################################################
12
29
  def method_missing(method_name, *args, &)
13
- if @in_locals
14
- if args[0].nil?
15
- raise ArgumentError,
16
- %(not assigning anything to this local #{method_name})
17
- end
30
+ BLOCK_KEYS.each do |block_key|
31
+ if @in_block_key
32
+ raise ArgumentError, %(not assigning anything to this #{block_key}) if args[0].nil?
33
+
34
+ @in_block_key = false
35
+ @translation[:template][block_key.to_sym][method_name.to_sym] = args[0]
18
36
 
19
- @in_locals = false
20
- @translation[:template][:locals][method_name.to_sym] = args[0]
21
- elsif method_name.to_s.eql?(%(locals))
22
- @translation = {} if @translation.nil?
23
- @translation[:template] = {} if @translation[:template].nil?
24
- @translation[:template][:locals] = {} if @translation[:template][:locals].nil?
25
- @in_locals = true
26
- yield
27
- else
28
- abstract_method_missing(
29
- method_name.to_sym,
30
- KEYS,
31
- *args,
32
- &
33
- )
37
+ elsif method_name.to_s.eql?(block_key.to_s)
38
+
39
+ @translation = {} if @translation.nil?
40
+ @translation[:template] = {} if @translation[:template].nil?
41
+ if @translation[:template][block_key.to_sym].nil?
42
+ @translation[:template][block_key.to_sym] =
43
+ {}
44
+ end
45
+ @in_block_key = true
46
+
47
+ yield
48
+ else
49
+ abstract_method_missing(
50
+ method_name.to_sym,
51
+ RESOURCE_KEYS,
52
+ *args,
53
+ &
54
+ )
55
+ end
34
56
  end
35
57
  end
36
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraform-synthesizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - drzthslnt@gmail.com