aws-cfn-decompiler 0.0.3 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/aws-cfn-decompiler.gemspec +1 -1
- data/aws-cfn-decompiler.iml +1 -1
- data/lib/aws/cfn/decompiler.rb +50 -34
- data/lib/aws/cfn/decompiler/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56583dbaf79a17fd28f8f9ca367e4140cb92e32f
|
4
|
+
data.tar.gz: e07d430c72fb933e813cad544a9ea0a6b028e2f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caceeb015088514df93392d67139d8341dbbde5b9fd306dabf82a5a0cf28817b5e523156cb74b861396290feaec4dfe9dc392111c91b0e0592ffbd0997ef994c
|
7
|
+
data.tar.gz: d6cdf66d58e042c2e4c4abce922a5f78489ded3f1fbf9d816d1704a68b75ff1901e0fda80f767de760a8292baf105aef40cb33f7d8d762c3ffe4fada8d3c90c4
|
data/aws-cfn-decompiler.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency "psych"
|
24
24
|
spec.add_dependency "json"
|
25
25
|
# spec.add_dependency "yajl-ruby"
|
26
|
-
spec.add_dependency 'aws-cfn-compiler', '>= 0.1
|
26
|
+
spec.add_dependency 'aws-cfn-compiler', '>= 0.2.1', '~> 0.2'
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler', "~> 1.6"
|
29
29
|
spec.add_development_dependency 'rake'
|
data/aws-cfn-decompiler.iml
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
<orderEntry type="jdk" jdkName="RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]" jdkType="RUBY_SDK" />
|
21
21
|
<orderEntry type="sourceFolder" forTests="false" />
|
22
22
|
<orderEntry type="library" scope="PROVIDED" name="awesome_print (v1.2.0, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
|
23
|
-
<orderEntry type="library" scope="PROVIDED" name="aws-cfn-compiler (v0.1
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="aws-cfn-compiler (v0.2.1, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
|
24
24
|
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.2, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
|
25
25
|
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.1, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
|
26
26
|
<orderEntry type="library" scope="PROVIDED" name="psych (v2.0.5, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
|
data/lib/aws/cfn/decompiler.rb
CHANGED
@@ -50,40 +50,61 @@ module Aws
|
|
50
50
|
|
51
51
|
def save(output_dir)
|
52
52
|
|
53
|
+
specification = {}
|
53
54
|
format = @opts[:format] rescue 'yaml'
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
path = File.join(dir,file)
|
63
|
-
|
64
|
-
hash = { name => value }
|
65
|
-
|
66
|
-
begin
|
67
|
-
File.delete path if File.exists? path
|
68
|
-
File.open path, 'w' do |f|
|
69
|
-
case format
|
70
|
-
when /json/
|
71
|
-
f.write JSON.pretty_generate(compiled)
|
72
|
-
when /yaml/
|
73
|
-
f.write hash.to_yaml line_width: 1024, indentation: 4, canonical: false
|
74
|
-
else
|
75
|
-
raise "Unsupported format #{format}. Should have noticed this earlier!"
|
55
|
+
@items.each do |section, section_items|
|
56
|
+
case section
|
57
|
+
when /Mappings|Parameters|Resources|Outputs/
|
58
|
+
specification[section] = []
|
59
|
+
section_items.each do |name,value|
|
60
|
+
dir = File.join(output_dir,section.to_s)
|
61
|
+
unless File.directory?(dir)
|
62
|
+
Dir.mkdir(dir)
|
76
63
|
end
|
77
|
-
|
64
|
+
file = "#{name}.#{format}"
|
65
|
+
hash = { name => value }
|
66
|
+
|
67
|
+
save_section(dir, file, format, section, hash)
|
68
|
+
specification[section] << name
|
78
69
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
70
|
+
when /AWSTemplateFormatVersion|Description/
|
71
|
+
specification[section] = section_items
|
72
|
+
else
|
73
|
+
raise "ERROR: Unsupported section '#{section}' in template"
|
84
74
|
end
|
85
75
|
|
86
76
|
end
|
77
|
+
|
78
|
+
# Save specification
|
79
|
+
unless @opts[:specification].nil?
|
80
|
+
dir = File.dirname(@opts[:specification])
|
81
|
+
dir = output_dir unless dir
|
82
|
+
save_section(dir, File.basename(@opts[:specification]), format, '', specification, "Specification to #{dir}/")
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
def save_section(dir, file, format, section, hash, join='/')
|
88
|
+
path = File.join(dir, file)
|
89
|
+
|
90
|
+
begin
|
91
|
+
# File.delete path if File.exists? path
|
92
|
+
File.open path, File::CREAT|File::TRUNC|File::RDWR, 0644 do |f|
|
93
|
+
case format
|
94
|
+
when /json/
|
95
|
+
f.write JSON.pretty_generate(compiled)
|
96
|
+
when /yaml/
|
97
|
+
f.write hash.to_yaml line_width: 1024, indentation: 4, canonical: false
|
98
|
+
else
|
99
|
+
raise "Unsupported format #{format}. Should have noticed this earlier!"
|
100
|
+
end
|
101
|
+
f.close
|
102
|
+
end
|
103
|
+
puts " decompiled #{section}#{join}#{file}."
|
104
|
+
rescue
|
105
|
+
puts "!!! Could not write compiled file #{path}: #{$!}"
|
106
|
+
abort!
|
107
|
+
end
|
87
108
|
end
|
88
109
|
|
89
110
|
def load(file=nil)
|
@@ -105,12 +126,7 @@ module Aws
|
|
105
126
|
else
|
106
127
|
raise "Unsupported file type for specification: #{file}"
|
107
128
|
end
|
108
|
-
|
109
|
-
|
110
|
-
template.each {|key,val|
|
111
|
-
@items[key.to_sym] = val
|
112
|
-
}
|
113
|
-
|
129
|
+
@items = template
|
114
130
|
else
|
115
131
|
raise "Unable to open template: #{abs}"
|
116
132
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-cfn-decompiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christo De Lange
|
@@ -72,20 +72,20 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.1
|
75
|
+
version: 0.2.1
|
76
76
|
- - "~>"
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: '0.
|
78
|
+
version: '0.2'
|
79
79
|
type: :runtime
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0.1
|
85
|
+
version: 0.2.1
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '0.
|
88
|
+
version: '0.2'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: bundler
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|