Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First import

  • Loading branch information...
commit e77ec38819c795995c2105acd3d29fe1c495017d 0 parents
@topfunky authored
6 History.txt
@@ -0,0 +1,6 @@
+=== 1.0.0 / 2010-03-09
+
+* 1 major enhancement
+
+ * Birthday!
+
7 Manifest.txt
@@ -0,0 +1,7 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+bin/stakeout
+lib/stakeout.rb
+test/test_stakeout.rb
48 README.txt
@@ -0,0 +1,48 @@
+= stakeout
+
+* FIX (url)
+
+== DESCRIPTION:
+
+Watches files and runs a command when files change.
+
+== FEATURES/PROBLEMS:
+
+* WIP: Will use OS-specific polling soon...
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2010 Topfunky Corporation
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 Rakefile
@@ -0,0 +1,12 @@
+# -*- ruby -*-
+
+require 'rubygems'
+require 'hoe'
+require './lib/stakeout.rb'
+
+Hoe.new('stakeout', Stakeout::VERSION) do |p|
+ # p.rubyforge_name = 'stakeoutx' # if different than lowercase project name
+ # p.developer('FIX', 'FIX@example.com')
+end
+
+# vim: syntax=Ruby
111 bin/stakeout
@@ -0,0 +1,111 @@
+#!/usr/bin/env ruby
+
+##
+# Originally from http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/Monitor/StakingOutFileChanges.rdoc
+# Modified by Geoffrey Grosenbach http://peepcode.com
+#
+# Watches files and runs a command when any of them are modified.
+#
+# If one argment is given, will run that command and watch app, lib, test, spec.
+#
+# rstakeout "ruby test/functional/models/order.rb"
+# => watches app/**/* lib/**/* test/**/* spec/**/*
+#
+# Can use Ruby's Dir[] to get file glob. Quote your args to take advantage of this.
+#
+# rstakeout 'rake test:recent' **/*.rb
+# => Only watches Ruby files one directory down
+#
+# rstakeout 'rake test:recent' '**/*.rb'
+# => Watches all Ruby files in all directories and subdirectories
+
+def growl(title, msg, img, pri=0, sticky="")
+ msg.gsub!(/\e\[\d+\w/, '') # Remove terminal color codes
+ system "growlnotify -n autotest --image ~/.autotest_images/#{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
+end
+
+def self.growl_fail(output)
+ growl "FAIL", "#{output}", "fail.png", 2
+end
+
+def self.growl_pass(output)
+ growl "Pass", "#{output}", "pass.png"
+end
+
+command = ARGV.shift
+file_patterns_to_watch = (ARGV.length > 0 ? ARGV : ['app/**/*', 'config/**/*', 'lib/**/*', 'test/**/*', 'spec/**/*', 'features/**/*'])
+
+files = {}
+
+file_patterns_to_watch.each do |arg|
+ Dir[arg].each { |file|
+ files[file] = File.mtime(file)
+ }
+end
+
+puts "Watching #{files.keys.join(', ')} [#{files.keys.length}]\n\n"
+puts "Will run: #{command}\n\n"
+
+trap('INT') do
+ puts "\nQuitting..."
+ exit
+end
+
+
+loop do
+
+ sleep 1
+
+ changed_file, last_changed = files.find { |file, last_changed|
+ File.mtime(file) > last_changed
+ }
+
+ if changed_file
+ files[changed_file] = File.mtime(changed_file)
+ next unless File.file?(changed_file)
+ puts "=> #{changed_file} changed, running #{command}"
+ results = `#{command}`
+ puts results
+
+ if results.include?('note: Completed tests for architectures')
+ # Objective-C
+ # ** BUILD SUCCEEDED **
+ output = results.slice(/\*\* BUILD SUCCEEDED \*\*/)
+ if output
+ growl_pass("SUCCEEDED")
+ else
+ growl_fail("FAILED")
+ end
+ elsif results.include? 'tests'
+ # Test/Unit
+ output = results.slice(/(\d+)\s+tests?,\s*(\d+)\s+assertions?,\s*(\d+)\s+failures?(,\s*(\d+)\s+errors)?/)
+ if output
+ $~[3].to_i + $~[5].to_i > 0 ? growl_fail(output) : growl_pass(output)
+ end
+ elsif results.include? "steps"
+ # Cucumber
+ # 1 scenario (1 pending)
+ # 3 steps (1 skipped, 1 undefined, 1 pending)
+ output = results.slice(/^(\d+) steps?.*(\(((\d+) failed)?.*((\d+) passed)?.*((\d+) skipped)?.*((\d+) undefined)?.*((\d+) pending)?\))?$/)
+ if output
+ if (output =~ /failed/)
+ growl_fail(output)
+ else
+ growl_pass(output)
+ end
+ end
+
+ elsif results.include? 'example'
+ # RSpec
+ # 1 examples, 10 failures, 10 pending
+ output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
+ if output
+ $2.to_i > 0 ? growl_fail(output) : growl_pass(output)
+ end
+ end
+
+ puts "=> done"
+ end
+
+end
+
3  lib/stakeout.rb
@@ -0,0 +1,3 @@
+class Stakeout
+ VERSION = '1.0.0'
+end
8 test/test_stakeout.rb
@@ -0,0 +1,8 @@
+require "test/unit"
+require "stakeout"
+
+class TestStakeout < Test::Unit::TestCase
+ def test_sanity
+ flunk "write tests or I will kneecap you"
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.