Class: Test::Unit::ColorScheme

### Home Classes Methods

### In Files

- lib/test/unit/color-scheme.rb

### Parent

Object

### Methods

- ::[]
- ::[]=
- ::all
- ::available_colors
- ::default
- ::default_for_256_colors
- ::default_for_8_colors
- ::new
- #[]
- #[]=
- #each
- #to_hash

### Included Modules

- Enumerable

### Class/Module Index

Quicksearch

- Test
- Test::Unit
- Test::Unit::AssertionFailedError
- Test::Unit::Assertions
- Test::Unit::Attribute
- Test::Unit::Attribute::BaseClassMethods
- Test::Unit::Attribute::ClassMethods
- Test::Unit::Attribute::StringifyKeyHash
- Test::Unit::AttributeMatcher
- Test::Unit::AutoRunner
- Test::Unit::CodeSnippetFetcher
- Test::Unit::Collector
- Test::Unit::Collector::Descendant
- Test::Unit::Collector::Dir
- Test::Unit::Collector::Load
- Test::Unit::Collector::ObjectSpace
- Test::Unit::Collector::XML
- Test::Unit::Collector::XML::Listener
- Test::Unit::Color
- Test::Unit::Color::Error
- Test::Unit::Color::ParseError
- Test::Unit::ColorScheme
- Test::Unit::Data
- Test::Unit::Data::ClassMethods
- Test::Unit::Data::ClassMethods::Loader
- Test::Unit::Diff
- Test::Unit::Diff::Differ
- Test::Unit::Diff::ReadableDiffer
- Test::Unit::Diff::SequenceMatcher
- Test::Unit::Diff::UTF8Line
- Test::Unit::Diff::UnifiedDiffer
- Test::Unit::Error
- Test::Unit::ErrorHandler
- Test::Unit::ExceptionHandler
- Test::Unit::ExceptionHandler::ClassMethods
- Test::Unit::Failure
- Test::Unit::FailureHandler
- Test::Unit::FaultLocationDetector
- Test::Unit::Fixture
- Test::Unit::Fixture::ClassMethods
- Test::Unit::MixColor
- Test::Unit::Notification
- Test::Unit::NotificationHandler
- Test::Unit::NotifiedError
- Test::Unit::NullResultContainerInitializer
- Test::Unit::Omission
- Test::Unit::OmissionHandler
- Test::Unit::OmittedError
- Test::Unit::PendedError
- Test::Unit::Pending
- Test::Unit::PendingHandler
- Test::Unit::Priority
- Test::Unit::Priority::Checker
- Test::Unit::Priority::ClassMethods
- Test::Unit::TestCase
- Test::Unit::TestCase::InternalData
- Test::Unit::TestCaseNotificationSupport
- Test::Unit::TestCaseOmissionSupport
- Test::Unit::TestCasePendingSupport
- Test::Unit::TestResult
- Test::Unit::TestResultErrorSupport
- Test::Unit::TestResultFailureSupport
- Test::Unit::TestResultNotificationSupport
- Test::Unit::TestResultOmissionSupport
- Test::Unit::TestResultPendingSupport
- Test::Unit::TestSuite
- Test::Unit::UI
- Test::Unit::UI::Console
- Test::Unit::UI::Console::ColorizedReadableDiffer
- Test::Unit::UI::Console::OutputLevel
- Test::Unit::UI::Console::TestRunner
- Test::Unit::UI::Emacs
- Test::Unit::UI::Emacs::TestRunner
- Test::Unit::UI::TestRunner
- Test::Unit::UI::TestRunnerMediator
- Test::Unit::UI::TestRunnerUtilities
- Test::Unit::UI::XML
- Test::Unit::UI::XML::TestRunner
- Test::Unit::Util
- Test::Unit::Util::BacktraceFilter
- Test::Unit::Util::MethodOwnerFinder
- Test::Unit::Util::Observable
- Test::Unit::Util::Output
- Test::Unit::Util::ProcWrapper
- Object

No matching classes.

# Test::Unit::ColorScheme

### Public Class Methods

[](id) click to toggle source

    # File lib/test/unit/color-scheme.rb, line 84
    def [](id)
      @@schemes[id.to_s]
    end

[]=(id, scheme_or_spec) click to toggle source

    # File lib/test/unit/color-scheme.rb, line 88
    def []=(id, scheme_or_spec)
      if scheme_or_spec.is_a?(self)
        scheme = scheme_or_spec
      else
        scheme = new(scheme_or_spec)
      end
      @@schemes[id.to_s] = scheme
    end

