From 628ec101c7db22514d7687446875f4f399a6838a Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Tue, 6 Aug 2013 06:34:42 +1000
Subject: [PATCH] minor refactoring

---
 lib/autospec/runner.rb | 47 ++++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/lib/autospec/runner.rb b/lib/autospec/runner.rb
index c0a35044e8f..b5d5027e3ca 100644
--- a/lib/autospec/runner.rb
+++ b/lib/autospec/runner.rb
@@ -19,7 +19,7 @@ class Autospec::Runner
   watch(%r{^app/(.*)(\.erb|\.haml)$})                 { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
   watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
   watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
-  watch('app/controllers/application_controller.rb')  { "spec/controllers" }
+  watch("app/controllers/application_controller.rb")  { "spec/controllers" }
 
   # Capybara request specs
   watch(%r{^app/views/(.+)/.*\.(erb|haml)$})          { |m| "spec/requests/#{m[1]}_spec.rb" }
@@ -85,27 +85,7 @@ class Autospec::Runner
     end
 
     while spork_running
-
-      STDIN.gets
-
-      if @queue.length == 0
-        @queue << ['spec', 'spec']
-        @signal.signal
-      else
-        specs = failed_specs(:delete => false)
-        puts
-        puts
-        if specs.length == 0
-          puts "No specs have failed yet!"
-          puts
-        else
-          puts "The following specs have failed: "
-          specs.each do |s|
-            puts s
-          end
-          puts
-        end
-      end
+      process_queue
     end
 
     puts "Spork has been terminated, exiting"
@@ -116,6 +96,29 @@ class Autospec::Runner
     stop_spork
   end
 
+  def process_queue
+    STDIN.gets
+
+    if @queue.length == 0
+      @queue << ['spec', 'spec']
+      @signal.signal
+    else
+      specs = failed_specs(:delete => false)
+      puts
+      puts
+      if specs.length == 0
+        puts "No specs have failed yet!"
+        puts
+      else
+        puts "The following specs have failed: "
+        specs.each do |s|
+          puts s
+        end
+        puts
+      end
+    end
+  end
+
   def wait_for(timeout_milliseconds)
     timeout = (timeout_milliseconds + 0.0) / 1000
     finish = Time.now + timeout