terraform-synthesizer 0.0.11 → 0.0.12

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: f90f5699ff8c7f745a0b7477e950e7dd00182d4760f04f08ebed17d65c04a9f3
4
- data.tar.gz: ce554fffa6127e250282a40982055a402d176817664e980af54cc48d44ed18f6
3
+ metadata.gz: 2b1ed3d06b7b6df3a70385de351fd7da73acfa35827c1b7bb9b5ed9acbe61172
4
+ data.tar.gz: deae55a2e30c123e3fe65107f3ba29d2a510ce9b79eabb36405017001e0cc187
5
5
  SHA512:
6
- metadata.gz: 9e9403c96c0716572715d5c0848a2b8b0b59f2588c5beb98d7d7589fee4d9e20c0b88be3e82d28762cda98a433f5df4d5d9a351038857fb84618f092f79258dd
7
- data.tar.gz: af001d8ce851814ce1b4f264da2e9439c6972aac0ffab45f3b13441f7246bafa329817bfd13dbac94bed9eeb8c4de5598428eef4982bb55b153a7dda510832c5
6
+ metadata.gz: e638fe8b874bcd89f9d939b7b05a47bbde45e8c9b0bf046d7a2735699a6e77c3c8d91a83b8d81b7dea10ef99eb74ea441d0427f5597542408a1edfea56087321
7
+ data.tar.gz: 3bca73ea2a6c12b0763b464751e72fe48509b659074e42c3b15629229b46000139aa3531a289f183a743fb825e09e0e30e9ced6843fb88a9a10c92fd8c894150
@@ -1,3 +1,3 @@
1
1
  module TerraformSynthesizer
2
- VERSION = %(0.0.11).freeze
2
+ VERSION = %(0.0.12).freeze
3
3
  end
@@ -1,35 +1,38 @@
1
1
  require %(abstract-synthesizer)
2
2
 
3
3
  class TerraformSynthesizer < AbstractSynthesizer
4
- def method_missing(method_name, ...)
4
+ KEYS = %i[
5
+ terraform
6
+ resource
7
+ variable
8
+ output
9
+ data
10
+ ].freeze
11
+
12
+ def method_missing(method_name, *args, &)
5
13
  if @in_locals
6
14
  if args[0].nil?
7
15
  raise ArgumentError,
8
16
  %(not assigning anything to this local #{method_name})
9
17
  end
10
18
 
11
- @translation[:template][:locals][method_name.to_sym] = args[0]
12
19
  @in_locals = false
13
- end
14
- if method_name.to_s.eql?(%(locals))
20
+ @translation[:template][:locals].merge!(
21
+ { method_name.to_sym => args[0] }
22
+ )
23
+ elsif method_name.to_s.eql?(%(locals))
24
+
15
25
  @translation = {} if @translation.nil?
16
26
  @translation[:template] = {} if @translation[:template].nil?
17
27
  @translation[:template][:locals] = {} if @translation[:template][:locals].nil?
18
- @translation[:template][:locals].merge!(yield) if block_given?
19
28
  @in_locals = true
29
+ yield
20
30
  else
21
- return {} if @in_locals
22
-
23
31
  abstract_method_missing(
24
- method_name,
25
- %i[
26
- terraform
27
- resource
28
- variable
29
- output
30
- data
31
- ],
32
- ...
32
+ method_name.to_sym,
33
+ KEYS,
34
+ *args,
35
+ &
33
36
  )
34
37
  end
35
38
  end
@@ -0,0 +1,45 @@
1
+ require %(terraform-synthesizer)
2
+
3
+ describe TerraformSynthesizer do
4
+ context %(main) do
5
+ let(:synth) do
6
+ described_class.new
7
+ end
8
+
9
+ it %(should compile small declaration and be hash) do
10
+ synth.synthesize do
11
+ resource :aws_vpc, :thing do
12
+ cidr_block %(10.0.0.0/16)
13
+ end
14
+ locals do
15
+ special_var %(special_value)
16
+ end
17
+ end
18
+ expect(synth.synthesis).to be_kind_of(Hash)
19
+ end
20
+
21
+ it %(should contain locals) do
22
+ synth.synthesize do
23
+ resource :aws_vpc, :thing do
24
+ cidr_block %(10.0.0.0/16)
25
+ end
26
+ locals do
27
+ special_var %(special_value)
28
+ end
29
+ end
30
+ expect(synth.synthesis[:locals][:special_var]).to be_kind_of(String)
31
+ end
32
+
33
+ it %(should contain resources) do
34
+ synth.synthesize do
35
+ resource :aws_vpc, :thing do
36
+ cidr_block %(10.0.0.0/16)
37
+ end
38
+ locals do
39
+ special_var %(special_value)
40
+ end
41
+ end
42
+ expect(synth.synthesis[:resource][:aws_vpc][:thing]).to be_kind_of(Hash)
43
+ end
44
+ end
45
+ 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.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - drzthslnt@gmail.com
@@ -45,6 +45,7 @@ files:
45
45
  - gemset.nix
46
46
  - lib/terraform-synthesizer.rb
47
47
  - lib/terraform-synthesizer/version.rb
48
+ - spec/terraform_spec.rb
48
49
  - terraform-synthesizer.gemspec
49
50
  homepage: https://github.com/drzln/terraform-synthesizer
50
51
  licenses: