aws-cfn-yats 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGM1NDQ3NmIyNWY3NTExMzI4YjUxNzQyNmRiODhhYzdhMjdlZWE2OA==
4
+ Zjc0Y2ZmNWM2NzZkNWIwMjI3NDI2NGFjN2UxNWZhNjA2MDNjMDUyNQ==
5
5
  data.tar.gz: !binary |-
6
- ZWIzNTYwOGRlNTY2MzJmNWM3ZWIyZTI3OWMwN2IwYjk5MTA3YzhjMw==
6
+ ZWQ1Y2MyNTEzMWEyMmQ0MjM2NDBlNmM5NTkwZDVhMWM0NWYwZTVkMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWJhZTU4YzJlYmZiOGI4MDE2YzJiMDhmZWRmZDQxY2M5MTk3YTQzYmNiZjE0
10
- MDM4YWVkMmZmMTI1MWE5NTViZTk3ZTU3YTI5Zjg4N2I4MjQyMGUwYTc1NjZl
11
- YTk1YTE5Zjk2OThiM2E4NmY5NTI1NzFiMmY4YTE2OTVkNDk3N2I=
9
+ MTQyY2EzNGM2ZTE0ODc0NjM4MjE4NmU5OTA4NjQ2NWMzYWUyMTEwMjdkMmQz
10
+ ZWYwZDYyOGRhZmI4NTViMmM1ZGZhZjE4NWFlY2MzMWU4NjUzMjAyODhiMzI0
11
+ YmIwY2RhYjdlZTc0Y2MyYmVjMjQ0ZjFlNDBkMjkwZmY1YjQxMmM=
12
12
  data.tar.gz: !binary |-
13
- YTY2YTAwNGE2MTRjMTllMDkwYzFjNjM0YTgwMjA2MGNmN2I0ZDlkOGUzYzcx
14
- MDUxNjMzYjU2ZWMyM2RlOGY4ZDFmNDA3Zjg0M2I4MGZiNDNjOGZlMjkxZWQ0
15
- YjExMzYzZDgyMDVjYmMxOGZkN2FiY2YxOTZkMjM0MDIzNTU2ZGU=
13
+ NTM5ZTI4YmQ4ODQ4NDA2MWM5Zjc1MDQ3MGZmMDQ3M2Y0NjY3MmE4Y2YxYmIz
14
+ OTUwNTg4YzVmNjY1ODYwMWI4YzdhM2UzZTNlOGQ2ZDQzMGMxNmIyOWQ3ZmU2
15
+ ZGU0MTA1NmI1NzliMmQ0YjYzMDUwZWNmOGNiMTY5OGI3N2JkOTQ=
data/Gemfile CHANGED
@@ -1,3 +1,13 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
4
+
5
+ gem 'cloudformation-ruby-dsl', :path => '../cloudformation-ruby-dsl', :group => :development
6
+
7
+ gem 'dldinternet-mixlib-logging', :path => '../dldinternet-mixlib-logging', :group => :development
8
+ gem 'dldinternet-mixlib-cli', :path => '../dldinternet-mixlib-cli', :group => :development
9
+ gem 'aws-cfn-dsl', :path => '../aws-cfn-dsl', :group => :development
10
+ gem 'aws-cfn-decompiler', :path => '../aws-cfn-decompiler', :group => :development
11
+ gem 'aws-cfn-compiler', :path => '../aws-cfn-compiler', :group => :development
12
+ gem 'aws-cfn-yats', :path => '../aws-cfn-yats', :group => :development
13
+ gem 'aws-cfn-stacker', :path => '../aws-cfn-stacker', :group => :development
@@ -8,15 +8,64 @@
8
8
  <content url="file://$MODULE_DIR$" />
9
9
  <orderEntry type="inheritedJdk" />
10
10
  <orderEntry type="sourceFolder" forTests="false" />
