dbrady-switchy 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.rdoc +38 -0
  2. data/bin/sparky +69 -42
  3. metadata +3 -2
data/README.rdoc CHANGED
@@ -2,6 +2,44 @@
2
2
 
3
3
  Ruby Application to switch AC loads (e.g. turn a lamp on and off).
4
4
 
5
+ Update 2009-09-26: This has actually become something of a
6
+ unit-testing light dongle for me. The basic switching hardware was
7
+ finished quite early, so the only thing left to do was to add a Killer
8
+ Demo App(TM). The basic switching app is just called "switchy", and it
9
+ controls individual pins 1 through 10 on the board.
10
+
11
+ The Killer Demo, then, would be Sparky, Sparcumber, and Autospark.
12
+ Each of these has a "christmas tree" LED arrangement: Five LEDs on
13
+ each side of the device are wired for run, fail, warning, and pass.
14
+ There are two green LEDs for pass on each side, so the pinouts are:
15
+
16
+ Pins 1-5 (left side): blue, red, yellow, green, green
17
+ Pins 10-6 (right side, note reverse order because pin numbering continues
18
+ clockwise around the board): blue, red, yellow, green, green
19
+
20
+ Sparky provides an RSpec progress formatter, so that it gets updated
21
+ as each spec runs. While running it animates the LEDs to show the
22
+ current overall progress. As each spec finishes an LED of the
23
+ appropriate color lights up.
24
+
25
+ Sparky also has a generic mode. If you run "sparky foo", sparky will
26
+ turn on the running lights, then run the foo command. When foo
27
+ finishes, its exit status will be used to turn on either the red or
28
+ green lights.
29
+
30
+ Sparcumber does for Cucumber what Sparky does for RSpec. Get Cucumber
31
+ configured so you can type "cucumber" from the root of your project,
32
+ then type "sparcumber" instead. Sparcumber will light up the board as
33
+ Cucumber runs.
34
+
35
+ Autospark is currently vaporware. All it should do is hook sparky into
36
+ autospec. Patches are welcome. There is a spec.sparky.opts file in the
37
+ res folder, however, that will achieve this for now, but it does cause
38
+ your project to take a dependency on sparky, which in turn requires
39
+ having the hardware dongle connected to run your specs, which is less
40
+ than agile.
41
+
42
+
5
43
  = Example
6
44
 
7
45
  == Command-line Apps
data/bin/sparky CHANGED
@@ -1,52 +1,79 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # TODO! This, along with switchy, needs to be made into a rubygem!
4
- # Others may have difficulty using this in a portable fashion without
5
- # a /Users/dbrady folder, for example...
6
-
7
- def show_run
8
- # system "switchy 1 0 2 1 3 1 4 1"
9
- system "switchy 1 1 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 1"
10
- end
11
2
 
12
- def show_fail
13
- system "switchy 1 0 2 1 3 0 4 0 5 0 6 0 7 0 8 0 9 1 10 0"
14
- end
3
+ class Sparky
4
+ def show_run
5
+ # system "switchy 1 0 2 1 3 1 4 1"
6
+ system "switchy 1 1 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 1"
7
+ end
15
8
 
16
- def show_pending
17
- system "switchy 1 0 2 0 3 1 4 0 5 0 6 0 7 0 8 1 9 0 10 0"
18
- end
9
+ def show_fail
10
+ system "switchy 1 0 2 1 3 0 4 0 5 0 6 0 7 0 8 0 9 1 10 0"
11
+ end
19
12
 
20
- def show_pass
21
- system "switchy 1 0 2 0 3 0 4 1 5 1 6 1 7 1 8 0 9 0 10 0"
22
- end
13
+ def show_pending
14
+ system "switchy 1 0 2 0 3 1 4 0 5 0 6 0 7 0 8 1 9 0 10 0"
15
+ end
23
16
 
24
- def show_reset
25
- system "switchy 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0"
17
+ def show_pass
18
+ system "switchy 1 0 2 0 3 0 4 1 5 1 6 1 7 1 8 0 9 0 10 0"
19
+ end
20
+
21
+ def show_reset
22
+ system "switchy 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0"
23
+ end
24
+
25
+ def show_all
26
+ system "switchy 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1"
27
+ end
28
+
29
+ def show_selftest
30
+ show_reset
31
+
32
+ show_all
33
+ sleep 1.0
34
+ show_reset
35
+
36
+ 1.upto(10) do |i|
37
+ system "switchy #{i} 1"
38
+ system "switchy #{i} 0"
39
+ end
40
+
41
+ %w(run fail pending pass).each do |msg|
42
+ send "show_#{msg}"
43
+ sleep 0.5
44
+ end
45
+ sleep 0.5
46
+ show_reset
47
+ end
26
48
  end
27
49
 
28
- case ARGV[0].downcase
29
- when "reset" then show_reset
30
- when "pending" then show_pending
31
- when "fail" then show_fail
32
- when "pass" then show_pass
33
- when "run" then show_run
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)
40
- else
41
- # TODO: If spec or rake spec:*, bind formatter
42
- # TODO: If autospec, bind formatter
43
- show_run
44
-
45
- cmd = ARGV.map {|a| '"' + a.gsub(/"/, '\"') + '"' } * ' '
46
-
47
- if system(cmd)
48
- show_pass
50
+ if __FILE__==$0
51
+ s = Sparky.new
52
+
53
+ case ARGV[0].downcase
54
+ when "reset" then s.show_reset
55
+ when "pending" then s.show_pending
56
+ when "fail" then s.show_fail
57
+ when "pass" then s.show_pass
58
+ when "run" then s.show_run
59
+ when "test" then s.show_test
60
+ when "selftest" then s.show_selftest
61
+ when "spec"
62
+ lib_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'sparky_progress_formatter.rb'))
63
+ args = ARGV[1..-1].dup.map {|a| '"' + a.gsub(/"/, '\"') + '"' } * ' '
64
+ cmd = "spec --require #{lib_path} --format Spec::Runner::Formatter::SparkyProgressFormatter #{args}"
65
+ system(cmd)
49
66
  else
50
- show_fail
67
+ # TODO: If spec or rake spec:*, bind formatter
68
+ # TODO: If autospec, bind formatter
69
+ s.show_run
70
+
71
+ cmd = ARGV.map {|a| '"' + a.gsub(/"/, '\"') + '"' } * ' '
72
+
73
+ if system(cmd)
74
+ s.show_pass
75
+ else
76
+ s.show_fail
77
+ end
51
78
  end
52
79
  end
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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Brady
@@ -46,6 +46,7 @@ files:
46
46
  - MIT-LICENSE
47
47
  has_rdoc: true
48
48
  homepage: http://github.com/dbrady/switchy
49
+ licenses:
49
50
  post_install_message:
50
51
  rdoc_options:
51
52
  - --line-numbers
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
72
  requirements: []
72
73
 
73
74
  rubyforge_project:
74
- rubygems_version: 1.2.0
75
+ rubygems_version: 1.3.5
75
76
  signing_key:
76
77
  specification_version: 2
77
78
  summary: Switchy USB serial load switcher