dbrady-switchy 0.0.6 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -152,3 +152,23 @@ TODO: Write me!
152
152
  on red light and leave it on.
153
153
  * Blink RGB yellow by seting Red and Green to blink. (Need to build
154
154
  the system to permit synchronous blink rates.)
155
+
156
+ * 2009-04-20: Review previous TODOs in light of first finished
157
+ prototype.
158
+
159
+ * Change progress formatter lights, and light up only one
160
+ pass/fail/pending LED as specs run. As each example completes,
161
+ animate the display by moving the the one led to another spot. So if
162
+ all your specs are passing, you'll see the green light move 1 -> 2
163
+ -> 3 -> 4 -> 1 -> 2 etc. If you have any pending specs, they will
164
+ light up 1 -> 2 -> 1 -> 2 etc. When the test finishes, light up all
165
+ the status lights of the appropriate color.
166
+
167
+ * As a potential addition, light up one of EACH status color as they
168
+ occur. So you might have Pass light 3, Pending light 2, and Fail
169
+ light 1 lit. As each example completes, animate the status light for
170
+ that example's color. Then, when it's finished, turn on all status
171
+ lights for the final pass/pend/fail status and turn off all other
172
+ lights.
173
+
174
+
data/bin/sparky CHANGED
@@ -32,7 +32,14 @@ when "fail" then show_fail
32
32
  when "pass" then show_pass
33
33
  when "run" then show_run
34
34
  when "test" then show_test