11
+ <orderEntry type="module" module-name="aws-cfn-compiler" />
12
+ <orderEntry type="module" module-name="aws-cfn-decompiler" />
13
+ <orderEntry type="module" module-name="aws-cfn-dsl" />
14
+ <orderEntry type="module-library">
15
+ <library name="aws-cfn-stacker (v[path], /Users/cdelange/Dropbox/DLDInternet/ws/gems-ws/aws-cfn-stacker) [path][gem]">
16
+ <CLASSES>
17
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/bin" />
18
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/lib" />
19
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/pkg" />
20
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/.idea" />
21
+ </CLASSES>
22
+ <JAVADOC />
23
+ <SOURCES>
24
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/bin" />
25
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/lib" />
26
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/pkg" />
27
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/.idea" />
28
+ </SOURCES>
29
+ </library>
30
+ </orderEntry>
31
+ <orderEntry type="module" module-name="cloudformation-ruby-dsl" />
32
+ <orderEntry type="module-library">
33
+ <library name="dldinternet-mixlib-cli (v0.1.0, /Users/cdelange/Dropbox/DLDInternet/ws/gems-ws/dldinternet-mixlib-cli) [path][gem]">
34
+ <CLASSES>
35
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/bin" />
36
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/lib" />
37
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/pkg" />
38
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/.idea" />
39
+ </CLASSES>
40
+ <JAVADOC />
41
+ <SOURCES>
42
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/bin" />
43
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/lib" />
44
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/pkg" />
45
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/.idea" />
46
+ </SOURCES>
47
+ </library>
48
+ </orderEntry>
49
+ <orderEntry type="module-library">
50
+ <library name="dldinternet-mixlib-logging (v0.2.0, /Users/cdelange/Dropbox/DLDInternet/ws/gems-ws/dldinternet-mixlib-logging) [path][gem]">
51
+ <CLASSES>
52
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/bin" />
53
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/lib" />
54
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/pkg" />
55
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/.idea" />
56
+ </CLASSES>
57
+ <JAVADOC />
58
+ <SOURCES>
59
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/bin" />
60
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/lib" />
61
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/pkg" />
62
+ <root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/.idea" />
63
+ </SOURCES>
64
+ </library>
65
+ </orderEntry>
11
66
  <orderEntry type="library" scope="PROVIDED" name="awesome_print (v1.2.0, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
