Module: Autotest::Screen
- Defined in:
- lib/autotest/screen.rb
Class Method Summary collapse
- .clear_screen_caption ⇒ Object
- .green(text) ⇒ Object
- .red(text) ⇒ Object
- .screen_caption=(caption) ⇒ Object
- .screen_pid(pid = Process.ppid) ⇒ Object
- .update(kind, num = nil, total = num) ⇒ Object
- .yellow(text) ⇒ Object
Instance Method Summary collapse
-
#ran_command ⇒ Object
Parse the RSpec and Test::Unit results and send them to Growl.
Class Method Details
.clear_screen_caption ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/autotest/screen.rb', line 45 def self. system %Q{ screen -S #{screen_pid} -X eval 'caption splitonly' } rescue STDERR.puts "Unable to find parent screen process." STDERR.puts $!. STDERR.puts $!.backtrace.join( "\n" ) end |
.green(text) ⇒ Object
9 10 11 |
# File 'lib/autotest/screen.rb', line 9 def self.green( text ) "%{dG}#{text}" end |
.red(text) ⇒ Object
13 14 15 |
# File 'lib/autotest/screen.rb', line 13 def self.red( text ) "%{dR}#{text}" end |
.screen_caption=(caption) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/autotest/screen.rb', line 37 def self.( ) system %Q{ screen -S #{screen_pid} -X eval 'caption always "#{}"' } rescue STDERR.puts "Unable to find parent screen process." STDERR.puts $!. STDERR.puts $!.backtrace.join( "\n" ) end |
.screen_pid(pid = Process.ppid) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/autotest/screen.rb', line 21 def self.screen_pid( pid=Process.ppid ) @screen_pid ||= lambda { status = File.read( "/proc/#{pid}/stat" ) unless status =~ /(\d+) \((.*?)\) \w (\d+)/ raise "Trouble reading status of process #{pid}" end pid, exe, ppid = $1, $2, $3 if exe =~ /^screen/i pid else screen_pid( ppid ) end }.call end |
.update(kind, num = nil, total = num) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/autotest/screen.rb', line 54 def self.update( kind, num=nil, total=num ) case kind when :failure self. = red( " #{num} failed from #{total}." ) when :pending self. = yellow( " #{num} pending from #{total}." ) when :success self. = green( " #{num} passed." ) when :error self. = red( " Error running tests." ) else raise "Unexpected kind of update #{kind}" end end |
.yellow(text) ⇒ Object
17 18 19 |
# File 'lib/autotest/screen.rb', line 17 def self.yellow( text ) "%{dy}#{text}" end |
Instance Method Details
#ran_command ⇒ Object
Parse the RSpec and Test::Unit results and send them to Growl.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/autotest/screen.rb', line 78 Autotest.add_hook :ran_command do |autotest| result = Autotest::Result.new( autotest ) if result.exists? case result.framework when 'rspec' if result.has?( 'example-failed' ) update :failure, result[ 'example-failed' ], result[ 'example' ] elsif result.has?( 'example-pending' ) update :pending, result[ 'example-pending' ], result[ 'example' ] else update :success, result.get( 'example' ) end end else update :error end false end |