aws-cfn-decompiler 0.5.0 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZWU4ODg1ZTFhZjYyNGYxZjE3ODA0YjNiYjVhZWMyZmRjYTIxODE0Yw==
5
- data.tar.gz: !binary |-
6
- YjUzZGE4NjhhZDQ1Y2UyZGIyN2Q2NjkwYzE0NWYxODc1YTg1YmMyZA==
2
+ SHA1:
3
+ metadata.gz: f180799b3fab6757e8326a52443d9ecf0606663b
4
+ data.tar.gz: c0580cd70f1f96a1e6a92f6f93b4e5f6c85c8eb4
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NDM3ZTBlNzAyYzhiYTRhMGMyYjA3NTUxOTYwMWUxYzc3NDlkN2ZmZTU2ZTQ1
10
- OGU4ZWFkNzljZTJhNmViYjhkZjFmMmRmZTdmOTY4NDM0OGU5OTQ3NTk3MjVj
11
- NjFiZTk5YTMyY2I0YTc3ODZiYTFmYjEwZDZiNmJhYjUzMDU3MWQ=
12
- data.tar.gz: !binary |-
13
- ZGQ4NjFmYjVmZDZlMWUwYjM4ZDM5ODA2NDljOGU1MjlhNjI2YWE2NzM3MDlk
14
- OWM2NzE3ZWZmNTg5MzhlMmNkYzUyZWU3ZDJhODQ3MjVjYzJlNjgzZjU2MzRj
15
- MTVkNWJlNjA3ODFlOWVmYmQzMjlmZjM4ODk3ZDQ4MzdkNzM3OTE=
6
+ metadata.gz: 9707cc9a2f5b7070f30125f631d69a479a342abeba846fb011134883079f730022cc8fd9cc620eb1cb05d11294b47eaede28c902cc8f87bef80b5b6da121b27c
7
+ data.tar.gz: bb86570d78d67a89bb1b74496de78d1f07f969bec5e59b6b31dc65033062d1b91d8710aea71469c0f10f81cd893379a29c6aead221c3497cb1edb136532c65c6
data/Gemfile CHANGED
@@ -2,3 +2,16 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in aws-cfn-decompiler.gemspec
4
4
  gemspec
5
+
6
+ gem 'cloudformation-ruby-dsl', :path => '../cloudformation-ruby-dsl', :group => :development
7
+
8
+ gem 'dldinternet-mixlib-logging', :path => '../dldinternet-mixlib-logging', :group => :development
9
+ gem 'dldinternet-mixlib-cli', :path => '../dldinternet-mixlib-cli', :group => :development
10
+ gem 'aws-cfn-dsl', :path => '../aws-cfn-dsl', :group => :development
11
+ gem 'aws-cfn-decompiler', :path => '../aws-cfn-decompiler', :group => :development
12
+ gem 'aws-cfn-compiler', :path => '../aws-cfn-compiler', :group => :development
13
+ gem 'aws-cfn-yats', :path => '../aws-cfn-yats', :group => :development
14
+ gem 'aws-cfn-stacker', :path => '../aws-cfn-stacker', :group => :development
15
+
16
+ gem 'bundler', "~> 1.6", :group => :development
17
+ gem 'rake', :group => :development
@@ -8,13 +8,71 @@
8
8
  <content url="file://$MODULE_DIR$" />
9
9
  <orderEntry type="jdk" jdkName="RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]" jdkType="RUBY_SDK" />
10
10
  <orderEntry type="sourceFolder" forTests="false" />
11
+ <orderEntry type="module" module-name="aws-cfn-compiler" />
12
+ <orderEntry type="module" module-name="aws-cfn-dsl" />
13
+ <orderEntry type="module-library">
14
+ <library name="aws-cfn-stacker (v[path], /Users/cdelange/Dropbox/DLDInternet/ws/gems-ws/aws-cfn-stacker) [path][gem]">
15
+ <CLASSES>
16
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/bin" />
17
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/lib" />
18
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/pkg" />
19
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/.idea" />
20
+ </CLASSES>
21
+ <JAVADOC />
22
+ <SOURCES>
23
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/bin" />
24
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/lib" />
25
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/pkg" />
26
+ <root url="file://$MODULE_DIR$/../aws-cfn-stacker/.idea" />
27
+ </SOURCES>
28
+ </library>
29
+ </orderEntry>
30
+ <orderEntry type="module" module-name="aws-cfn-yats" />
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-decompiler]) [gem]" level="application" />
12
- <orderEntry type="library" scope="PROVIDED" name="aws-cfn-dsl (v0.0.4, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
13
67
  <orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.2, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