all() click to toggle source

    # File lib/test/unit/color-scheme.rb, line 80
    def all
      @@schemes.merge("default" => default)
    end

available_colors() click to toggle source

    # File lib/test/unit/color-scheme.rb, line 97
    def available_colors
      case ENV["COLORTERM"]
      when "gnome-terminal"
        256
      else
        case ENV["TERM"]
        when /-256color\z/
          256
        else
          8
        end
      end
    end

default() click to toggle source

    # File lib/test/unit/color-scheme.rb, line 9
    def default
      if available_colors == 256
        default_for_256_colors
      else
        default_for_8_colors
      end
    end

default_for_256_colors() click to toggle source

    # File lib/test/unit/color-scheme.rb, line 49
    def default_for_256_colors
      @@default_for_256_colors ||=
        new("pass" => Color.new("030", :background => true) +
                      Color.new("555", :bold => true),
            "failure" => Color.new("300", :background => true) +
                         Color.new("555", :bold => true),
            "pending" => Color.new("303", :background => true) +
                          Color.new("555", :bold => true),
            "omission" => Color.new("001", :background => true) +
                          Color.new("555", :bold => true),
            "notification" => Color.new("011", :background => true) +
                              Color.new("555", :bold => true),
            "error" => Color.new("000", :background => true) +
                       Color.new("550", :bold => true),
            "case" => Color.new("220", :background => true) +
                      Color.new("555", :bold => true),
            "suite" => Color.new("110", :background => true) +
                       Color.new("555", :bold => true),
            "diff-inserted-tag" => Color.new("500", :background => true) +
                                   Color.new("000", :bold => true),
            "diff-deleted-tag" => Color.new("050", :background => true) +
                                  Color.new("000", :bold => true),
            "diff-difference-tag" => Color.new("005", :background => true) +
                                     Color.new("555", :bold => true),
            "diff-inserted" => Color.new("300", :background => true) +
                               Color.new("555", :bold => true),
            "diff-deleted" =>  Color.new("030", :background => true) +
                               Color.new("555", :bold => true))
    end

default_for_8_colors() click to toggle source

    # File lib/test/unit/color-scheme.rb, line 18
    def default_for_8_colors
      @@default_for_8_colors ||=
        new("pass" => Color.new("green", :background => true) +
                      Color.new("white", :bold => true),
            "failure" => Color.new("red", :background => true) +
                         Color.new("white", :bold => true),
            "pending" => Color.new("magenta", :background => true) +
                         Color.new("white", :bold => true),
            "omission" => Color.new("blue", :background => true) +
                         Color.new("white", :bold => true),
            "notification" => Color.new("cyan", :background => true) +
                              Color.new("white", :bold => true),
            "error" => Color.new("black", :background => true) +
                       Color.new("yellow", :bold => true),
            "case" => Color.new("blue", :background => true) +
                      Color.new("white", :bold => true),
            "suite" => Color.new("green", :background => true) +
                       Color.new("white", :bold => true),
            "diff-inserted-tag" => Color.new("red", :background => true) +
                                   Color.new("black", :bold => true),
            "diff-deleted-tag" => Color.new("green", :background => true) +
                                  Color.new("black", :bold => true),
            "diff-difference-tag" => Color.new("cyan", :background => true) +
                                     Color.new("white", :bold => true),
            "diff-inserted" => Color.new("red", :background => true) +
                               Color.new("white", :bold => true),
            "diff-deleted" =>  Color.new("green", :background => true) +
                               Color.new("white", :bold => true))
    end

new(scheme_spec) click to toggle source

    # File lib/test/unit/color-scheme.rb, line 112
    def initialize(scheme_spec)
      @scheme = {}
      scheme_spec.each do |key, color_spec|
        self[key] = color_spec
      end
    end

### Public Instance Methods

[](name) click to toggle source

    # File lib/test/unit/color-scheme.rb, line 119
    def [](name)
      @scheme[name.to_s]
    end

[]=(name, color_spec) click to toggle source

    # File lib/test/unit/color-scheme.rb, line 123
    def []=(name, color_spec)
      @scheme[name.to_s] = make_color(color_spec)
    end

each(&block) click to toggle source

    # File lib/test/unit/color-scheme.rb, line 127
    def each(&block)
      @scheme.each(&block)
    end

to_hash() click to toggle source

    # File lib/test/unit/color-scheme.rb, line 131
    def to_hash
      hash = {}
      @scheme.each do |key, color|
        hash[key] = color
      end
      hash
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.