blink1-formatter 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,6 +11,10 @@ Or add to `.rspec` file
11
11
  --format progress
12
12
  --format Blink1Formatter
13
13
 
14
+ == Installing
15
+
16
+ gem install blink1-formatter
17
+
14
18
  == Author
15
19
 
16
20
  - {Atsushi Nagase}[http://ngs.io/]
@@ -4,48 +4,49 @@ require "rspec/core/formatters/base_formatter"
4
4
  class Blink1Formatter < RSpec::Core::Formatters::BaseFormatter
5
5
 
6
6
  COLOR_SUCCESS = [0, 255, 35]
7
- COLOR_PENDING = [255, 240, 6]
8
- COLOR_FAIL = [255, 7, 29]
9
-
7
+ COLOR_PENDING = [255, 200, 0]
8
+ COLOR_FAIL = [255, 10, 30]
9
+
10
10
  def example_passed(example)
11
- unless @color
12
- @color = COLOR_SUCCESS
13
- update_color
14
- end
11
+ self.color= COLOR_SUCCESS if self.color.eql?(COLOR_SUCCESS)
15
12
  super(example)
16
13
  end
17
14
 
18
15
  def example_pending(example)
19
- if @color == COLOR_SUCCESS
20
- @color = COLOR_PENDING
21
- update_color
22
- end
16
+ self.color= COLOR_PENDING unless self.color.eql?(COLOR_FAIL)
23
17
  super(example)
24
18
  end
25
19
 
26
20
  def example_failed(example)
27
- if @color != COLOR_FAIL
28
- @color = COLOR_FAIL
29
- update_color
30
- end
21
+ self.color= COLOR_FAIL
31
22
  super(example)
32
23
  end
33
24
 
34
25
  def dump_summary(duration, example_count, failure_count, pending_count)
35
- @blink1.blink(@color[0], @color[1], @color[2], 2)
36
- @blink1.fade_to_rgb(500, @color[0], @color[1], @color[2])
37
26
  super(duration, example_count, failure_count, pending_count)
27
+ blink1.blink(color[0], color[1], color[2], 2)
28
+ blink1.fade_to_rgb(500, color[0], color[1], color[2])
38
29
  end
39
30
 
40
- private
41
-
42
- def update_color
43
- unless @blink1
44
- @blink1 = Blink1.new
45
- @blink1.open
46
- end
47
- @blink1.fade_to_rgb(300, @color[0], @color[1], @color[2])
31
+ def blink1
32
+ unless @blink1
33
+ @blink1 = Blink1.new
34
+ @blink1.open
48
35
  end
36
+ @blink1
37
+ end
38
+
39
+ def color= c
40
+ unless c.eql?(@color)
41
+ @color = c
42
+ blink1.fade_to_rgb(300, c[0], c[1], c[2])
43
+ end
44
+ c
45
+ end
46
+
47
+ def color
48
+ @color || COLOR_SUCCESS
49
+ end
49
50
 
50
51
 
51
- end
52
+ end
@@ -1,3 +1,3 @@
1
1
  class Blink1Formatter
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blink1-formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-18 00:00:00.000000000 Z
12
+ date: 2012-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler