<commit_before>require "rspec-live/terminal"

module RSpecLive
  class Display
    attr_reader :watcher_display, :suite_display

    def initialize
      @terminal = Terminal.new
      @watcher_display = WatcherDisplay.new(@terminal.add_section :align => :center)
      @terminal.add_section :display => :block, :content => key_command_info
      @suite_display = SuiteDisplay.new(@terminal.add_section :display => :block)
    end

    private

    def key_command_info
      "[ A:all | R:rerun | Q:quit ]"
    end
  end

  class WatcherDisplay
    def initialize(section)
      @section = section
    end

    def status=(status)
      @section.content = "RSpec summary for #{File.basename Dir.pwd} (#{status})"
    end
  end

  class SuiteDisplay
    def initialize(section)
      @section = section
    end

    def show_examples(examples, suite_status, detailed_examples)
      @section.clear
      examples.map(&:status).each do |status|
        @section.add_section :content => character[status], :color => color[status]
      end
      @section.add_section :content => "#{suite_status}", :display => :block
      detailed_examples.each do |example|
        color = example.failed? ? :red : (example.passed? ? :green : :yellow )
        @section.add_section :content => example.details, :display => :block, :color => color, :wrap => true
      end
    end

    private

    def character
      {:unknown => ".", :passed => ".", :failed => "F", :pending => "S"}
    end

    def color
      {:unknown => :blue, :passed => :green, :failed => :red, :pending => :yellow}
    end
  end
end<commit_msg>Dry up color lookup for example detail display<commit_after>require "rspec-live/terminal"

module RSpecLive
  class Display
    attr_reader :watcher_display, :suite_display

    def initialize
      @terminal = Terminal.new
      @watcher_display = WatcherDisplay.new(@terminal.add_section :align => :center)
      @terminal.add_section :display => :block, :content => key_command_info
      @suite_display = SuiteDisplay.new(@terminal.add_section :display => :block)
    end

    private

    def key_command_info
      "[ A:all | R:rerun | Q:quit ]"
    end
  end

  class WatcherDisplay
    def initialize(section)
      @section = section
    end

    def status=(status)
      @section.content = "RSpec summary for #{File.basename Dir.pwd} (#{status})"
    end
  end

  class SuiteDisplay
    def initialize(section)
      @section = section
    end

    def show_examples(examples, suite_status, detailed_examples)
      @section.clear
      examples.map(&:status).each do |status|
        @section.add_section :content => character[status], :color => color[status]
      end
      @section.add_section :content => "#{suite_status}", :display => :block
      detailed_examples.each do |example|
        @section.add_section :content => example.details, :display => :block, :color => color[example.status], :wrap => true
      end
    end

    private

    def character
      {:unknown => ".", :passed => ".", :failed => "F", :pending => "S"}
    end

    def color
      {:unknown => :blue, :passed => :green, :failed => :red, :pending => :yellow}
    end
  end
end
{'fraction_non_alphanumeric': 0.12633900441083806, 'fraction_numerical': 0.0, 'mean_word_length': 3.024081115335868, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7117543', 'n_tokens_mistral': 985, 'n_tokens_neox': 934, 'n_words': 244}