Permalink
Browse files

Retab

  • Loading branch information...
1 parent 9f9e8d1 commit 14f890656fbdac422884c7ecc286df2a6b10a1e3 Grzegorz Miklaszewski committed Nov 3, 2011
Showing with 44 additions and 44 deletions.
  1. +20 −20 lib/rake_bubbler/bubble_task.rb
  2. +24 −24 lib/rake_bubbler/rake_bubbler.rb
View
40 lib/rake_bubbler/bubble_task.rb
@@ -4,40 +4,40 @@
require 'tempfile'
module RakeBubbler
- module BubbleTask
+ module BubbleTask
def self.included(klass)
klass.class_eval do
- def invoke_with_output_capture(*params)
- return invoke_without_output_capture(*params) unless RakeBubbler.capture_task?(name)
-
- duration, error = nil
+ def invoke_with_output_capture(*params)
+ return invoke_without_output_capture(*params) unless RakeBubbler.capture_task?(name)
+
+ duration, error = nil
started = Time.now
-
- # capture task output
- output = RakeBubbler.capture_output do
- time = Benchmark.measure(name) do
+
+ # capture task output
+ output = RakeBubbler.capture_output do
+ time = Benchmark.measure(name) do
begin
- # invoke task
- invoke_without_output_capture(*params)
+ # invoke task
+ invoke_without_output_capture(*params)
rescue Exception => e
error = e
end
- end
-
- duration = time.real
- end
-
- RakeBubbler.executed(name, duration, output, started, error)
+ end
+
+ duration = time.real
+ end
+
+ RakeBubbler.executed(name, duration, output, started, error)
raise error if error
- end # invoke_with_output_capture
+ end # invoke_with_output_capture
alias_method :invoke_without_output_capture, :invoke
alias_method :invoke, :invoke_with_output_capture
end
end
-
- end # BubbleTask
+
+ end # BubbleTask
end # RakeBubbler
View
48 lib/rake_bubbler/rake_bubbler.rb
@@ -17,31 +17,31 @@ def capture_task?(name)
end
def capture_output
- file = Tempfile.new(Digest::MD5.hexdigest((Time.now.to_i + rand(2**16)).to_s))
-
- read, write = IO.pipe
-
- save_stdout = $stdout.dup
- $stdout.reopen(write)
-
- if fork
- read.close
- yield
- write.close
- $stdout.reopen(save_stdout)
- save_stdout.close
- Process.wait
+ file = Tempfile.new(Digest::MD5.hexdigest((Time.now.to_i + rand(2**16)).to_s))
+
+ read, write = IO.pipe
+
+ save_stdout = $stdout.dup
+ $stdout.reopen(write)
+
+ if fork
+ read.close
+ yield
+ write.close
+ $stdout.reopen(save_stdout)
+ save_stdout.close
+ Process.wait
file.unlink
- file.read
- else
- write.close
- $stdout.close
- Shell.new.tee(file.path) < read > save_stdout
- read.close
- save_stdout.close
- exit!
- end # fork
- end # capture_output
+ file.read
+ else
+ write.close
+ $stdout.close
+ Shell.new.tee(file.path) < read > save_stdout
+ read.close
+ save_stdout.close
+ exit!
+ end # fork
+ end # capture_output
end
end

0 comments on commit 14f8906

Please sign in to comment.