le1t0-capistrano 2.5.18.008 → 2.5.18.009

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 2.5.18.009 / Jul 22, 2010
2
+
3
+ Added TeeIO class which can catch all output to $stderr/$stdout/etc, so the output can be emailed/stored
4
+
1
5
  == 2.5.18.008 / Jul 1, 2010
2
6
 
3
7
  Actually merged in new code
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.5.18.008
1
+ 2.5.18.009
data/bin/cap CHANGED
@@ -1,4 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'capistrano/cli/tee_io'
3
4
  require 'capistrano/cli'
5
+
6
+ Signal.trap("EXIT") do
7
+ TeeIO.output_all # make sure we request the output, so file pointers get closed also if not done already, just throw away the
8
+ # result
9
+ end
10
+ TeeIO.tee_all
11
+
4
12
  Capistrano::CLI.execute
@@ -0,0 +1,88 @@
1
+ require 'stringio'
2
+ class TeeIO
3
+ attr_accessor :old_io
4
+ attr_accessor :pipe_io
5
+ attr_accessor :teed_io_name
6
+ attr_accessor :auto_close_pipe_io
7
+
8
+ class << self
9
+
10
+ def tee_all(pipe_io = nil, &block)
11
+ if block_given?
12
+ tee("$stdout", pipe_io) do |io|
13
+ tee("$stderr", io) do
14
+ yield
15
+ end
16
+ end
17
+ else
18
+ io = tee("$stdout", pipe_io)
19
+ tee("$stderr", io)
20
+ end
21
+ end
22
+
23
+ def tee(teed_io_name, pipe_io = nil, &block)
24
+ eval("#{teed_io_name} = self.new(teed_io_name, pipe_io || StringIO.new, pipe_io.nil?)")
25
+ if block_given?
26
+ yield(eval("#{teed_io_name}.pipe_io"))
27
+ eval("#{teed_io_name}.output")
28
+ else
29
+ eval("#{teed_io_name}.pipe_io")
30
+ end
31
+ end
32
+
33
+ def output_all
34
+ $stderr.output if $stderr.is_a?(TeeIO)
35
+ $stdout.output if $stdout.is_a?(TeeIO)
36
+ end
37
+
38
+ end
39
+
40
+ def initialize(*args)
41
+ @teed_io_name = args[0]
42
+ @old_io = eval(args[0])
43
+ @pipe_io = args[1]
44
+ @auto_close_pipe_io = args[2]
45
+ end
46
+
47
+ def call_on_io(method_name, *args, &block)
48
+ call_on_old_io(method_name, *args, &block)
49
+ call_on_pipe_io(method_name, *args, &block)
50
+ end
51
+
52
+ def call_on_old_io(method_name, *args, &block)
53
+ if @old_io.is_a?(IO) || @old_io.is_a?(StringIO)
54
+ @old_io.send(method_name, *args, &block)
55
+ @old_io.flush
56
+ end
57
+ end
58
+
59
+ def call_on_pipe_io(method_name, *args, &block)
60
+ if @pipe_io.is_a?(IO) || @pipe_io.is_a?(StringIO)
61
+ @pipe_io.send(method_name, *args, &block)
62
+ @pipe_io.flush
63
+ end
64
+ end
65
+
66
+ def write(str)
67
+ call_on_io(:write, str)
68
+ end
69
+
70
+ def method_missing(method_name, *args, &block)
71
+ call_on_io(method_name, *args, &block)
72
+ end
73
+
74
+ def output
75
+ reset_io
76
+ if @auto_close_pipe_io && @pipe_io.is_a?(StringIO)
77
+ str = @pipe_io.string
78
+ @pipe_io.close
79
+ str
80
+ else
81
+ @pipe_io
82
+ end
83
+ end
84
+
85
+ def reset_io
86
+ eval("#{teed_io_name} = @old_io")
87
+ end
88
+ end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 2
7
7
  - 5
8
8
  - 18
9
- - 8
10
- version: 2.5.18.008
9
+ - 9
10
+ version: 2.5.18.009
11
11
  platform: ruby
12
12
  authors:
13
13
  - Le1t0
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-01 00:00:00 +02:00
18
+ date: 2010-07-22 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -123,6 +123,7 @@ files:
123
123
  - lib/capistrano/cli/help.rb
124
124
  - lib/capistrano/cli/help.txt
125
125
  - lib/capistrano/cli/options.rb
126
+ - lib/capistrano/cli/tee_io.rb
126
127
  - lib/capistrano/cli/ui.rb
127
128
  - lib/capistrano/command.rb
128
129
  - lib/capistrano/configuration.rb