Permalink
Browse files

adding autotest hook

git-svn-id: svn+ssh://rubyforge.org/var/svn/betabrite/trunk@31 32089d7b-f314-0410-b504-a527b3b390a0
  • Loading branch information...
aaronp
aaronp committed Feb 12, 2008
1 parent 1333df0 commit be080b26e9c764fe29fa65314595b3fefce3d7c8
Showing with 49 additions and 1 deletion.
  1. +7 −0 .autotest
  2. +2 −1 History.txt
  3. +1 −0 Manifest.txt
  4. +13 −0 README.txt
  5. +22 −0 lib/betabrite/autotest.rb
  6. +3 −0 lib/betabrite/string.rb
  7. +1 −0 test/test_string.rb
View
@@ -0,0 +1,7 @@
+require 'betabrite/autotest'
+require 'usb'
+
+Autotest::BetaBrite.hook(BetaBrite::USB) do |failures, erorrs|
+ failures.rgb('0000FF') if failures.green?
+end
+
View
@@ -1,8 +1,9 @@
=== 1.0.0
-* 2 Major Enhancements:
+* 3 Major Enhancements:
* Adding support for USB betabrite signs (Thanks Thought Hammer)
+ * Added an autotest hook
* Changed API to use more DSL type interface
=== 0.0.2
View
@@ -5,6 +5,7 @@ Manifest.txt
README.txt
Rakefile
lib/betabrite.rb
+lib/betabrite/autotest.rb
lib/betabrite/base.rb
lib/betabrite/files.rb
lib/betabrite/files/dots.rb
View
@@ -34,6 +34,19 @@ Here is an example of modifying the default sign text:
end
bb.write!
+== Autotest Support
+Here is an example of a .autotest file using the BetaBrite module:
+
+ require 'betabrite/autotest'
+ require 'usb'
+
+ Autotest::BetaBrite.hook(BetaBrite::USB) do |failures, erorrs|
+ failures.rgb('0000FF') if failures.green?
+ end
+
+You don't need to give the hook method a block, but you can if you'd like to
+customize your messages.
+
== Allocating Memory
The memory in the BetaBrite sign should be configured before anything is
written to it. You only have to configure the memory once before writing to
View
@@ -0,0 +1,22 @@
+require 'betabrite'
+
+module Autotest::BetaBrite
+ def self.hook(klass, *args, &block)
+ Autotest.add_hook :ran_command do |at|
+ if at.results.last =~ /^.* (\d+) failures, (\d+) errors$/
+ bb = klass.new(*args) do |sign|
+ sign.textfile do
+ failures = string("#{$1} failures").red
+ errors = string(" #{$2} errors").red
+ failures.green if $1 == '0'
+ errors.green if $2 == '0'
+ block.call(failures, errors) if block
+ print failures
+ print errors
+ end
+ end
+ bb.write!
+ end
+ end
+ end
+end
View
@@ -98,6 +98,9 @@ def to_s
@color = Color.const_get(constant)
self
end
+ define_method(:"#{constant.downcase}?") do
+ @color == Color.const_get(constant)
+ end
end
CharSet.constants.each do |constant|
View
@@ -25,6 +25,7 @@ def test_parse
assert_equal(2, parsed.length)
assert parsed.all? { |x| x.is_a?(BetaBrite::String) }
assert_equal BetaBrite::String::Color::GREEN, parsed[0].color
+ assert parsed[0].green?
assert_equal 'FF00FF', parsed[1].color
assert_equal 'foo', parsed[0].string
assert_equal 'bar', parsed[1].string

0 comments on commit be080b2

Please sign in to comment.