Module: Dex::UI::StdoutRouter
- Defined in:
- lib/dex/ui/stdout_router.rb
Defined Under Namespace
Constant Summary collapse
- WRITE_WITHOUT_DEX_UI =
:write_without_dex_ui
- NotEnabled =
Class.new(StandardError)
Class Attribute Summary collapse
-
.duplicate_output_to ⇒ Object
Returns the value of attribute duplicate_output_to.
Class Method Summary collapse
- .assert_enabled! ⇒ Object
- .disable ⇒ Object
- .enable ⇒ Object
- .enabled?(stream = $stdout) ⇒ Boolean
-
.ensure_activated ⇒ Object
TODO: remove this.
- .with_enabled ⇒ Object
Class Attribute Details
.duplicate_output_to ⇒ Object
Returns the value of attribute duplicate_output_to.
7 8 9 |
# File 'lib/dex/ui/stdout_router.rb', line 7 def duplicate_output_to @duplicate_output_to end |
Class Method Details
.assert_enabled! ⇒ Object
130 131 132 |
# File 'lib/dex/ui/stdout_router.rb', line 130 def assert_enabled! raise NotEnabled unless enabled? end |
.disable ⇒ Object
157 158 159 160 161 162 |
# File 'lib/dex/ui/stdout_router.rb', line 157 def disable return false unless enabled?($stdout) && enabled?($stderr) deactivate($stdout) deactivate($stderr) true end |
.enable ⇒ Object
146 147 148 149 150 151 |
# File 'lib/dex/ui/stdout_router.rb', line 146 def enable return false if enabled?($stdout) || enabled?($stderr) activate($stdout, :stdout) activate($stderr, :stderr) true end |
.enabled?(stream = $stdout) ⇒ Boolean
153 154 155 |
# File 'lib/dex/ui/stdout_router.rb', line 153 def enabled?(stream = $stdout) stream.respond_to?(WRITE_WITHOUT_DEX_UI) end |
.ensure_activated ⇒ Object
TODO: remove this
142 143 144 |
# File 'lib/dex/ui/stdout_router.rb', line 142 def ensure_activated enable unless enabled? end |
.with_enabled ⇒ Object
134 135 136 137 138 139 |
# File 'lib/dex/ui/stdout_router.rb', line 134 def with_enabled enable yield ensure disable end |