Sha256: 255af6f642d7c403f92d5e4cc648b17841d3f76c3df1578efde7fe94b4b6a19a

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'

# Borrowing from "whiches" gem ...
cmd  = File.basename(__FILE__)
exes = []
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
  exts.each { |ext|
    exe = File.join(path, "#{cmd}#{ext}")
    exes << exe if File.executable? exe
  }
end
path = if exes.size > 0
         File.dirname(exes[0])
       else
         File.dirname(__FILE__)
       end

add_path = File.expand_path(File.join(path, "..", "lib"))
$:.unshift(add_path)

require 'aws/cfn/yats'

unless (ARGV & %w(-h --help -?)).empty?
  $stderr.puts <<"EOF"
usage: #{$PROGRAM_NAME} [cloudformation-template.json] ...

Converts the specified CloudFormation JSON template or template fragment to
Ruby DSL syntax.  Reads from stdin or from the specified json files.  Note
that the input must be valid JSON.

Examples:

  # Convert a JSON CloudFormation template to Ruby DSL syntax
  #{$PROGRAM_NAME} my-template.json > my-template.rb
  chmod +x my-template.rb

  # Convert the JSON fragment in the clipboard to Ruby DSL syntax
  pbpaste | #{$PROGRAM_NAME} | less

EOF
  exit(2)
end

j2r = Aws::Cfn::Yats::Json2Rb.new

if ARGV.empty?
  template = $stdin.read
  j2r.transform(template)
else
  ARGV.each do |filename|
    template = File.read(filename)
    j2r.transform(template)
  end
end
# The user should make the resulting template executable w/chmod +x

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aws-cfn-yats-0.1.6 bin/cfn-json2rb
aws-cfn-yats-0.1.5 bin/cfn-json2rb
aws-cfn-yats-0.1.2 bin/cfn-json2rb
aws-cfn-yats-0.1.1 bin/cfn-json2rb
aws-cfn-yats-0.1.0 bin/cfn-json2rb