aws-cfn-yats 0.0.4 → 0.1.0

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
  SHA1:
3
- metadata.gz: fda00bef545348a75a1f0174c6326191849f52c0
4
- data.tar.gz: b8a994c8177d43ccb3851431ef539fd00c50875f
3
+ metadata.gz: a8686d1353a219389116ceb376be5be49b122ba3
4
+ data.tar.gz: 4d5ca1a4dceb9d62817b5e40396f13bee82d22ed
5
5
  SHA512:
6
- metadata.gz: bfe62e3061e0501f7aea69dfdf07af1907d49385eabf9029c2b0b74b4509b959a96d469c89a1cb96c0d11bb73cfe2ae0adfea9868be610ff5a78b8cfab70ce3d
7
- data.tar.gz: 3d7bf59a237f67fa825cfc513d84511bb14d55bf1a2bf46966c6cbae8e9df3d841ad9ee7f60f366f08aaa287aa9fd2b3281afd1cb94a0033b240d436247a717e
6
+ metadata.gz: 13d38649e2ec100eb55fc6f9f7ce64d21f376da46f437a3cd62b286db9df30ec10c908d67b27ae7c99975ddfe5264d63c436c27ac77d80dfe0dfd21d080b03fe
7
+ data.tar.gz: cab66c25c8254f40a33517d583a25a5017a58b51504902ee70ee8e08757315755e943b2411022be6bcad9d6b59df3bb7cc0fd1d071d943f6418b283341e87ab6
data/aws-cfn-yats.gemspec CHANGED
@@ -18,7 +18,7 @@ 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 'aws-cfn-dsl', '>=0.0.2'
21
+ spec.add_dependency 'json_pure', '> 0'
22
22
  spec.add_dependency 'aws-cfn-decompiler', '>= 0.0.3', '~> 0.0'
23
23
  spec.add_dependency 'aws-cfn-compiler', '>= 0.2.1', '~> 0.2'
24
24
  spec.add_dependency 'cloud_builder', '> 0'
data/aws-cfn-yats.iml CHANGED
@@ -29,6 +29,7 @@
29
29
  <orderEntry type="library" scope="PROVIDED" name="cloud_builder (v0.0.11, RVM: ruby-2.1.2) [gem]" level="application" />
30
30
  <orderEntry type="library" scope="PROVIDED" name="cloudformer (v0.0.11, RVM: ruby-2.1.2) [gem]" level="application" />
31
31
  <orderEntry type="library" scope="PROVIDED" name="i18n (v0.6.9, RVM: ruby-2.1.2) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="json_pure (v1.8.1, RVM: ruby-2.1.2) [gem]" level="application" />
32
33
  <orderEntry type="library" scope="PROVIDED" name="mini_portile (v0.6.0, RVM: ruby-2.1.2) [gem]" level="application" />
33
34
  <orderEntry type="library" scope="PROVIDED" name="minitest (v5.3.4, RVM: ruby-2.1.2) [gem]" level="application" />
34
35
  <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.6.2.1, RVM: ruby-2.1.2) [gem]" level="application" />
data/bin/cfn-json2rb CHANGED
@@ -22,7 +22,6 @@ add_path = File.expand_path(File.join(path, "..", "lib"))
22
22
  $:.unshift(add_path)
23
23
 
24
24
  require 'aws/cfn/yats'
25
- require 'json'
26
25
 
27
26
  unless (ARGV & %w(-h --help -?)).empty?
28
27
  $stderr.puts <<"EOF"
data/bin/cfn-json2yaml CHANGED
@@ -22,7 +22,6 @@ add_path = File.expand_path(File.join(path, "..", "lib"))
22
22
  $:.unshift(add_path)
23
23
 
24
24
  require 'aws/cfn/yats'
25
- require 'json'
26
25
 
27
26
  unless (ARGV & %w(-h --help -?)).empty?
28
27
  $stderr.puts <<"EOF"
data/bin/cfn-yaml2json CHANGED
@@ -22,7 +22,6 @@ add_path = File.expand_path(File.join(path, "..", "lib"))
22
22
  $:.unshift(add_path)
23
23
 
24
24
  require 'aws/cfn/yats'
25
- require 'json'
26
25
 
27
26
  unless (ARGV & %w(-h --help -?)).empty?
28
27
  $stderr.puts <<"EOF"
@@ -5,6 +5,7 @@ unless RUBY_VERSION >= '1.9'
5
5
  exit(2)
6
6
  end
7
7
 
8
+ require 'json/pure'
8
9
  require "aws/cfn/yats/version"
9
10
 
10
11
  module Aws
@@ -88,7 +89,7 @@ module Aws
88
89
  when :resources
89
90
  val.each { |k, v| pprint_cfn_resource k, v }
90
91
  else
91
- pprint_value(val, '')
92
+ pprint_value(val)
92
93
  end
93
94
  end
94
95
 
@@ -12,6 +12,23 @@ module Aws
12
12
 
13
13
  protected
14
14
 
15
+ def pprint(val)
16
+ case detect_type(val)
17
+ when :template
18
+ pprint_cfn_template(val)
19
+ when :parameter
20
+ pprint_cfn_section 'parameter', 'TODO', val
21
+ when :resource
22
+ pprint_cfn_resource 'TODO', val
23
+ when :parameters
24
+ val.each { |k, v| pprint_cfn_section 'parameter', k, v }
25
+ when :resources
26
+ val.each { |k, v| pprint_cfn_resource k, v }
27
+ else
28
+ pprint_value(val, '')
29
+ end
30
+ end
31
+
15
32
  def pprint_cfn_template(tpl)
16
33
  puts "#!/usr/bin/env ruby"
17
34
  puts
@@ -8,8 +8,19 @@ module Aws
8
8
  class Json2Yaml < Base
9
9
 
10
10
  def pprint_cfn_template(tpl)
11
+ pprint_value(tpl)
12
+ end
13
+
14
+ def pprint_cfn_section(section, name, options)
15
+ pprint_value(section)
16
+ end
17
+
18
+ def pprint_cfn_resource(name, options)
19
+ pprint_value({ name => options })
20
+ end
11
21
 
12
- yml = YAML::dump(tpl)
22
+ def pprint_value(val, indent="\t")
23
+ yml = YAML::dump(val)
13
24
 
14
25
  puts yml
15
26
  end
@@ -1,7 +1,7 @@
1
1
  module Aws
2
2
  module Cfn
3
3
  module Yats
4
- VERSION = "0.0.4"
4
+ VERSION = "0.1.0"
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,6 @@
1
1
  require "aws/cfn/yats/base"
2
2
  require 'yaml'
3
+ require 'json/pure'
3
4
 
4
5
  module Aws
5
6
  module Cfn
@@ -16,8 +17,24 @@ module Aws
16
17
  end
17
18
 
18
19
  def pprint_cfn_template(tpl)
20
+ pprint_value(tpl)
21
+ end
22
+
23
+ def pprint_cfn_section(section, name, options)
24
+ pprint_value(section)
25
+ end
26
+
27
+ def pprint_cfn_resource(name, options)
28
+ pprint_value({ name => options })
29
+ end
19
30
 
20
- @json = JSON.pretty_generate(tpl)
31
+ def pprint_value(val, indent="\t")
32
+ @json = JSON.pretty_generate(val, {
33
+ :indent => indent,
34
+ :space => ' ',
35
+ :object_nl => "\n",
36
+ :array_nl => "\n"
37
+ } )
21
38
 
22
39
  puts @json
23
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-cfn-yats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christo De Lange
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json_pure
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: aws-cfn-decompiler
15
29
  requirement: !ruby/object:Gem::Requirement