aws-cfn-decompiler 0.6.0 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7aeb28a3e087cf7ada2d2842283f27c34076fa70
4
- data.tar.gz: 756e2950012c76c57c6ade2965096d5fe25b265b
3
+ metadata.gz: db417aafff50d73c42de66f4c80097d530653369
4
+ data.tar.gz: 833fa918eeabce35b42a09e2bce5a523d0b0c864
5
5
  SHA512:
6
- metadata.gz: 2bc4574d3bcbfaaef555a4b6ae54862508f83fe33c0ea25b7235abb399e5b7a1b59d5f967cb1fb7a5928cd6b9dd9cab360217ce43ad876800c7b37290a79ce32
7
- data.tar.gz: 9a7d623cf3adfd4f88aeae49a43abe388e1c3a9fa520e37daf05b41d842ff34b3825cccf814e0a3eab896c79d51b1de2dee99e54dcdb42c7775f38c437b4b9d6
6
+ metadata.gz: 48d6d134e7fa7f1aad5452a44c1fdad1173ec2c9005fdb127673aa405223993abee503f3c9695b0832973917ab64bc8e6e1c690da9c5ac50c61840089d9f1a9c
7
+ data.tar.gz: c280a5cc7784e25fcc2568b530bbfb050429fe3a54887453caae78a4b84e55e8bca8cb3484e9a6b7e75fbb331df02a3fc49fc3e12e6edfb93bc3898aef80e6da
data/Gemfile CHANGED
@@ -8,10 +8,10 @@ gem 'cloudformation-ruby-dsl', :path => '../cloudformation-ruby-dsl', :group =>
8
8
  gem 'dldinternet-mixlib-logging', :path => '../dldinternet-mixlib-logging', :group => :development
9
9
  gem 'dldinternet-mixlib-cli', :path => '../dldinternet-mixlib-cli', :group => :development
10
10
  gem 'aws-cfn-dsl', :path => '../aws-cfn-dsl', :group => :development
11
- gem 'aws-cfn-decompiler', :path => '../aws-cfn-decompiler', :group => :development
12
11
  gem 'aws-cfn-compiler', :path => '../aws-cfn-compiler', :group => :development
13
12
  gem 'aws-cfn-yats', :path => '../aws-cfn-yats', :group => :development
14
13
  gem 'aws-cfn-stacker', :path => '../aws-cfn-stacker', :group => :development
15
14
 
15
+ gem 'json_pure', :group => :development
16
16
  gem 'bundler', "~> 1.6", :group => :development
17
17
  gem 'rake', :group => :development
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "awesome_print", '~> 1.2', '>= 1.2.0'
22
- spec.add_dependency "psych"
23
- spec.add_dependency "json"
24
- spec.add_dependency "slop"
25
- spec.add_dependency 'aws-cfn-compiler', '>= 0.5.0', '~> 0.5'
21
+ spec.add_dependency 'awesome_print', '~> 1.2', '>= 1.2.0'
22
+ spec.add_dependency 'psych'
23
+ spec.add_dependency 'json'
24
+ spec.add_dependency 'slop'
25
+ spec.add_dependency 'aws-cfn-compiler', '>= 0.7.0', '~> 0.7'
26
26
 
27
27
  end
@@ -53,6 +53,7 @@
53
53
  <orderEntry type="library" scope="PROVIDED" name="detabulator (v0.1.0, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
54
54
  <orderEntry type="library" scope="PROVIDED" name="inifile (v2.0.2, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
55
55
  <orderEntry type="library" scope="PROVIDED" name="json (v1.8.1, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
56
+ <orderEntry type="library" scope="PROVIDED" name="json_pure (v1.8.1, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
56
57
  <orderEntry type="library" scope="PROVIDED" name="little-plugger (v1.1.3, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
57
58
  <orderEntry type="library" scope="PROVIDED" name="logging (v1.8.2, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
