Module: Dex::UI::StdoutRouter

Defined in:
lib/dex/ui/stdout_router.rb

Defined Under Namespace

Classes: Capture, Writer

Constant Summary collapse

WRITE_WITHOUT_DEX_UI =
:write_without_dex_ui
NotEnabled =
Class.new(StandardError)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.duplicate_output_toObject

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

Raises:



130
131
132
# File 'lib/dex/ui/stdout_router.rb', line 130

def assert_enabled!
  raise NotEnabled unless enabled?
end

.disableObject



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

.enableObject



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

Returns:

  • (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_activatedObject

TODO: remove this



142
143
144
# File 'lib/dex/ui/stdout_router.rb', line 142

def ensure_activated
  enable unless enabled?
end

.with_enabledObject



134
135
136
137
138
139
# File 'lib/dex/ui/stdout_router.rb', line 134

def with_enabled
  enable
  yield
ensure
  disable
end