autotest-tmux 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/autotest-tmux.gemspec +2 -2
- data/lib/autotest/tmux.rb +156 -156
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.3
|
data/autotest-tmux.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{autotest-tmux}
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["MIKAMI Yoshiyuki"]
|
12
|
-
s.date = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-22}
|
13
13
|
s.description = %q{displays autotest/autospec progress on tmux status-right.}
|
14
14
|
s.email = %q{yoshuki@saikyoline.jp}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/autotest/tmux.rb
CHANGED
@@ -1,156 +1,156 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'autotest'
|
3
|
-
|
4
|
-
##
|
5
|
-
# Autotest::Tmux displays autotest/autospec progress on tmux status-right.
|
6
|
-
#
|
7
|
-
# == Features
|
8
|
-
# * Screenshots aren't available yet. (but, almost same as autotest_screen[http://f.hatena.ne.jp/yoshuki/autotest_screen/].)
|
9
|
-
#
|
10
|
-
# == Synopsis
|
11
|
-
# $HOME/.autotest
|
12
|
-
# require 'autotest/tmux'
|
13
|
-
# # Autotest::Tmux.statusright = '"#22T" %H:%M %d-%b-%y (your statusright)'
|
14
|
-
#
|
15
|
-
# * To prevent server information (like "set option: status-right -> ..."), you should start tmux server with -q option first.
|
16
|
-
#
|
17
|
-
|
18
|
-
class Autotest::Tmux
|
19
|
-
DEFAULT_STATUSRIGHT = '"#22T" %H:%M %d-%b-%y'
|
20
|
-
DEFAULT_TMUX_CMD = 'tmux'
|
21
|
-
|
22
|
-
SCREEN_COLOR = {
|
23
|
-
:black => ['white', 'black'],
|
24
|
-
:green => ['white', 'green'],
|
25
|
-
:yellow => ['black', 'yellow'],
|
26
|
-
:red => ['white', 'red']
|
27
|
-
}
|
28
|
-
|
29
|
-
@last_result = {}
|
30
|
-
|
31
|
-
def self.message(msg=statusright, sc=:black)
|
32
|
-
msg ||= statusright # when nil given
|
33
|
-
sc ||= :black # when nil given
|
34
|
-
|
35
|
-
col = SCREEN_COLOR[sc]
|
36
|
-
msg = "#[fg=#{col[0]},bg=#{col[1]}] #{msg} #[default]" unless msg == statusright
|
37
|
-
send_cmd(msg)
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.clear
|
41
|
-
send_cmd('')
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.run_tmux_session?
|
45
|
-
system "#{tmux_cmd} has-session"
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.execute?
|
49
|
-
!($TESTING || !run_tmux_session?)
|
50
|
-
end
|
51
|
-
|
52
|
-
@statusright = @tmux_cmd = nil
|
53
|
-
def self.statusright; @statusright || DEFAULT_STATUSRIGHT.dup; end
|
54
|
-
def self.statusright=(s); @statusright = s; end
|
55
|
-
def self.tmux_cmd; @tmux_cmd || DEFAULT_TMUX_CMD.dup; end
|
56
|
-
def self.tmux_cmd=(tc); @tmux_cmd = tc; end
|
57
|
-
|
58
|
-
def self.send_cmd(msg)
|
59
|
-
system "#{tmux_cmd} set status-right '#{msg.gsub("'", "\'")}'"
|
60
|
-
end
|
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, *args|
|
66
|
-
# next false
|
67
|
-
#end
|
68
|
-
|
69
|
-
Autotest.add_hook :died do |at, *args|
|
70
|
-
message "Exception occured. (#{at.class})", :red
|
71
|
-
puts "Exception occured. (#{at.class}): #{args.first}"
|
72
|
-
next false
|
73
|
-
end
|
74
|
-
|
75
|
-
# Do nothing.
|
76
|
-
#Autotest.add_hook :green do |at, *args|
|
77
|
-
# next false
|
78
|
-
#end
|
79
|
-
|
80
|
-
Autotest.add_hook :initialize do |at, *args|
|
81
|
-
message "Run with #{at.class}" if execute?
|
82
|
-
next false
|
83
|
-
end
|
84
|
-
|
85
|
-
# Do nothing.
|
86
|
-
#Autotest.add_hook :interrupt do |at, *args|
|
87
|
-
# next false
|
88
|
-
#end
|
89
|
-
|
90
|
-
Autotest.add_hook :quit do |at, *args|
|
91
|
-
message if execute?
|
92
|
-
next false
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.parse_output(output, class_name)
|
96
|
-
case class_name
|
97
|
-
when 'Autotest', 'Autotest::Rails'
|
98
|
-
results = output.scan(/(\d+)\s*failures?,\s*(\d+)\s*errors?/).first
|
99
|
-
num_failures, num_errors = results.map{|r| r.to_i}
|
100
|
-
|
101
|
-
if num_failures > 0 || num_errors > 0
|
102
|
-
result = {:message => "Red F:#{num_failures} E:#{num_errors}", :color => :red}
|
103
|
-
else
|
104
|
-
result = {:message => 'All Green', :color => :green}
|
105
|
-
end
|
106
|
-
when 'Autotest::Rspec', 'Autotest::Rspec2', 'Autotest::RailsRspec', 'Autotest::RailsRspec2', 'Autotest::MerbRspec'
|
107
|
-
results = output.scan(/(\d+)\s*examples?,\s*(\d+)\s*failures?(?:,\s*(\d+)\s*pendings?)?/).first
|
108
|
-
num_examples, num_failures, num_pendings = results.map{|r| r.to_i}
|
109
|
-
|
110
|
-
if num_failures > 0
|
111
|
-
result = {:message => "Fail F:#{num_failures} P:#{num_pendings}", :color => :red}
|
112
|
-
elsif num_pendings > 0
|
113
|
-
result = {:message => "Pend F:#{num_failures} P:#{num_pendings}", :color => :yellow}
|
114
|
-
else
|
115
|
-
result = {:message => 'All Green', :color => :green}
|
116
|
-
end
|
117
|
-
end
|
118
|
-
result || {:message => "Unknown class. (#{class_name})"}
|
119
|
-
end
|
120
|
-
|
121
|
-
Autotest.add_hook :ran_command do |at, *args|
|
122
|
-
next false unless execute?
|
123
|
-
|
124
|
-
output = at.results.join
|
125
|
-
class_name = at.class.name
|
126
|
-
|
127
|
-
@last_result = parse_output(output, class_name)
|
128
|
-
next false
|
129
|
-
end
|
130
|
-
|
131
|
-
# Do nothing.
|
132
|
-
#Autotest.add_hook :red do |at, *args|
|
133
|
-
# next false
|
134
|
-
#end
|
135
|
-
|
136
|
-
# Do nothing.
|
137
|
-
#Autotest.add_hook :reset do |at, *args|
|
138
|
-
# next false
|
139
|
-
#end
|
140
|
-
|
141
|
-
Autotest.add_hook :run_command do |at, *args|
|
142
|
-
message 'Running' if execute?
|
143
|
-
next false
|
144
|
-
end
|
145
|
-
|
146
|
-
# Do nothing.
|
147
|
-
#Autotest.add_hook :updated do |at, *args|
|
148
|
-
# next false
|
149
|
-
#end
|
150
|
-
|
151
|
-
Autotest.add_hook :waiting do |at, *args|
|
152
|
-
sleep 0.5
|
153
|
-
message @last_result[:message], @last_result[:color] if execute?
|
154
|
-
next false
|
155
|
-
end
|
156
|
-
end
|
1
|
+
require 'rubygems'
|
2
|
+
require 'autotest'
|
3
|
+
|
4
|
+
##
|
5
|
+
# Autotest::Tmux displays autotest/autospec progress on tmux status-right.
|
6
|
+
#
|
7
|
+
# == Features
|
8
|
+
# * Screenshots aren't available yet. (but, almost same as autotest_screen[http://f.hatena.ne.jp/yoshuki/autotest_screen/].)
|
9
|
+
#
|
10
|
+
# == Synopsis
|
11
|
+
# $HOME/.autotest
|
12
|
+
# require 'autotest/tmux'
|
13
|
+
# # Autotest::Tmux.statusright = '"#22T" %H:%M %d-%b-%y (your statusright)'
|
14
|
+
#
|
15
|
+
# * To prevent server information (like "set option: status-right -> ..."), you should start tmux server with -q option first.
|
16
|
+
#
|
17
|
+
|
18
|
+
class Autotest::Tmux
|
19
|
+
DEFAULT_STATUSRIGHT = '"#22T" %H:%M %d-%b-%y'
|
20
|
+
DEFAULT_TMUX_CMD = 'tmux'
|
21
|
+
|
22
|
+
SCREEN_COLOR = {
|
23
|
+
:black => ['white', 'black'],
|
24
|
+
:green => ['white', 'green'],
|
25
|
+
:yellow => ['black', 'yellow'],
|
26
|
+
:red => ['white', 'red']
|
27
|
+
}
|
28
|
+
|
29
|
+
@last_result = {}
|
30
|
+
|
31
|
+
def self.message(msg=statusright, sc=:black)
|
32
|
+
msg ||= statusright # when nil given
|
33
|
+
sc ||= :black # when nil given
|
34
|
+
|
35
|
+
col = SCREEN_COLOR[sc]
|
36
|
+
msg = "#[fg=#{col[0]},bg=#{col[1]}] #{msg} #[default]" unless msg == statusright
|
37
|
+
send_cmd(msg)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.clear
|
41
|
+
send_cmd('')
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.run_tmux_session?
|
45
|
+
system "#{tmux_cmd} has-session"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.execute?
|
49
|
+
!($TESTING || !run_tmux_session?)
|
50
|
+
end
|
51
|
+
|
52
|
+
@statusright = @tmux_cmd = nil
|
53
|
+
def self.statusright; @statusright || DEFAULT_STATUSRIGHT.dup; end
|
54
|
+
def self.statusright=(s); @statusright = s; end
|
55
|
+
def self.tmux_cmd; @tmux_cmd || DEFAULT_TMUX_CMD.dup; end
|
56
|
+
def self.tmux_cmd=(tc); @tmux_cmd = tc; end
|
57
|
+
|
58
|
+
def self.send_cmd(msg)
|
59
|
+
system "#{tmux_cmd} set status-right '#{msg.gsub("'", "\'")}'"
|
60
|
+
end
|
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, *args|
|
66
|
+
# next false
|
67
|
+
#end
|
68
|
+
|
69
|
+
Autotest.add_hook :died do |at, *args|
|
70
|
+
message "Exception occured. (#{at.class})", :red
|
71
|
+
puts "Exception occured. (#{at.class}): #{args.first}" unless args.nil?
|
72
|
+
next false
|
73
|
+
end
|
74
|
+
|
75
|
+
# Do nothing.
|
76
|
+
#Autotest.add_hook :green do |at, *args|
|
77
|
+
# next false
|
78
|
+
#end
|
79
|
+
|
80
|
+
Autotest.add_hook :initialize do |at, *args|
|
81
|
+
message "Run with #{at.class}" if execute?
|
82
|
+
next false
|
83
|
+
end
|
84
|
+
|
85
|
+
# Do nothing.
|
86
|
+
#Autotest.add_hook :interrupt do |at, *args|
|
87
|
+
# next false
|
88
|
+
#end
|
89
|
+
|
90
|
+
Autotest.add_hook :quit do |at, *args|
|
91
|
+
message if execute?
|
92
|
+
next false
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.parse_output(output, class_name)
|
96
|
+
case class_name
|
97
|
+
when 'Autotest', 'Autotest::Rails'
|
98
|
+
results = output.scan(/(\d+)\s*failures?,\s*(\d+)\s*errors?/).first
|
99
|
+
num_failures, num_errors = results.map{|r| r.to_i}
|
100
|
+
|
101
|
+
if num_failures > 0 || num_errors > 0
|
102
|
+
result = {:message => "Red F:#{num_failures} E:#{num_errors}", :color => :red}
|
103
|
+
else
|
104
|
+
result = {:message => 'All Green', :color => :green}
|
105
|
+
end
|
106
|
+
when 'Autotest::Rspec', 'Autotest::Rspec2', 'Autotest::RailsRspec', 'Autotest::RailsRspec2', 'Autotest::MerbRspec', 'Autotest::CucumberRspec2'
|
107
|
+
results = output.scan(/(\d+)\s*examples?,\s*(\d+)\s*failures?(?:,\s*(\d+)\s*pendings?)?/).first
|
108
|
+
num_examples, num_failures, num_pendings = results.map{|r| r.to_i}
|
109
|
+
|
110
|
+
if num_failures > 0
|
111
|
+
result = {:message => "Fail F:#{num_failures} P:#{num_pendings}", :color => :red}
|
112
|
+
elsif num_pendings > 0
|
113
|
+
result = {:message => "Pend F:#{num_failures} P:#{num_pendings}", :color => :yellow}
|
114
|
+
else
|
115
|
+
result = {:message => 'All Green', :color => :green}
|
116
|
+
end
|
117
|
+
end
|
118
|
+
result || {:message => "Unknown class. (#{class_name})"}
|
119
|
+
end
|
120
|
+
|
121
|
+
Autotest.add_hook :ran_command do |at, *args|
|
122
|
+
next false unless execute?
|
123
|
+
|
124
|
+
output = at.results.join
|
125
|
+
class_name = at.class.name
|
126
|
+
|
127
|
+
@last_result = parse_output(output, class_name)
|
128
|
+
next false
|
129
|
+
end
|
130
|
+
|
131
|
+
# Do nothing.
|
132
|
+
#Autotest.add_hook :red do |at, *args|
|
133
|
+
# next false
|
134
|
+
#end
|
135
|
+
|
136
|
+
# Do nothing.
|
137
|
+
#Autotest.add_hook :reset do |at, *args|
|
138
|
+
# next false
|
139
|
+
#end
|
140
|
+
|
141
|
+
Autotest.add_hook :run_command do |at, *args|
|
142
|
+
message 'Running' if execute?
|
143
|
+
next false
|
144
|
+
end
|
145
|
+
|
146
|
+
# Do nothing.
|
147
|
+
#Autotest.add_hook :updated do |at, *args|
|
148
|
+
# next false
|
149
|
+
#end
|
150
|
+
|
151
|
+
Autotest.add_hook :waiting do |at, *args|
|
152
|
+
sleep 0.5
|
153
|
+
message @last_result[:message], @last_result[:color] if execute?
|
154
|
+
next false
|
155
|
+
end
|
156
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: autotest-tmux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.2.
|
5
|
+
version: 1.2.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- MIKAMI Yoshiyuki
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-22 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: autotest
|