14
- <orderEntry type="library" scope="PROVIDED" name="cloudformation-ruby-dsl (v0.4.3, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
68
+ <orderEntry type="library" scope="PROVIDED" name="colorize (v0.7.3, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
15
69
  <orderEntry type="library" scope="PROVIDED" name="detabulator (v0.1.0, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
70
+ <orderEntry type="library" scope="PROVIDED" name="inifile (v2.0.2, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
16
71
  <orderEntry type="library" scope="PROVIDED" name="json (v1.8.1, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="json_pure (v1.8.1, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
72
+ <orderEntry type="library" scope="PROVIDED" name="little-plugger (v1.1.3, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
73
+ <orderEntry type="library" scope="PROVIDED" name="logging (v1.8.2, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
74
+ <orderEntry type="library" scope="PROVIDED" name="mixlib-cli (v1.5.0, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
75
+ <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.10.1, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
18
76
  <orderEntry type="library" scope="PROVIDED" name="psych (v2.0.5, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
19
77
  <orderEntry type="library" scope="PROVIDED" name="rake (v10.3.2, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
20
78
  <orderEntry type="library" scope="PROVIDED" name="slop (v3.5.0, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
@@ -15,48 +15,57 @@ module Aws
15
15
 
16
16
  specification = {}
17
17
  format = @opts[:format] rescue 'yaml'
18
- @items.each do |section, section_items|
19
- case section
20
- when /Mappings|Parameters|Resources|Outputs/
21
- specification[section] = []
22
- section_items.each do |name,value|
23
- dir = File.join(output_dir,section.to_s)
24
- unless File.directory?(dir)
25
- Dir.mkdir(dir)
18
+ if format.match(%r'^ruby|rb$')
19
+ pprint_cfn_template simplify(@items)
20
+ else
21
+ @items.each do |section, section_items|
22
+ case section
23
+ when /Mappings|Parameters|Resources|Outputs/
24
+ specification[section] = []
25
+ section_items.each do |name,value|
26
+ dir = File.join(output_dir,section.to_s)
27
+ unless File.directory?(dir)
28
+ Dir.mkdir(dir)
29
+ end
30
+ file = "#{name}.#{format}"
31
+ hash = { name => value }
32
+
33
+ save_section(dir, file, format, section, hash)
34
+ specification[section] << name
26
35
  end
27
- file = "#{name}.#{format}"
28
- hash = { name => value }
36
+ when /AWSTemplateFormatVersion|Description/
37
+ specification[section] = section_items
38
+ else
39
+ abort! "Unsupported section '#{section}' in template"
40
+ end
29
41
 
30
- save_section(dir, file, format, section, hash)
31
- specification[section] << name
32
- end
33
- when /AWSTemplateFormatVersion|Description/
34
- specification[section] = section_items
35
- else
36
- raise "ERROR: Unsupported section '#{section}' in template"
37
42
  end
38
43
 
39
- end
40
-
41
- # Save specification
42
- unless @opts[:specification].nil?
43
- dir = File.dirname(@opts[:specification])
44
- dir = output_dir unless dir
45
- save_section(dir, File.basename(@opts[:specification]), format, '', specification, "Specification to #{dir}/")
44
+ # Save specification
45
+ unless @opts[:specification].nil?
46
+ dir = File.dirname(@opts[:specification])
47
+ dir = output_dir unless dir
48
+ save_section(dir, File.basename(@opts[:specification]), format, '', specification, "Specification to #{dir}/")
49
+ end
46
50
  end
47
51
 
48
52
  end
49
53
 
50
54
  def save_section(dir, file, format, section, hash, join='/')
55
+ logStep "Saving section #{hash.keys[0]} to #{section}/#{file} "
51
56
  path = File.join(dir, file)
52
57
 
53
58
  begin
54
59
  # File.delete path if File.exists? path
55
60
  File.open path, File::CREAT|File::TRUNC|File::RDWR, 0644 do |f|
56
61
  case format
57
- when /json/
58
- f.write JSON.pretty_generate(compiled)
59
- when /yaml/
62
+ when /ruby|rb/
63
+ @output.unshift f
64
+ pprint(hash)
65
+ @output.shift
66
+ when /json|js/
67
+ f.write JSON.pretty_generate(hash)
68
+ when /yaml|yml/
60
69
  f.write hash.to_yaml line_width: 1024, indentation: 4, canonical: false
61
70
  else
62
71
  raise "Unsupported format #{format}. Should have noticed this earlier!"
@@ -70,18 +79,9 @@ module Aws
70
79
  end
71
80
  end
72
81
 
73
- def decompile(file=nil)
74
- load file
75
-
76
- puts
77
- puts 'Validating decompiled file...'
78
-
79
- validate(@items)
80
-
81
- end
82
-
83
82
  def load(file=nil)
84
83
  if file
84
+ logStep "Loading #{file}"
85
85
  begin
86
86
  abs = File.absolute_path(File.expand_path(file))
87
87
  unless File.exists?(abs) or @opts[:output].nil?
@@ -92,16 +92,15 @@ module Aws
92
92
  end
93
93
  if File.exists?(abs)
94
94
  case File.extname(File.basename(abs)).downcase
95
- when /json/
96
- template = JSON.parse(File.read(abs))
97
- when /yaml/
98
- template = YAML.load(File.read(abs))
95
+ when /json|js/
96
+ @items = JSON.parse(File.read(abs))
97
+ when /yaml|yml/
98
+ @items = YAML.load(File.read(abs))
99
99
  else
100
- raise "Unsupported file type for specification: #{file}"
100
+ abort! "Unsupported file type for specification: #{file}"
101
101
  end
102
- @items = template
103
102
  else
104
- raise "Unable to open template: #{abs}"
103
+ abort! "Unable to open template: #{abs}"
105
104
  end
106
105
  end
107
106
  end
@@ -12,32 +12,39 @@ module Aws
12
12
  def run
13
13
 
14
14
  @opts = Slop.parse(help: true, strict: true) do
15
+ # command File.basename(__FILE__,'.rb')
15
16
  on :j, :template=, 'The template to decompile', as: String
16
17
  on :o, :output=, 'The directory to output the components to.', as: String
17
- on :f, :format=, 'The output format of the components. [JSON|YAML|Ruby]', as: String, match: %r/yaml|json|ruby/i
18
+ on :f, :format=, 'The output format of the components. [JSON|YAML|Ruby]', as: String, match: %r/ruby|rb|yaml|yml|json|js/i
18
19
  on :s, :specification=, 'The specification file to create.', as: String
20
+ on :n, :functions=, 'Enable function use.', as: String, match: %r/0|1|yes|no|on|off|enable|disable|set|unset|true|false|raw/i
19
21
  end
20
22
 
23
+ @config[:functions] = @opts[:functions].downcase.match %r'^(1|true|on|yes|enable|set)$'
24
+
21
25
  unless @opts[:template]
22
- puts @opts
26
+ @logger.error @opts
23
27
  exit
24
28
  end
25
29
  unless @opts[:output].nil?
26
30
  unless File.directory?(@opts[:output])
27
- puts @opts
31
+ Dir.mkdir(@opts[:output])
32
+ end
33
+ unless File.directory?(@opts[:output])
34
+ @logger.error "Cannot see output directory: #{@opts[:output]}"
35
+ @logger.error @opts.to_s
28
36
  exit
29
37
  end
30
38
  end
31
39
 
32
- decompile @opts[:template]
40
+ load @opts[:template]
41
+
42
+ validate(@items)
33
43
 
34
44
  output_dir = @opts[:output] || Dir.pwd
35
- puts
36
- puts "Writing decompiled parts to #{output_dir}..."
37
45
  save(output_dir)
38
46
 
39
- puts
40
- puts '*** Decompiled Successfully ***'
47
+ @logger.step '*** Decompiled Successfully ***'
41
48
  end
42
49
 
43
50
  protected
@@ -1,7 +1,7 @@
1
1
  module Aws
2
2
  module Cfn
3
3
  module DeCompiler
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,95 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-cfn-decompiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.2
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: awesome_print
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.2'
20
- - - ! '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 1.2.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.2'
30
- - - ! '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.2.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: psych
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ! '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ! '>='
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: json
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ! '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ! '>='
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: slop
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ! '>='
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ! '>='
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: aws-cfn-compiler
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ! '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: 0.5.0
82
- - - ~>
82
+ - - "~>"
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0.5'
85
85
  type: :runtime
86
86
  prerelease: false
87
87
  version_requirements: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - ! '>='
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: 0.5.0
92
- - - ~>
92
+ - - "~>"
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0.5'
95
95
  description: The idea is to extract a big CloudFormation template into a folder structure
@@ -102,9 +102,9 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
- - .gitignore
106
- - .ruby-gemset
107
- - .ruby-version
105
+ - ".gitignore"
106
+ - ".ruby-gemset"
107
+ - ".ruby-version"
108
108
  - Gemfile
109
109
  - LICENSE.txt
110
110
  - README.md
@@ -140,12 +140,12 @@ require_paths:
140
140
  - lib
141
141
  required_ruby_version: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ! '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
- - - ! '>='
148
+ - - ">="
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  requirements: []