Sha256: af34df5e7b00d07f888d5c6f213c78b7d032f4c9f64790d68d47097921131357

Contents?: true

Size: 1008 Bytes

Versions: 3

Compression:

Stored size: 1008 Bytes

Contents

module FlareUp

  class Emitter

    RISKY_OPTIONS = [
      :aws_access_key,
      :aws_secret_key,
      :redshift_username,
      :redshift_password
    ]

    def self.error(message)
      err("\x1b[31m#{message}")
    end

    def self.success(message)
      out("\x1b[32m#{message}")
    end

    def self.warn(message)
      err("\x1b[33m#{message}")
    end

    def self.info(message)
      out(message)
    end

    def self.out(message)
      $stderr.puts(sanitize(message)) unless ENV['TESTING']
    end
    private_class_method :out

    def self.err(message)
      $stdout.puts(sanitize(message)) unless ENV['TESTING']
    end
    private_class_method :err

    def self.sanitize(message)
      RISKY_OPTIONS.each do |risky_option|
        message.gsub!(OptionStore.get(risky_option), 'REDACTED') if OptionStore.get(risky_option)
      end
      message.gsub!(/\e\[(\d+)(;\d+)*m/, '') unless OptionStore.get(:colorize_output)
      message
    end
    private_class_method :sanitize

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flare-up-0.10 lib/flare_up/emitter.rb
flare-up-0.9 lib/flare_up/emitter.rb
flare-up-0.8 lib/flare_up/emitter.rb