Class: Test::Unit::ColorScheme
- Inherits:
-
Object
- Object
- Test::Unit::ColorScheme
- Includes:
- Enumerable
- Defined in:
- lib/test/unit/color-scheme.rb
Constant Summary collapse
- @@default =
nil
- @@schemes =
{}
Class Method Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, color_spec) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(scheme_spec) ⇒ ColorScheme
constructor
A new instance of ColorScheme.
- #to_hash ⇒ Object
Constructor Details
#initialize(scheme_spec) ⇒ ColorScheme
Returns a new instance of ColorScheme.
59 60 61 62 63 64 |
# File 'lib/test/unit/color-scheme.rb', line 59 def initialize(scheme_spec) @scheme = {} scheme_spec.each do |key, color_spec| self[key] = color_spec end end |
Class Method Details
.[](id) ⇒ Object
45 46 47 |
# File 'lib/test/unit/color-scheme.rb', line 45 def [](id) @@schemes[id.to_s] end |
.[]=(id, scheme_or_spec) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/test/unit/color-scheme.rb', line 49 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 ⇒ Object
41 42 43 |
# File 'lib/test/unit/color-scheme.rb', line 41 def all @@schemes.merge("default" => default) end |
.default ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/test/unit/color-scheme.rb', line 10 def default @@default ||= new("pass" => Color.new("green", :foreground => false) + Color.new("white", :bold => true), "failure" => Color.new("red", :foreground => false) + Color.new("white", :bold => true), "pending" => Color.new("magenta", :bold => true), "omission" => Color.new("blue", :bold => true), "notification" => Color.new("cyan", :bold => true), "error" => Color.new("yellow", :bold => true) + Color.new("black", :foreground => false), "case" => Color.new("white", :bold => true) + Color.new("blue", :foreground => false), "suite" => Color.new("white", :bold => true) + Color.new("green", :foreground => false), "diff-inserted-tag" => Color.new("red", :bold => true), "diff-deleted-tag" => Color.new("green", :bold => true), "diff-difference-tag" => Color.new("cyan", :bold => true), "diff-inserted" => Color.new("red", :foreground => false) + Color.new("white", :bold => true), "diff-deleted" => Color.new("green", :foreground => false) + Color.new("white", :bold => true)) end |
Instance Method Details
#[](name) ⇒ Object
66 67 68 |
# File 'lib/test/unit/color-scheme.rb', line 66 def [](name) @scheme[name.to_s] end |
#[]=(name, color_spec) ⇒ Object
70 71 72 |
# File 'lib/test/unit/color-scheme.rb', line 70 def []=(name, color_spec) @scheme[name.to_s] = make_color(color_spec) end |
#each(&block) ⇒ Object
74 75 76 |
# File 'lib/test/unit/color-scheme.rb', line 74 def each(&block) @scheme.each(&block) end |
#to_hash ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/test/unit/color-scheme.rb', line 78 def to_hash hash = {} @scheme.each do |key, color| hash[key] = color end hash end |