cfndsl 0.3.6 → 0.4.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmMzN2MxYzJjYzBjZmMwYmIxYTgxMDU4ZTk3NTM1YzJlNTI2NDg0NA==
4
+ Yjc5YTJlYmM0ZTQ0YTM3MmU1OWQ5Yjc4MmYwMWYyYTg5ZmE1NTdjOA==
5
5
  data.tar.gz: !binary |-
6
- NGE0MzE5MjdhZWFiY2Y1OThmYzM5NzJhOTFhODA1MjY3YjU2ODIzNQ==
6
+ ZTU2YWQ0NjAzMzVkZjY4YjdjNmUwOGY3MDJhZjk5NTEwZTZmMDAzMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDU1ZGZjMDE3MDQwY2EzZDI5ODg4ZTMxMzE1MTM0YTkzYzA3ZDU3MDYyYmIz
10
- OWZiOWNlZWM0NjgwOGRiYjg2ZDgwNDVjNDY0ZTQ4N2YxMjY1NjEyZWNjOGZm
11
- ODA0MDcwOWU0NzVmZjkwNDNlNzc0N2M2OTFlZjJhZGNhYTU0OTQ=
9
+ NWQ1NmYzOTZjZWY5NGMwZGQ0NDliZDI4Y2Y0MDZmOTUyNmEzZDE2MDBmZmMy
10
+ MGYwNTE3MDQ5MGJjNmZkYzY3N2VhYzA3NjcwMGM3MDJjN2FiOTcwZGFkMzk1
11
+ N2ZmNGU3ZGRhY2RiNDRjOGIzNGZjZTAxNTM3ZThiMmYyMDg1YTI=
12
12
  data.tar.gz: !binary |-
13
- ZGVkMWEyNTAzZTIwMDA2NDU1Y2NhMDJmMzYyN2ZiNzY0YmE2YzEwYTQ5MTRj
14
- NDg2NTQyZTk1MGUxMjQ1ZjMzMDdkZGU4ODEyM2QyMmIwMGVmNjlkNmUwOWZh
15
- YjU4NmIyNWQ2ODA5NjRlNjYwNmU5YjlmOTRhYjU1NjA2MjlmODA=
13
+ Y2JjODdlMTIxZWMwZWE3YWFlMzBmMjgzNTBlZTUzM2E2MWU2NDliMjA3YmQ3
14
+ YWI3MWRjOGVkYjgwNWFjODE4NmYxNzVlYmRhOWEyY2NkZmMxYTQ5NTc2NGI2
15
+ ODRkNjRmNThkNTQwYWUwN2UzOTE2ZWFhMDc1NWRiNjJkNjUzMTU=
data/README.md CHANGED
@@ -101,6 +101,7 @@ Usage: cfndsl [options] FILE
101
101
  -y, --yaml FILE Import yaml file as local variables
102
102
  -r, --ruby FILE Evaluate ruby file before template
103
103
  -j, --json FILE Import json file as local variables
104
+ -p, --pretty Pretty-format output JSON
104
105
  -D, --define "VARIABLE=VALUE" Directly set local VARIABLE as VALUE
105
106
  -v, --verbose Turn on verbose ouptut
106
107
  -h, --help Display this screen
data/bin/cfndsl CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'cfndsl'
4
4
  require 'optparse'
5
+ require 'json'
5
6
 
6
7
  options = {}
7
8
 
@@ -27,6 +28,9 @@ optparse = OptionParser.new do|opts|
27
28
  options[:extras].push([:json,File.expand_path(file)])
28
29
  end
29
30
 
31
+ opts.on( '-p', '--pretty', 'Pretty-format output JSON') do
32
+ options[:pretty] = true
33
+ end
30
34
 
31
35
  opts.on( '-D', '--define "VARIABLE=VALUE"', 'Directly set local VARIABLE as VALUE' ) do |file|
32
36
  options[:extras].push([:raw,file])
@@ -64,4 +68,4 @@ else
64
68
  verbose.puts("Writing to STDOUT") if verbose
65
69
  end
66
70
 
67
- output.puts model.to_json
71
+ output.puts options[:pretty] ? JSON.pretty_generate(model) : model.to_json
@@ -21,7 +21,9 @@ module CfnDsl
21
21
 
22
22
  def generate(opts)
23
23
  log(opts)
24
- outputter(opts).puts model(opts[:filename])
24
+ outputter(opts) do |output|
25
+ output.puts model(opts[:filename])
26
+ end
25
27
  end
26
28
 
27
29
  def log(opts)
@@ -30,7 +32,7 @@ module CfnDsl
30
32
  end
31
33
 
32
34
  def outputter(opts)
33
- opts[:output].nil? ? STDOUT : file_output(opts[:output])
35
+ opts[:output].nil? ? yield(STDOUT) : file_output(opts[:output]) { |f| yield f }
34
36
  end
35
37
 
36
38
  def model(filename)
@@ -48,7 +50,7 @@ module CfnDsl
48
50
  end
49
51
 
50
52
  def file_output(path)
51
- File.open(File.expand_path(path), "w")
53
+ File.open(File.expand_path(path), "w") { |f| yield f }
52
54
  end
53
55
  end
54
56
  end
@@ -1,3 +1,3 @@
1
1
  module CfnDsl
2
- VERSION = "0.3.6"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfndsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-09 00:00:00.000000000 Z
12
+ date: 2016-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler