class Bukelatta::DSL::Converter

Public Class Methods

convert(exported, options = {}) click to toggle source
# File lib/bukelatta/dsl/converter.rb, line 4
def self.convert(exported, options = {})
  self.new(exported, options).convert
end
new(exported, options = {}) click to toggle source
# File lib/bukelatta/dsl/converter.rb, line 8
def initialize(exported, options = {})
  @exported = exported
  @options = options
end

Public Instance Methods

convert() click to toggle source
# File lib/bukelatta/dsl/converter.rb, line 13
def convert
  output_buckets(@exported)
end

Private Instance Methods

output_bucket(bucket_name, policy) click to toggle source
# File lib/bukelatta/dsl/converter.rb, line 33
  def output_bucket(bucket_name, policy)
    policy = policy.pretty_inspect.gsub(/^/, '  ').strip

    <<-EOS
bucket #{bucket_name.inspect} do
  #{policy}
end
    EOS
  end
output_buckets(policy_by_bucket) click to toggle source
# File lib/bukelatta/dsl/converter.rb, line 19
def output_buckets(policy_by_bucket)
  buckets = []

  policy_by_bucket.sort_by(&:first).each do |bucket_name, policy|
    if not policy or not matched?(bucket_name)
      next
    end

    buckets << output_bucket(bucket_name, policy)
  end

  buckets.join("\n")
end