Module: Dev::UI::StdoutRouter
- Defined in:
- lib/dev/ui/stdout_router.rb
Defined Under Namespace
Constant Summary collapse
- WRITE_WITHOUT_DEV_UI =
:write_without_dev_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.
8 9 10 |
# File 'lib/dev/ui/stdout_router.rb', line 8 def duplicate_output_to @duplicate_output_to end |
Class Method Details
.assert_enabled! ⇒ Object
133 134 135 |
# File 'lib/dev/ui/stdout_router.rb', line 133 def assert_enabled! raise NotEnabled unless enabled? end |
.disable ⇒ Object
160 161 162 163 164 165 |
# File 'lib/dev/ui/stdout_router.rb', line 160 def disable return false unless enabled?($stdout) && enabled?($stderr) deactivate($stdout) deactivate($stderr) true end |
.enable ⇒ Object
149 150 151 152 153 154 |
# File 'lib/dev/ui/stdout_router.rb', line 149 def enable return false if enabled?($stdout) || enabled?($stderr) activate($stdout, :stdout) activate($stderr, :stderr) true end |
.enabled?(stream = $stdout) ⇒ Boolean
156 157 158 |
# File 'lib/dev/ui/stdout_router.rb', line 156 def enabled?(stream = $stdout) stream.respond_to?(WRITE_WITHOUT_DEV_UI) end |
.ensure_activated ⇒ Object
TODO: remove this
145 146 147 |
# File 'lib/dev/ui/stdout_router.rb', line 145 def ensure_activated enable unless enabled? end |
.with_enabled ⇒ Object
137 138 139 140 141 142 |
# File 'lib/dev/ui/stdout_router.rb', line 137 def with_enabled enable yield ensure disable end |