12
- <orderEntry type="library" scope="PROVIDED" name="aws-cfn-compiler (v0.5.0, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
13
- <orderEntry type="library" scope="PROVIDED" name="aws-cfn-decompiler (v0.5.0, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
14
- <orderEntry type="library" scope="PROVIDED" name="aws-cfn-dsl (v0.2.0, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="cloudformation-ruby-dsl (v0.4.3, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
16
67
  <orderEntry type="library" scope="PROVIDED" name="colorize (v0.7.3, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
17
68
  <orderEntry type="library" scope="PROVIDED" name="detabulator (v0.1.0, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="dldinternet-mixlib-cli (v0.1.0, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="dldinternet-mixlib-logging (v0.1.6, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
20
69
  <orderEntry type="library" scope="PROVIDED" name="inifile (v2.0.2, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
21
70
  <orderEntry type="library" scope="PROVIDED" name="json (v1.8.1, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
22
71
  <orderEntry type="library" scope="PROVIDED" name="little-plugger (v1.1.3, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
@@ -7,6 +7,7 @@ end
7
7
 
8
8
  require 'json/pure'
9
9
  require "aws/cfn/yats/version"
10
+ require "aws/cfn/decompiler/base"
10
11
 
11
12
  module Aws
12
13
  module Cfn
@@ -15,21 +16,7 @@ module Aws
15
16
  attr_accessor :json
16
17
  attr_accessor :simple
17
18
 
18
- class Base
19
-
20
- def self.abstract_methods(*args)
21
- args.each do |name|
22
- class_eval(<<-END, __FILE__, __LINE__)
23
- def #{name}(*args)
24
- raise NotImplementedError.new("You must implement #{name}.")
25
- end
26
- END
27
- end
28
- end
29
-
30
- def initialize
31
- end
32
-
19
+ class Base < Aws::Cfn::DeCompiler::Base
33
20
 
34
21
  def transform(template)
35
22
  @template = template
@@ -37,92 +24,7 @@ module Aws
37
24
  @simple = simplify(@json)
38
25
  pprint(@simple)
39
26
  end
40
-
41
- def simplify(val)
42
- if val.is_a?(Hash)
43
- val = Hash[val.map { |k,v| [k, simplify(v)] }]
44
- # if val.length != 1
45
- # val
46
- # else
47
- # k, v = val.entries[0]
48
- # # CloudFormation functions
49
- # case
50
- # when k == 'Fn::Base64'
51
- # FnCall.new 'base64', [v], true
52
- # when k == 'Fn::FindInMap'
53
- # FnCall.new 'find_in_map', v
54
- # when k == 'Fn::GetAtt'
55
- # FnCall.new 'get_att', v
56
- # when k == 'Fn::GetAZs'
57
- # FnCall.new 'get_azs', v != '' ? [v] : []
58
- # when k == 'Fn::Join'
59
- # FnCall.new 'join', [v[0]] + v[1], true
60
- # when k == 'Fn::Select'
61
- # FnCall.new 'select', v
62
- # # when k == 'Ref' && v == 'AWS::Region'
63
- # # FnCall.new 'aws_region', []
64
- # # when k == 'Ref' && v == 'AWS::StackName'
65
- # # FnCall.new 'aws_stack_name', []
66
- # when k == 'Ref'
67
- # FnCall.new 'ref', [v]
68
- # else
69
- # val
70
- # end
71
- # end
72
- elsif val.is_a?(Array)
73
- val.map { |v| simplify(v) }
74
- else
75
- val
76
- end
77
- end
78
-
79
- def pprint(val)
80
- case detect_type(val)
81
- when :template
82
- pprint_cfn_template(val)
83
- when :parameter
84
- pprint_cfn_section 'parameter', 'TODO', val
85
- when :resource
86
- pprint_cfn_resource 'TODO', val
87
- when :parameters
88
- val.each { |k, v| pprint_cfn_section 'parameter', k, v }
89
- when :resources
90
- val.each { |k, v| pprint_cfn_resource k, v }
91
- else
92
- pprint_value(val)
93
- end
94
- end
95
-
96
- protected
97
-
98
- # Attempt to figure out what fragment of the template we have. This is imprecise and can't
99
- # detect Mappings and Outputs sections reliably, so it doesn't attempt to.
100
- def detect_type(val)
101
- if val.is_a?(Hash) && val['AWSTemplateFormatVersion']
102
- :template
103
- elsif val.is_a?(Hash) && /^(String|Number)$/ =~ val['Type']
104
- :parameter
105
- elsif val.is_a?(Hash) && val['Type']
106
- :resource
107
- elsif val.is_a?(Hash) && val.values.all? { |v| detect_type(v) == :parameter }
108
- :parameters
109
- elsif val.is_a?(Hash) && val.values.all? { |v| detect_type(v) == :resource }
110
- :resources
111
- end
112
- end
113
-
114
- # def method_missing(name, *args)
115
- # raise "Abstract base class call to missing method #{name}"
116
- # end
117
-
118
-
119
- private
120
-
121
-
122
27
  end
123
-
124
- Base::abstract_methods :pprint_cfn_template, :pprint_cfn_section, :pprint_cfn_resource, :pprint_value
125
-
126
28
  end
127
29
  end
128
30
  end
@@ -1,7 +1,7 @@
1
1
  module Aws
2
2
  module Cfn
3
3
  module Yats
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.8"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-cfn-yats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christo De Lange
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2014-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-cfn-decompiler