<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>images/bad.png</filename>
    </added>
    <added>
      <filename>images/good.png</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1,13 @@
+def growl(message, image)
+  message.gsub!(&quot;'&quot;,'')
+  message.strip!
+  system &quot;growlnotify -n 'Beholder' -m '#{message}' --image #{image}&quot; 
+end
+
 Beholder.runner = 'spec --options spec/spec.opts --require spec/setup.rb'
+Beholder.on_success = lambda do |output| 
+  growl 'It is all good, in the applebees neighborhood', '/Users/chad/Projects/spicycode/spicycode-beholder/images/good.png'
+end
+Beholder.on_failure = lambda do |output| 
+  growl output, '/Users/chad/Projects/spicycode/spicycode-beholder/images/bad.png'
+end</diff>
      <filename>.treasure_map.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,12 +5,17 @@ class Beholder
   DEFAULT_RUNNER = 'ruby'
 
   class &lt;&lt; self
-    attr_writer :runner, :test_types, :possible_treasure_map_locations
-    
+    attr_writer :test_types, :possible_treasure_map_locations
+    attr_accessor :on_success, :on_failure 
+
     def runner
       @runner ||= ::Beholder::DEFAULT_RUNNER
     end
 
+    def runner=(new_runner)
+      @runner = new_runner
+    end
+
     def possible_treasure_map_locations
       @possible_treasure_map_locations ||= [&quot;#{Dir.pwd}/.treasure_map.rb&quot;, &quot;#{Dir.pwd}/treasure_map.rb&quot;, &quot;#{Dir.pwd}/config/treasure_map.rb&quot;]
     end
@@ -79,12 +84,7 @@ class Beholder
     @current_map = nil
   end
   
-  def default_options
-    { :command =&gt; ::Beholder.runner }
-  end
-
   def prepare_spell_for(pattern, options = {}, &amp;blk)
-    options = default_options.merge(options)
     @current_map &lt;&lt; [pattern, options, blk]
   end
 
@@ -105,18 +105,20 @@ class Beholder
   def on_change(paths)
     say &quot;#{paths} changed&quot; unless paths.nil? || paths.empty?
 
-    treasure_maps_changed = paths.select { |p| ::Beholder.possible_treasure_map_locations.include?(p) }
-    treasure_maps_changed.each {|map_path| read_map_at(map_path) }
-
+    paths.reject! { |path| ::Beholder.possible_treasure_map_locations.include?(path) }
     runners_with_paths = {}
+
     paths.each do |path| 
-      find_and_populate_matches(path, runners_with_paths) 
-    end  
+      runner, tests = *find_and_populate_matches(path)
+      next if tests.nil? || tests.empty?
 
-    runners_with_paths.each do |runner, paths| 
-      paths.uniq!
-      paths.compact!
-    end
+      tests.uniq!
+      tests.compact!
+
+      if tests.any?
+        runners_with_paths[runner] = tests
+      end
+    end  
 
     run_tests runners_with_paths
   end
@@ -160,7 +162,7 @@ class Beholder
         puts &quot;   Did you just send me an INT? Ugh.  I'll quit for real if you do it again.&quot;
         @sent_an_int = true
         Kernel.sleep 1.5
-        run_tests ::Beholder.runner =&gt; ::Beholder.all_tests
+        run_tests nil =&gt; ::Beholder.all_tests
       end
     end
   end    
@@ -203,16 +205,12 @@ class Beholder
     @sent_an_int = false
   end
 
-  def find_and_populate_matches(path, runners_with_paths)
+  def find_and_populate_matches(path)
     treasure_maps.each do |name, map|
       map.each do |pattern, options, blk|
-        run_using = options[:command]
-
         if match = path.match(pattern)
           say &quot;Found the match for #{path} using the #{name} map &quot;
-          runners_with_paths[run_using] ||= []
-          runners_with_paths[run_using].concat(blk.call(match))
-          return
+          return [options[:command], blk.call(match)]
         end
       end
     end
@@ -226,7 +224,14 @@ class Beholder
     return if runners_with_paths.empty?
 
     runners_with_paths.each do |runner, paths|
-      system build_cmd(runner, paths)
+      runner ||= ::Beholder.runner
+      result = %x{#{build_cmd(runner, paths)}}
+      puts result
+      if $?.exitstatus.zero?
+        ::Beholder.on_success &amp;&amp; ::Beholder.on_success.call(result) 
+      else
+        ::Beholder.on_failure &amp;&amp; ::Beholder.on_failure.call(result) 
+      end
     end
     
     blink
@@ -235,6 +240,9 @@ class Beholder
   private
 
   def remove_runners_with_no_valid_files_to_run(runners_with_paths)
+    return [] if runners_with_paths.nil?
+    require 'pp'
+    pp runners_with_paths
     runners_with_paths.each do |runner, paths|
       paths.reject! do |path|
         found_treasure = File.exist?(path)</diff>
      <filename>lib/beholder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,6 @@ describe Beholder do
   end
 
   describe &quot;when run is called&quot; do
-    
     it &quot;should create a new beholder&quot; do
       beholder = stub(Beholder.new) { prepare; start }
       mock(Beholder).new { beholder }
@@ -42,26 +41,15 @@ describe Beholder do
       
       Beholder.run
     end
-    
   end
   
   describe &quot;when it notices file(s) changed&quot; do
-    
     it &quot;should identify what was changed&quot; do
       files = ['widgets'] 
       beholder = Beholder.new
-      mock(beholder).find_and_populate_matches('widgets', {}) { nil }
+      mock(beholder).find_and_populate_matches('widgets') { nil }
       beholder.on_change files
     end
-    
-    it &quot;should re-eval the treasure map if the map was modified&quot; do
-      treasure_map = &quot;#{Dir.pwd}/.treasure_map.rb&quot;
-      beholder = Beholder.new
-      stub(File).exist?(treasure_map) { true }
-      mock(beholder).read_map_at(treasure_map)
-      beholder.on_change treasure_map
-    end
-    
   end
   
   describe &quot;build_cmd&quot; do
@@ -74,11 +62,9 @@ describe Beholder do
       beholder = Beholder.new
       beholder.build_cmd(&quot;ruby&quot;, [&quot;test/foo_test.rb&quot;, &quot;test/functionals/foo_test.rb&quot;]).should == %[ruby test/foo_test.rb test/functionals/foo_test.rb]
     end
-    
   end
   
   describe &quot;blink&quot; do
-    
     it &quot;should forget about any interlopers&quot; do
       beholder = Beholder.new
       beholder.instance_variable_set(&quot;@sent_an_int&quot;, true) # Not so hot, but I'm tired
@@ -87,11 +73,9 @@ describe Beholder do
       beholder.__send__ :blink
       beholder.sent_an_int.should be_false
     end
-    
   end
   
   describe &quot;when shutting down&quot; do
-    
     it &quot;should stop watching for changes&quot;  do
       beholder = Beholder.new
       stub(beholder).exit
@@ -105,11 +89,9 @@ describe Beholder do
       mock(beholder).exit
       beholder.shutdown
     end
-    
   end
   
   describe &quot;watch&quot; do
-    
     it &quot;adds paths to watch&quot; do
       beholder = Beholder.new
       beholder.watch &quot;bar&quot;, &quot;foo&quot;
@@ -141,6 +123,7 @@ describe Beholder do
       # This is not ideal
       # currently returns array, array 
       beholder.treasure_maps[:example].first.first.should == %r%example_helper\.rb% 
+      1.should == 3
     end
     
     # it &quot;adds mapping using default command of ruby&quot; do
@@ -152,7 +135,6 @@ describe Beholder do
   end
   
   describe &quot;tests_matching&quot; do
-
     it &quot;finds a fuzzy match from all tests&quot; do
       beholder = Beholder.new
       stub(Beholder).all_tests { [&quot;spec/unit/bar_example.rb&quot;, &quot;src/foo_system_example.rb&quot;, &quot;spec/some/deeper/dir/foo_example.rb&quot;] }
@@ -161,7 +143,6 @@ describe Beholder do
   end
   
   describe &quot;read_map_at&quot; do
-    
     it &quot;rescues exceptions from instance_eval'ing the map, and carries on&quot; do
       beholder = Beholder.new
       stub(File).exist? { true }
@@ -169,11 +150,9 @@ describe Beholder do
       stub(beholder).puts
       lambda { beholder.read_map_at(&quot;my_map.rb&quot;) }.should_not raise_error
     end
-    
   end
   
   describe &quot;say&quot; do
-    
     it &quot;puts to stdout if verbose is true&quot; do
       begin 
         ARGV.push(&quot;-v&quot;)</diff>
      <filename>spec/beholder_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>82cc140f72e2eebca9d407031e52a3861fdef702</id>
    </parent>
  </parents>
  <author>
    <name>Chad Humphries</name>
    <email>chad@spicycode.com</email>
  </author>
  <url>http://github.com/spicycode/beholder/commit/3cf82368bed30c4bdd0de30539dac9a50f821830</url>
  <id>3cf82368bed30c4bdd0de30539dac9a50f821830</id>
  <committed-date>2009-10-09T10:50:41-07:00</committed-date>
  <authored-date>2009-10-09T10:50:41-07:00</authored-date>
  <message>In progress magic</message>
  <tree>58a540e3e495843daa412084cb74b9c25ebcedae</tree>
  <committer>
    <name>Chad Humphries</name>
    <email>chad@spicycode.com</email>
  </committer>
</commit>
