class Monosasi::DSL::Converter
Public Class Methods
convert(exported, options = {})
click to toggle source
# File lib/monosasi/dsl/converter.rb, line 2 def self.convert(exported, options = {}) self.new(exported, options).convert end
new(exported, options = {})
click to toggle source
# File lib/monosasi/dsl/converter.rb, line 6 def initialize(exported, options = {}) @exported = exported @options = options end
Public Instance Methods
convert()
click to toggle source
# File lib/monosasi/dsl/converter.rb, line 11 def convert output_rules(@exported) end
Private Instance Methods
output_batch_parameters(params)
click to toggle source
# File lib/monosasi/dsl/converter.rb, line 125 def output_batch_parameters(params) Dslh.deval({"batch_parameters" => params}, initial_depth: 2, force_dump_braces: true) end
output_ecs_parameters(params)
click to toggle source
# File lib/monosasi/dsl/converter.rb, line 121 def output_ecs_parameters(params) Dslh.deval({"ecs_parameters" => params}, initial_depth: 2, force_dump_braces: true) end
output_rule(name, rule)
click to toggle source
# File lib/monosasi/dsl/converter.rb, line 27 def output_rule(name, rule) body = <<-EOS state #{rule[:state].inspect} EOS if rule[:description] body += <<-EOS description #{rule[:description].inspect} EOS end if rule[:schedule_expression] body += <<-EOS schedule_expression #{rule[:schedule_expression].inspect} EOS end if rule[:event_pattern] event_pattern = rule[:event_pattern].pretty_inspect event_pattern.gsub!(/^/, "\s" * 4) body += <<-EOS event_pattern do #{event_pattern.strip} end EOS end if rule[:targets] body += output_targets(rule[:targets]) end <<-EOS rule #{name.inspect} do #{body.strip} end EOS end
output_rules(rule_by_name)
click to toggle source
# File lib/monosasi/dsl/converter.rb, line 17 def output_rules(rule_by_name) rules = [] rule_by_name.sort_by(&:first).each do |name, rule| rules << output_rule(name, rule) end rules.join("\n") end
output_target(id, target)
click to toggle source
# File lib/monosasi/dsl/converter.rb, line 72 def output_target(id, target) body = <<-EOS arn #{target[:arn].inspect} EOS if target[:input] input = target[:input].pretty_inspect input.gsub!(/^/, "\s" * 6) body += <<-EOS input #{target[:input].inspect} EOS end if target[:input_path] body += <<-EOS input_path #{target[:input_path].inspect} EOS end if target[:input_transformer] body += <<-EOS input_transformer #{target[:input_transformer].inspect} EOS end if target[:ecs_parameters] body += output_ecs_parameters(target[:ecs_parameters]) body += "\n" end if target[:role_arn] body += <<-EOS role_arn #{target[:role_arn].inspect} EOS end if target[:batch_parameters] body += output_batch_parameters(target[:batch_parameters]) body += "\n" end <<-EOS.chomp target #{id.inspect} do #{body.strip} end EOS end
output_targets(targets)
click to toggle source
# File lib/monosasi/dsl/converter.rb, line 66 def output_targets(targets) targets.map {|id, target| output_target(id, target).chomp }.join("\n") end