autotest_screen 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +6 -0
- data/README.txt +51 -0
- data/Rakefile +12 -0
- data/lib/autotest/screen.rb +148 -0
- data/test/test_autotest_screen.rb +11 -0
- metadata +71 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
= autotest_screen
|
2
|
+
|
3
|
+
* http://autotest-screen.rubyforge.org/
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Autotest::Screen shows autotest/autospec progress on GNU Screen's status line.
|
8
|
+
|
9
|
+
== FEATURES:
|
10
|
+
|
11
|
+
* Screenshots are available in here[http://f.hatena.ne.jp/yoshuki/autotest_screen/].
|
12
|
+
|
13
|
+
== SYNOPSIS
|
14
|
+
|
15
|
+
$HOME/.autotest
|
16
|
+
require 'autotest/screen'
|
17
|
+
# Autotest::Screen.statusline = '%H %`%-w%{=b bw}%n %t%{-}%+w (your statusline)'
|
18
|
+
|
19
|
+
== REQUIREMENTS:
|
20
|
+
|
21
|
+
* rubygems
|
22
|
+
* autotest
|
23
|
+
|
24
|
+
== INSTALL:
|
25
|
+
|
26
|
+
* sudo gem install autotest_screen
|
27
|
+
|
28
|
+
== LICENSE:
|
29
|
+
|
30
|
+
(The MIT License)
|
31
|
+
|
32
|
+
Copyright (c) 2009 MIKAMI Yoshiyuki
|
33
|
+
|
34
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
35
|
+
a copy of this software and associated documentation files (the
|
36
|
+
"Software"), to deal in the Software without restriction, including
|
37
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
38
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
39
|
+
permit persons to whom the Software is furnished to do so, subject to
|
40
|
+
the following conditions:
|
41
|
+
|
42
|
+
The above copyright notice and this permission notice shall be
|
43
|
+
included in all copies or substantial portions of the Software.
|
44
|
+
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
46
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
47
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
48
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
49
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
50
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
51
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/autotest/screen.rb'
|
6
|
+
|
7
|
+
Hoe.new('autotest_screen', Autotest::Screen::VERSION) do |p|
|
8
|
+
p.rubyforge_name = 'autotest-screen'
|
9
|
+
p.developer('MIKAMI Yoshiyuki', 'yoshuki@saikyoline.jp')
|
10
|
+
end
|
11
|
+
|
12
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'autotest'
|
3
|
+
|
4
|
+
##
|
5
|
+
# Autotest::Screen shows autotest/autospec progress on GNU Screen's status line.
|
6
|
+
#
|
7
|
+
# == FEATURES:
|
8
|
+
# * Screenshots are available in here[http://f.hatena.ne.jp/yoshuki/autotest_screen/].
|
9
|
+
#
|
10
|
+
# == SYNOPSIS
|
11
|
+
# $HOME/.autotest
|
12
|
+
# require 'autotest/screen'
|
13
|
+
# # Autotest::Screen.statusline = '%H %`%-w%{=b bw}%n %t%{-}%+w (your statusline)'
|
14
|
+
#
|
15
|
+
|
16
|
+
class Autotest::Screen
|
17
|
+
VERSION = '4.0.0'
|
18
|
+
|
19
|
+
DEFAULT_STATUSLINE = '%H %`%-w%{=b bw}%n %t%{-}%+w'
|
20
|
+
DEFAULT_SCREEN_CMD = 'screen'
|
21
|
+
|
22
|
+
SCREEN_COLOR = {
|
23
|
+
:black => 'dd',
|
24
|
+
:green => 'gw',
|
25
|
+
:yellow => 'yk',
|
26
|
+
:red => 'rw',
|
27
|
+
}
|
28
|
+
|
29
|
+
def self.message(msg, color = :black)
|
30
|
+
col = SCREEN_COLOR[color]
|
31
|
+
msg = %Q[ %{=b #{col}} #{msg} %{-}]
|
32
|
+
send_cmd(msg)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.clear
|
36
|
+
send_cmd('')
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.run_screen_session?
|
40
|
+
str = `#{screen_cmd} -ls`
|
41
|
+
str.match(/(\d+) Socket/) && ($1.to_i > 0)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.execute?
|
45
|
+
!($TESTING || !run_screen_session?)
|
46
|
+
end
|
47
|
+
|
48
|
+
@statusline, @screen_cmd = nil
|
49
|
+
def self.statusline; @statusline || DEFAULT_STATUSLINE.dup; end
|
50
|
+
def self.statusline=(a); @statusline = a; end
|
51
|
+
def self.screen_cmd; @screen_cmd || DEFAULT_SCREEN_CMD.dup; end
|
52
|
+
def self.screen_cmd=(a); @screen_cmd = a; end
|
53
|
+
|
54
|
+
def self.send_cmd(msg)
|
55
|
+
cmd = %(#{screen_cmd} -X eval 'hardstatus alwayslastline "#{(statusline + msg).gsub('"', '\"')}"') #' stupid ruby-mode
|
56
|
+
system cmd
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
60
|
+
@last_message = {}
|
61
|
+
|
62
|
+
# All blocks return false, to execute each of following blocks defined in user's own ".autotest".
|
63
|
+
|
64
|
+
# Do nothing.
|
65
|
+
#Autotest.add_hook :all_good do |at|
|
66
|
+
# next false
|
67
|
+
#end
|
68
|
+
|
69
|
+
Autotest.add_hook :died do |at|
|
70
|
+
message "Exception occured. (#{at.class})", :red
|
71
|
+
next false
|
72
|
+
end
|
73
|
+
|
74
|
+
# Do nothing.
|
75
|
+
#Autotest.add_hook :green do |at|
|
76
|
+
# next false
|
77
|
+
#end
|
78
|
+
|
79
|
+
Autotest.add_hook :initialize do |at|
|
80
|
+
message "Run with #{at.class}" if execute?
|
81
|
+
next false
|
82
|
+
end
|
83
|
+
|
84
|
+
# Do nothing.
|
85
|
+
#Autotest.add_hook :interrupt do |at|
|
86
|
+
# next false
|
87
|
+
#end
|
88
|
+
|
89
|
+
Autotest.add_hook :quit do |at|
|
90
|
+
clear if execute?
|
91
|
+
next false
|
92
|
+
end
|
93
|
+
|
94
|
+
Autotest.add_hook :ran_command do |at|
|
95
|
+
next false unless execute?
|
96
|
+
|
97
|
+
output = at.results.join
|
98
|
+
|
99
|
+
case at.class.name
|
100
|
+
when 'Autotest::Rails'
|
101
|
+
results = output.scan(/(\d+)\s*failures?,\s*(\d+)\s*errors?/).first
|
102
|
+
num_failures, num_errors = results.map{|r| r.to_i}
|
103
|
+
|
104
|
+
if num_failures > 0 || num_errors > 0
|
105
|
+
@last_message = {:message => "Red F:#{num_failures} E:#{num_errors}", :color => :red}
|
106
|
+
else
|
107
|
+
@last_message = {:message => 'All Green', :color => :green}
|
108
|
+
end
|
109
|
+
when 'Autotest::RailsRspec'
|
110
|
+
results = output.scan(/(\d+)\s*examples?,\s*(\d+)\s*failures?(?:,\s*(\d+)\s*pendings?)?/).first
|
111
|
+
num_examples, num_failures, num_pendings = results.map{|r| r.to_i}
|
112
|
+
|
113
|
+
if num_failures > 0
|
114
|
+
@last_message = {:message => "Fail F:#{num_failures} P:#{num_pendings}", :color => :red}
|
115
|
+
elsif num_pendings > 0
|
116
|
+
@last_message = {:message => "Pend F:#{num_failures} P:#{num_pendings}", :color => :yellow}
|
117
|
+
else
|
118
|
+
@last_message = {:message => 'All Green', :color => :green}
|
119
|
+
end
|
120
|
+
end
|
121
|
+
next false
|
122
|
+
end
|
123
|
+
|
124
|
+
# Do nothing.
|
125
|
+
#Autotest.add_hook :red do |at|
|
126
|
+
# next false
|
127
|
+
#end
|
128
|
+
|
129
|
+
# Do nothing.
|
130
|
+
#Autotest.add_hook :reset do |at|
|
131
|
+
# next false
|
132
|
+
#end
|
133
|
+
|
134
|
+
Autotest.add_hook :run_command do |at|
|
135
|
+
message 'Running' if execute?
|
136
|
+
next false
|
137
|
+
end
|
138
|
+
|
139
|
+
# Do nothing.
|
140
|
+
#Autotest.add_hook :updated do |at, updated|
|
141
|
+
# next false
|
142
|
+
#end
|
143
|
+
|
144
|
+
Autotest.add_hook :waiting do |at|
|
145
|
+
message @last_message[:message], @last_message[:color] if execute?
|
146
|
+
next false
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'autotest/screen'
|
4
|
+
|
5
|
+
class TestAutotestScreen < Test::Unit::TestCase
|
6
|
+
def test_all_added_hooks_called
|
7
|
+
Autotest::HOOKS.keys.each do |hook|
|
8
|
+
assert(Autotest::ALL_HOOKS.include?(hook), %Q!"#{hook}" never called.!)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: autotest_screen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 4.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MIKAMI Yoshiyuki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-19 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.11.0
|
24
|
+
version:
|
25
|
+
description: Autotest::Screen shows autotest/autospec progress on GNU Screen's status line.
|
26
|
+
email:
|
27
|
+
- yoshuki@saikyoline.jp
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
files:
|
37
|
+
- History.txt
|
38
|
+
- Manifest.txt
|
39
|
+
- README.txt
|
40
|
+
- Rakefile
|
41
|
+
- lib/autotest/screen.rb
|
42
|
+
- test/test_autotest_screen.rb
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: http://autotest-screen.rubyforge.org/
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --main
|
48
|
+
- README.txt
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: autotest-screen
|
66
|
+
rubygems_version: 1.3.1
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: Autotest::Screen shows autotest/autospec progress on GNU Screen's status line.
|
70
|
+
test_files:
|
71
|
+
- test/test_autotest_screen.rb
|