theine 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/theine/worker.rb +12 -2
  2. metadata +18 -2
data/lib/theine/worker.rb CHANGED
@@ -76,7 +76,7 @@ module Theine
76
76
  end
77
77
 
78
78
  def stdout=(value)
79
- $orig_stdout = $stdout
79
+ patch_out_io($stdout, value)
80
80
  @stdout = value
81
81
  r, w = IO.pipe
82
82
  $stdout = w
@@ -84,7 +84,7 @@ module Theine
84
84
  end
85
85
 
86
86
  def stderr=(value)
87
- $orig_stderr = $stderr
87
+ patch_out_io($stderr, value)
88
88
  @stderr = value
89
89
  r, w = IO.pipe
90
90
  $stderr = w
@@ -96,6 +96,16 @@ module Theine
96
96
  end
97
97
 
98
98
  private
99
+ def patch_out_io(io, write_to)
100
+ # This is done because Rails 'remembers' $stdout in some places when it's
101
+ # loaded, for example for logging SQL in the Rails console.
102
+ # We have to pre-load Rails and at that point we do not know what to change
103
+ # $stdout to, so this is why we patch it here.
104
+ io.singleton_class.send :define_method, :write do |*args, &block|
105
+ write_to.write(*args, &block)
106
+ end
107
+ end
108
+
99
109
  def rails_reload!
100
110
  ActionDispatch::Reloader.cleanup!
101
111
  ActionDispatch::Reloader.prepare!
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: theine
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.8
5
+ version: 0.0.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jan Berdajs
@@ -10,7 +10,23 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2013-10-02 00:00:00.000000000 Z
13
- dependencies: []
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pry
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ none: false
28
+ prerelease: false
29
+ type: :runtime
14
30
  description: A Rails preloader for JRuby
15
31
  email: mrbrdo@mrbrdo.net
16
32
  executables: