Class: FlareUp::Emitter

Inherits:
Object
  • Object
show all
Defined in:
lib/flare_up/emitter.rb

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.error(message) ⇒ Object

TODO: How do we test this?



13
14
15
# File 'lib/flare_up/emitter.rb', line 13

def self.error(message)
  $stderr.puts sanitize("\x1b[31m#{message}") unless ENV['TESTING']
end

.info(message) ⇒ Object

TODO: How do we test this?



18
19
20
# File 'lib/flare_up/emitter.rb', line 18

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

.sanitize(message) ⇒ Object

TODO: How do we test this?



23
24
25
26
27
28
29
# File 'lib/flare_up/emitter.rb', line 23

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

.store_options(options) ⇒ Object

TODO: How do we test this?



32
33
34
# File 'lib/flare_up/emitter.rb', line 32

def self.store_options(options)
  @BOOT_OPTIONS = options
end