autotest-tmux 1.1.0 → 1.2.0

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/.gitignore CHANGED
@@ -17,5 +17,6 @@ tmtags
17
17
  coverage
18
18
  rdoc
19
19
  pkg
20
+ release
20
21
 
21
22
  ## PROJECT::SPECIFIC
data/README.rdoc CHANGED
@@ -4,7 +4,7 @@ http://github.com/yoshuki/autotest-tmux
4
4
 
5
5
  == Description
6
6
 
7
- Autotest::Tmux shows autotest/autospec progress on tmux status-right.
7
+ Autotest::Tmux displays autotest/autospec progress on tmux status-right.
8
8
 
9
9
  == Features
10
10
 
data/Rakefile CHANGED
@@ -5,8 +5,8 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "autotest-tmux"
8
- gem.summary = %Q{shows autotest/autospec progress on tmux status-right.}
9
- gem.description = %Q{shows autotest/autospec progress on tmux status-right.}
8
+ gem.summary = %Q{displays autotest/autospec progress on tmux status-right.}
9
+ gem.description = %Q{displays autotest/autospec progress on tmux status-right.}
10
10
  gem.email = "yoshuki@saikyoline.jp"
11
11
  gem.homepage = "http://github.com/yoshuki/autotest-tmux"
12
12
  gem.authors = ["MIKAMI Yoshiyuki"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{autotest-tmux}
8
- s.version = "1.1.0"
8
+ s.version = "1.2.0"
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{2010-10-14}
13
- s.description = %q{shows autotest/autospec progress on tmux status-right.}
12
+ s.date = %q{2010-10-15}
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 = [
16
16
  "LICENSE",
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.rdoc_options = ["--charset=UTF-8"]
34
34
  s.require_paths = ["lib"]
35
35
  s.rubygems_version = %q{1.3.7}
36
- s.summary = %q{shows autotest/autospec progress on tmux status-right.}
36
+ s.summary = %q{displays autotest/autospec progress on tmux status-right.}
37
37
  s.test_files = [
38
38
  "spec/autotest-tmux_spec.rb",
39
39
  "spec/spec_helper.rb"
data/lib/autotest/tmux.rb CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'autotest'
3
3
 
4
4
  ##
5
- # Autotest::Tmux shows autotest/autospec progress on tmux status-right.
5
+ # Autotest::Tmux displays autotest/autospec progress on tmux status-right.
6
6
  #
7
7
  # == Features
8
8
  # * Screenshots aren't available yet. (but, almost same as autotest_screen[http://f.hatena.ne.jp/yoshuki/autotest_screen/].)
@@ -26,8 +26,13 @@ class Autotest::Tmux
26
26
  :red => ['white', 'red']
27
27
  }
28
28
 
29
- def self.message(msg=statusright, color=:black)
30
- col = SCREEN_COLOR[color]
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]
31
36
  msg = "#[fg=#{col[0]},bg=#{col[1]}] #{msg} #[default]" unless msg == statusright
32
37
  send_cmd(msg)
33
38
  end
@@ -37,8 +42,7 @@ class Autotest::Tmux
37
42
  end
38
43
 
39
44
  def self.run_tmux_session?
40
- cmd = "#{tmux_cmd} has-session"
41
- system cmd
45
+ system "#{tmux_cmd} has-session"
42
46
  end
43
47
 
44
48
  def self.execute?
@@ -52,13 +56,9 @@ class Autotest::Tmux
52
56
  def self.tmux_cmd=(tc); @tmux_cmd = tc; end
53
57
 
54
58
  def self.send_cmd(msg)
55
- cmd = "#{tmux_cmd} set status-right '#{msg.gsub("'", "\'")}'"
56
- system cmd
57
- nil
59
+ system "#{tmux_cmd} set status-right '#{msg.gsub("'", "\'")}'"
58
60
  end
59
61
 
60
- @last_message = {}
61
-
62
62
  # All blocks return false, to execute each of following blocks defined in user's own ".autotest".
63
63
 
64
64
  # Do nothing.
@@ -104,23 +104,23 @@ class Autotest::Tmux
104
104
  num_failures, num_errors = results.map{|r| r.to_i}
105
105
 
106
106
  if num_failures > 0 || num_errors > 0
107
- @last_message = {:message => "Red F:#{num_failures} E:#{num_errors}", :color => :red}
107
+ @last_result = {:message => "Red F:#{num_failures} E:#{num_errors}", :color => :red}
108
108
  else
109
- @last_message = {:message => 'All Green', :color => :green}
109
+ @last_result = {:message => 'All Green', :color => :green}
110
110
  end
111
- when 'Autotest::Rspec', 'Autotest::Rspec2', 'Autotest::RailsRspec', 'Autotest::MerbRspec'
111
+ when 'Autotest::Rspec', 'Autotest::Rspec2', 'Autotest::RailsRspec', 'Autotest::RailsRspec2', 'Autotest::MerbRspec'
112
112
  results = output.scan(/(\d+)\s*examples?,\s*(\d+)\s*failures?(?:,\s*(\d+)\s*pendings?)?/).first
113
113
  num_examples, num_failures, num_pendings = results.map{|r| r.to_i}
114
114
 
115
115
  if num_failures > 0
116
- @last_message = {:message => "Fail F:#{num_failures} P:#{num_pendings}", :color => :red}
116
+ @last_result = {:message => "Fail F:#{num_failures} P:#{num_pendings}", :color => :red}
117
117
  elsif num_pendings > 0
118
- @last_message = {:message => "Pend F:#{num_failures} P:#{num_pendings}", :color => :yellow}
118
+ @last_result = {:message => "Pend F:#{num_failures} P:#{num_pendings}", :color => :yellow}
119
119
  else
120
- @last_message = {:message => 'All Green', :color => :green}
120
+ @last_result = {:message => 'All Green', :color => :green}
121
121
  end
122
122
  else
123
- @last_message = {:message => "Unknown class name. (#{class_name})", :color => :red}
123
+ @last_result = {:message => "Unknown class. (#{class_name})"}
124
124
  end
125
125
  next false
126
126
  end
@@ -147,7 +147,7 @@ class Autotest::Tmux
147
147
 
148
148
  Autotest.add_hook :waiting do |at, *args|
149
149
  sleep 0.5
150
- message @last_message[:message], @last_message[:color] if execute?
150
+ message @last_result[:message], @last_result[:color] if execute?
151
151
  next false
152
152
  end
153
153
  end
@@ -1,10 +1,36 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe Autotest::Tmux do
4
- context 'all added hooks should be called by autotest' do
4
+ context 'All added hooks should be called by autotest' do
5
5
  Autotest::HOOKS.keys.each do |hook|
6
6
  subject { Autotest::ALL_HOOKS }
7
7
  it { should include(hook) }
8
8
  end
9
9
  end
10
+
11
+ describe 'When display message' do
12
+ context 'without params' do
13
+ it { Autotest::Tmux.message.should be_true }
14
+ end
15
+
16
+ context 'with String as message' do
17
+ it { Autotest::Tmux.message('foo').should be_true }
18
+ end
19
+
20
+ context 'with nil as message' do
21
+ it { Autotest::Tmux.message(nil).should be_true }
22
+ end
23
+
24
+ context 'with Symbol as color' do
25
+ it { Autotest::Tmux.message('foo', :black).should be_true }
26
+ end
27
+
28
+ context 'with nil as color' do
29
+ it { Autotest::Tmux.message('foo', nil).should be_true }
30
+ end
31
+ end
32
+
33
+ after(:all) do
34
+ Autotest::Tmux.clear
35
+ end
10
36
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 1.1.0
9
+ version: 1.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - MIKAMI Yoshiyuki
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-14 00:00:00 +09:00
17
+ date: 2010-10-15 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -60,7 +60,7 @@ dependencies:
60
60
  version: "0"
61
61
  type: :runtime
62
62
  version_requirements: *id003
63
- description: shows autotest/autospec progress on tmux status-right.
63
+ description: displays autotest/autospec progress on tmux status-right.
64
64
  email: yoshuki@saikyoline.jp
65
65
  executables: []
66
66
 
@@ -112,7 +112,7 @@ rubyforge_project:
112
112
  rubygems_version: 1.3.7
113
113
  signing_key:
114
114
  specification_version: 3
115
- summary: shows autotest/autospec progress on tmux status-right.
115
+ summary: displays autotest/autospec progress on tmux status-right.
116
116
  test_files:
117
117
  - spec/autotest-tmux_spec.rb
118
118
  - spec/spec_helper.rb