35
+ when "spec"
36
+ lib_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'sparky_progress_formatter.rb'))
37
+ args = ARGV[1..-1].dup.map {|a| '"' + a.gsub(/"/, '\"') + '"' } * ' '
38
+ cmd = "spec --require #{lib_path} --format Spec::Runner::Formatter::SparkyProgressFormatter #{args}"
39
+ system(cmd)
35
40
  else
41
+ # TODO: If spec or rake spec:*, bind formatter
42
+ # TODO: If autospec, bind formatter
36
43
  show_run
37
44
 
38
45
  cmd = ARGV.map {|a| '"' + a.gsub(/"/, '\"') + '"' } * ' '
data/lib/sparky.rb ADDED
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env ruby
2
+ dir = File.expand_path(File.dirname(__FILE__))
3
+ $: << dir unless $:.include?(dir)
4
+ require 'switchy'
5
+
6
+ class Sparky
7
+ attr_accessor :passed, :failed, :pending
8
+
9
+ @@run_pins = [[Switchy::PINS::C4, Switchy::PINS::C2], [Switchy::PINS::C5, Switchy::PINS::D0 ]]
10
+ @@fail_pins = [[Switchy::PINS::C6, Switchy::PINS::D1], [Switchy::PINS::C7, Switchy::PINS::D2]]
11
+ @@pending_pins = [[Switchy::PINS::B7, Switchy::PINS::D3], [Switchy::PINS::B6, Switchy::PINS::D4]]
12
+ @@pass_pins = [[Switchy::PINS::B3, Switchy::PINS::D7, Switchy::PINS::B5, Switchy::PINS::D5],
13
+ [Switchy::PINS::B2, Switchy::PINS::B0, Switchy::PINS::B4, Switchy::PINS::D6]]
14
+
15
+ @@reset_pins = [[Switchy::PINS::C4, Switchy::PINS::C2,
16
+ Switchy::PINS::C6, Switchy::PINS::D1,
17
+ Switchy::PINS::B7, Switchy::PINS::D3,
18
+ Switchy::PINS::B5, Switchy::PINS::B3,
19
+ Switchy::PINS::D7, Switchy::PINS::D5]]
20
+ def initialize
21
+ @passed, @failed, @pending = -1, -1, -1
22
+ @switchy = Switchy.new
23
+ end
24
+
25
+ def set_pins(pins)
26
+ pins.first.each do |pin|
27
+ @switchy.set_pin pin, 1
28
+ end
29
+ pins.last.each do |pin|
30
+ @switchy.set_pin pin, 0
31
+ end
32
+ end
33
+
34
+ def set_pin(pin)
35
+ @switchy.set_pin pin.first, 1
36
+ @switchy.set_pin pin.last, 0
37
+ end
38
+
39
+ def clear_pin(pin)
40
+ @switchy.set_pin pin.first, 0
41
+ end
42
+
43
+ def clear_pins(pins)
44
+ pins.first.each do |pin|
45
+ @switchy.set_pin pin, 0
46
+ end
47
+ end
48
+
49
+ def pass
50
+ set_pins @@pass_pins
51
+ end
52
+
53
+ def clear_pass
54
+ clear_pins @@pass_pins
55
+ end
56
+
57
+ def failed
58
+ set_pins @@fail_pins
59
+ end
60
+
61
+ def clear_failed
62
+ clear_pins @@fail_pins
63
+ end
64
+
65
+ def pending
66
+ set_pins @@pending_pins
67
+ end
68
+
69
+ def clear_pending
70
+ clear_pins @@pending_pins
71
+ end
72
+
73
+ def run
74
+ set_pins @@run_pins
75
+ end
76
+
77
+ def clear_run
78
+ clear_pins @@run_pins
79
+ end
80
+
81
+ def reset
82
+ clear_pins @@reset_pins
83
+ end
84
+
85
+ def start_run
86
+ reset
87
+ run
88
+ end
89
+
90
+ def finish_run
91
+ reset
92
+ if @failed > -1
93
+ failed
94
+ elsif @pending > -1
95
+ pending
96
+ else
97
+ pass
98
+ end
99
+ end
100
+
101
+ def example_passed
102
+ clear_pin pin(:passed, @passed % 4) if @passed >= 0
103
+ @passed += 1
104
+ set_pin pin(:passed, @passed % 4)
105
+ end
106
+
107
+ def example_failed
108
+ clear_pin pin(:failed, @failed % 2) if @failed >= 0
109
+ @failed += 1
110
+ set_pin pin(:failed, @failed % 2)
111
+ end
112
+
113
+ def example_pending
114
+ clear_pin pin(:pending, @pending % 2) if @pending >= 0
115
+ @pending += 1
116
+ set_pin pin(:pending, @pending % 2)
117
+ end
118
+
119
+ def pin(set, idx)
120
+ pins = case set
121
+ when :passed then @@pass_pins
122
+ when :failed then @@fail_pins
123
+ when :pending then @@pending_pins
124
+ end
125
+ [ pins.first[idx], pins.last[idx] ]
126
+ end
127
+ end
128
+
@@ -0,0 +1,43 @@
1
+ require 'rubygems'
2
+ require 'spec/runner/formatter/progress_bar_formatter'
3
+ $: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ require 'sparky'
5
+
6
+ module Spec
7
+ module Runner
8
+ module Formatter
9
+ class SparkyProgressFormatter < ProgressBarFormatter
10
+ @@anything_failed_ever = false
11
+ @@anything_pended_ever = false
12
+
13
+ def initialize(a,b)
14
+ super
15
+ @sparky = Sparky.new
16
+ @sparky.start_run
17
+ end
18
+
19
+ def start_dump
20
+ @sparky.finish_run
21
+ super
22
+ end
23
+
24
+ def example_passed(example)
25
+ @sparky.example_passed
26
+ super
27
+ end
28
+
29
+ def example_failed(example, counter, failure)
30
+ @@anything_failed_ever = true
31
+ @sparky.example_failed
32
+ super
33
+ end
34
+
35
+ def example_pending(example, message)
36
+ @@anything_pended_ever = true
37
+ @sparky.example_pending
38
+ super
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,6 @@
1
+ --colour
2
+ --require /Library/Ruby/Gems/1.8/gems/switchy-0.1.0/lib/sparky_progress_formatter.rb
3
+ --format Spec::Runner::Formatter::SparkyProgressFormatter
4
+ --loadby mtime
5
+ --reverse
6
+ --backtrace
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbrady-switchy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Brady
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-17 00:00:00 -07:00
12
+ date: 2009-04-19 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -33,8 +33,11 @@ extra_rdoc_files:
33
33
  - README.rdoc
34
34
  - MIT-LICENSE
35
35
  files:
36
- - bin/switchy
37
36
  - bin/sparky
37
+ - bin/switchy
38
+ - lib/sparky.rb
39
+ - lib/sparky_progress_formatter.rb
40
+ - res/spec.sparky.opts
38
41
  - lib/switchy.rb
39
42
  - README.rdoc
40
43
  - MIT-LICENSE