58
59
  <orderEntry type="library" scope="PROVIDED" name="mixlib-cli (v1.5.0, RVM: ruby-1.9.3-p547 [aws-cfn-decompiler]) [gem]" level="application" />
@@ -11,15 +11,18 @@ module Aws
11
11
  class Base < ::Aws::Cfn::Compiler::Base
12
12
  attr_accessor :template
13
13
 
14
- def save_dsl(output_dir)
14
+ require "aws/cfn/decompiler/mixins/options"
15
+ include Aws::Cfn::DeCompiler::Options
16
+
17
+ def save_dsl(output_dir, decompiled=@items)
15
18
 
16
19
  specification = {}
17
- format = @opts[:format] rescue 'yaml'
20
+ format = @config[:format] rescue 'yaml'
18
21
  ruby = (not format.match(%r'^ruby|rb$').nil?)
19
22
  if ruby
20
- pprint_cfn_template simplify(@items)
23
+ pprint_cfn_template simplify(decompiled)
21
24
  end
22
- @items.each do |section, section_items|
25
+ decompiled.each do |section, section_items|
23
26
  case section
24
27
  when /Mappings|Parameters|Resources|Outputs/
25
28
  specification[section] = []
@@ -44,45 +47,16 @@ module Aws
44
47
  end
45
48
 
46
49
  # Save specification
47
- unless @opts[:specification].nil?
48
- dir = File.dirname(@opts[:specification])
50
+ unless @config[:specification].nil?
51
+ dir = File.dirname(@config[:specification])
49
52
  dir = output_dir unless dir
50
- save_section(dir, File.basename(@opts[:specification]), format, '', specification, "Specification in #{dir}/")
53
+ save_section(dir, File.basename(@config[:specification]), format, '', specification, '', "specification")
51
54
  end
52
55
 
53
56
  end
54
57
 
55
58
  protected
56
59
 
57
- def save_section(dir, file, format, section, hash, join='/')
58
- logStep "Saving section #{hash.keys[0]} to #{section}/#{file} "
59
- path = File.join(dir, file)
60
-
61
- begin
62
- if i_am_maintainer(path)
63
- # File.delete path if File.exists? path
64
- File.open path, File::CREAT|File::TRUNC|File::RDWR, 0644 do |f|
65
- case format
66
- when /ruby|rb|yaml|yml/
67
- f.write maintainer_comment('')
68
- f.write hash.to_yaml line_width: 1024, indentation: 4, canonical: false
69
- when /json|js/
70
- # You wish ... f.write maintainer_comment('')
71
- f.write JSON.pretty_generate(hash)
72
- else
73
- abort! "Internal: Unsupported format #{format}. Should have noticed this earlier!"
74
- end
75
- f.close
76
- end
77
- @logger.info " decompiled #{section}#{join}#{file}."
78
- else
79
- @logger.warn " Did not overwrite #{section}#{join}#{file}."
80
- end
81
- rescue
82
- abort! "!!! Could not write compiled file #{path}: #{$!}"
83
- end
84
- end
85
-
86
60
  end
87
61
  end
88
62
  end
@@ -11,49 +11,27 @@ module Aws
11
11
 
12
12
  def run
13
13
 
14
- @opts = Slop.parse(help: true, strict: true) do
15
- # command File.basename(__FILE__,'.rb')
16
- on :j, :template=, 'The template to decompile', as: String
17
- on :o, :output=, 'The directory to output the components to.', as: String
18
- on :f, :format=, 'The output format of the components. [JSON|YAML|Ruby]', as: String, match: %r/ruby|rb|yaml|yml|json|js/i
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
21
- on :O, :overwrite, 'Overwrite existing generated source files. (HINT: Think twice ...)', { as: String, optional_argument: true, default: 'off', match: %r/0|1|yes|no|on|off|enable|disable|set|unset|true|false|raw/i }
22
- end
14
+ parse_options
23
15
 
24
- @config[:overwrite] = if @opts[:overwrite].downcase.match %r'^(1|true|on|yes|enable|set)$'
25
- true
26
- else
27
- false
28
- end
29
- @config[:functions] = if @opts[:functions]
30
- (not @opts[:functions].downcase.match(%r'^(1|true|on|yes|enable|set)$').nil?)
31
- else
32
- false
33
- end
34
- @config[:directory] = @opts[:output]
16
+ set_config_options
35
17
 
36
- unless @opts[:template]
37
- @logger.error @opts
38
- exit
39
- end
40
- unless @opts[:output].nil?
41
- unless File.directory?(@opts[:output])
42
- Dir.mkdir(@opts[:output])
18
+ unless @config[:directory].nil?
19
+ unless File.directory?(@config[:directory])
20
+ Dir.mkdir(@config[:directory])
43
21
  end
44
- unless File.directory?(@opts[:output])
45
- @logger.error "Cannot see output directory: #{@opts[:output]}"
46
- @logger.error @opts.to_s
22
+ unless File.directory?(@config[:directory])
23
+ @logger.error "Cannot see output directory: #{@config[:directory]}"
24
+ @logger.error @config.to_s
47
25
  exit
48
26
  end
49
27
  end
50
28
 
51
- load_template @opts[:template]
29
+ decompiled = load_template @config[:template]
52
30
 
53
- validate(@items)
31
+ validate(decompiled)
54
32
 
55
- output_dir = @opts[:output] || Dir.pwd
56
- save_dsl(output_dir)
33
+ output_dir = @config[:directory] || Dir.pwd
34
+ save_dsl(output_dir,decompiled)
57
35
 
58
36
  @logger.step '*** Decompiled Successfully ***'
59
37
  end
@@ -0,0 +1,35 @@
1
+ module Aws
2
+ module Cfn
3
+ module DeCompiler
4
+ module Options
5
+
6
+ def parse_options
7
+ # noinspection RubySuperCallWithoutSuperclassInspection
8
+ setup_options
9
+
10
+ @opts.on :F, :format=, 'The output format of the components. [JSON|YAML|Ruby]', { as: String, match: @format_regex, default: 'yaml' }
11
+ @opts.on :s, :specification=, 'The specification file to create.', as: String
12
+
13
+ @opts.parse!
14
+
15
+ unless @opts[:directory]
16
+ puts @opts
17
+ abort! "Missing required option --directory"
18
+ end
19
+
20
+ unless @opts[:template]
21
+ puts @opts
22
+ abort! "Missing required option --template"
23
+ end
24
+
25
+ end
26
+
27
+ def set_config_options
28
+ setup_config
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
35
+
@@ -1,7 +1,7 @@
1
1
  module Aws
2
2
  module Cfn
3
3
  module DeCompiler
4
- VERSION = "0.6.0"
4
+ VERSION = '0.7.0'
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-decompiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
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-28 00:00:00.000000000 Z
11
+ date: 2014-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -78,20 +78,20 @@ dependencies:
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: 0.5.0
81
+ version: 0.7.0
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '0.5'
84
+ version: '0.7'
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
- version: 0.5.0
91
+ version: 0.7.0
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: '0.5'
94
+ version: '0.7'
95
95
  description: The idea is to extract a big CloudFormation template into a folder structure
96
96
  to better manage pieces of a CloudFormation deployment. Additionally, writing in
97
97
  JSON is hard, so the decompiler can create YAML files as well.
@@ -129,6 +129,7 @@ files:
129
129
  - lib/aws/cfn/decompiler.rb
130
130
  - lib/aws/cfn/decompiler/base.rb
131
131
  - lib/aws/cfn/decompiler/main.rb
132
+ - lib/aws/cfn/decompiler/mixins/options.rb
132
133
  - lib/aws/cfn/decompiler/version.rb
133
134
  homepage: https://github.com/dldinternet/aws-cfn-decompiler
134
135
  licenses: