class S3Secure::Encryption::List

Public Instance Methods

run() click to toggle source
# File lib/s3_secure/encryption/list.rb, line 3
def run
  presenter = CliFormat::Presenter.new(@options)
  presenter.header = ["Bucket", "Has Encryption?"]

  buckets.each do |bucket|
    $stderr.puts "Getting encryption for bucket #{bucket.color(:green)}"
    show = Show.new(bucket: bucket)

    row = [bucket, show.enabled?]
    if @options[:encryption].nil?
      presenter.rows << row # always show policy
    elsif @options[:encryption]
      presenter.rows << row if show.enabled? # only show if bucket has some encryption rules
    else
      presenter.rows << row unless show.enabled? # only show if bucket doesnt have any encryption rules
    end
  end

  presenter.show
end