public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Search Repo:
Michael S. Klishin (author)
Fri May 16 16:44:20 -0700 2008
commit  24331d46eb02ccf3c7fa658a74e58dbd6cd4c1ad
tree    b98b4e2d28102783831bdea656cbeb2b840db954
parent  c53276953f5ad83c328c0efebadfd599ef6f91a4
merb-core / autotest / textmate.rb
100644 45 lines (39 sloc) 1.002 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
if ENV["TM_RUBY"]
 
  module Autotest::HtmlConsole
    MAX = 30
    STATUS = {}
    OUT_DUP = STDOUT.dup
    require 'stringio'
    # $stdout = StringIO.new
    # $stderr = StringIO.new
 
    OUT_DUP.puts <<-HERE
<html>
<head>
<title>AutoTest Results</title>
<script>document.body.innerHTML = ''</script>
</head>
<body>
</body>
</html>
HERE
 
    def self.update(failures = nil)
      STATUS.delete STATUS.keys.sort.last if STATUS.size > MAX
      STATUS.sort.reverse.each do |t,s|
        if s > 0 then
          OUT_DUP.puts "<p style=\"color:red\">#{t}: #{failures.join("<br/>")}</p>"
        else
          OUT_DUP.puts "<p style=\"color:green\">#{t}: #{s}</p>"
        end
      end
      OUT_DUP.flush
    end
 
    Autotest.add_hook :red do |at|
      STATUS[Time.now] = at.files_to_test.size
      update(at.failures)
    end
 
    Autotest.add_hook :green do |at|
      STATUS[Time.now] = 0
      update
    end
  end
end