Class: OpalClosedTtyIO
- Inherits:
-
IO
- Object
- IO
- OpalClosedTtyIO
- Includes:
- IO::Writable
- Defined in:
- opal/opal/rspec/formatter/opal_closed_tty_io.rb
Instance Method Summary collapse
-
#closed? ⇒ Boolean
We're deferring to stdout here, which doesn't need to be closed, but RSpec::BaseTextFormatter doesn't know that, so override this.
-
#initialize(runner_type, io_type) ⇒ OpalClosedTtyIO
constructor
A new instance of OpalClosedTtyIO.
Constructor Details
#initialize(runner_type, io_type) ⇒ OpalClosedTtyIO
Returns a new instance of OpalClosedTtyIO.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'opal/opal/rspec/formatter/opal_closed_tty_io.rb', line 4 def initialize(runner_type, io_type) raise "Unknown IO type #{io_type}!" unless [:stdout, :stderr].include?(io_type) self.write_proc = case runner_type when :phantom `function(str){callPhantom([#{io_type}, str])}` when :node, :browser # opal io is already node aware, browser works as well, but we can't do anything about puts vs. print with the browser case io_type when :stdout $stdout.write_proc when :stderr $stderr.write_proc end else raise "Unknown runner type #{runner_type}" end @tty = true end |
Instance Method Details
#closed? ⇒ Boolean
We're deferring to stdout here, which doesn't need to be closed, but RSpec::BaseTextFormatter doesn't know that, so override this
24 25 26 |
# File 'opal/opal/rspec/formatter/opal_closed_tty_io.rb', line 24 def closed? true end |