module Bacon
  module ColoredOutput
    include SpecDoxOutput

    def handle_requirement(description)
      print spaces

      error = yield

      print error.empty? ? color("\e[32m") : color("\e[1;31m")
      print "  - #{description}"
      puts error.empty? ? color("\e[0m") : " [#{error}]#{color("\e[0m")}"
    end

    def color(escape_seq)
      if $stdout.respond_to?(:tty?) && $stdout.tty?
        escape_seq
      else
        ""
      end
    end
  end

  extend ColoredOutput
end
module Bacon
  module ColoredOutput
    def handle_requirement(*args)
      error = yield

      print error.empty? ? color("\e[32m") : color("\e[1;31m")
      super
      print color("\e[0m")
    end

    def color(escape_seq)
      if $stdout.respond_to?(:tty?) && $stdout.tty?
        escape_seq
      else
        ""
      end
    end
  end

  extend ColoredOutput
end
Make colored output universal (for any output style)
Make colored output universal (for any output style)
