Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion TDD killing my joy of Rails
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Phlip  
View profile  
 More options Nov 30 2006, 10:58 pm
From: "Phlip" <phlip2...@gmail.com>
Date: Thu, 30 Nov 2006 19:58:39 -0800
Local: Thurs, Nov 30 2006 10:58 pm
Subject: Re: [Rails] Re: TDD killing my joy of Rails

Brian Hogan wrote:
> Even better... install ZenTest

> gem install ZenTest

> autotest --rails

> Tests run when you save the corresponding file.  Makes it almost too easy.

My command line:

trigger 'rake recent' `find test -name \\*.rb` app/*/*.rb
app/views/*/*.rhtml

The utterly ugly and distastefully hacked-together contents of trigger are
below my sig.

Any editor, folks. Any editor. I don't even need to look at the console to
hear the results. If the punk rock ain't up too loud!

--
  Phlip
  http://www.greencheese.us/ZeekLand <-- NOT a blog!!!

#!/usr/bin/env ruby

 #  lazy-loop until a file changes, then run a command

def syntax()
    puts 'syntax: trigger "command...args" files...'
    exit 1
end

#  TODO  support **

syntax()  if 0 == ARGV.size

command = ARGV.shift
$fileTimes = {}

def anyFileChanged()
    anyChanged = false

    ARGV.each do |fn|  #  TODO  option to do Dir here
        begin
          mod = File.mtime(fn)
          anyChanged = true  if $fileTimes[fn] != mod
          $fileTimes[fn] = mod
        rescue
          puts $!
          sleep 2
        end
    end

    return anyChanged
end

anyFileChanged()  #  prime the pump

while true
    sleep 0.333
    if anyFileChanged()
        got = system(command)

        sound  = got ?  'drumloop.wav' :   'jaguar.wav'

        weWin32 = RUBY_PLATFORM.include?('mswin32')

        if weWin32
            system('"C:\\Program Files\\Windows Media Player\\mplayer2.exe"
/play /close s:\\bin\\' + sound)
        else
            system('aplay ~/bin/' + sound)
        end

    end
end

#One way is to use Win32API:

SND_MEMORY   = 0x00000004   # from "mmsystem.h"
SND_FILENAME = 0x00020000

def playSound()

  pPlaySound = Win32API.new("winmm", "PlaySound", ['P', 'L', 'L'], 'I')

  # play from file:
  pPlaySound.call("C:/your/sound.wav", 0, SND_FILENAME)

# play from memory:
  #wav = File.open("C:/your/sound.wav", File::RDONLY) {|f| f.binmode;
f.read }
  # PlaySound.call(wav, 0, SND_MEMORY)

end


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.