Sha256: 8e3b1822e91328c4469e4b8b22391050f1625841582a59e35f7c4248e6d6dd8b
Contents?: true
Size: 912 Bytes
Versions: 4
Compression:
Stored size: 912 Bytes
Contents
require "teaspoon/formatter/dot" module Teaspoon module Formatter class Pride < Dot PI_3 = Math::PI / 3 def initialize(*args) @color_index = 0 super end protected def log_spec(result) return log_pride if result.passing? super end private def log_pride return log_str(".") unless Teaspoon.configuration.color log_str("\e[38;5;#{next_color}m.\e[0m") end def colors @colors ||= (0...42).map do |i| i *= 1.0 / 6 36 * calc_color(i) + 6 * calc_color(i + 2 * PI_3) + calc_color(i + 4 * PI_3) + 16 end end def calc_color(val) (3 * Math.sin(val) + 3).to_i end def next_color c = colors[@color_index % colors.size] @color_index += 1 c end end end end
Version data entries
4 entries across 4 versions & 1 rubygems