Sha256: 783f8f08ede9e11f5a3ceeeae392d07e66d491a0e35b8f491cadaa4b668c04a4

Contents?: true

Size: 777 Bytes

Versions: 12

Compression:

Stored size: 777 Bytes

Contents

require 'stringio'
require 'rubygems/user_interaction'

class MockGemUi < Gem::StreamUI
  class TermError < RuntimeError; end

  module TTY

    attr_accessor :tty

    def tty?()
      @tty = true unless defined?(@tty)
      @tty
    end

  end

  def initialize(input = "")
    ins = StringIO.new input
    outs = StringIO.new
    errs = StringIO.new

    ins.extend TTY
    outs.extend TTY
    errs.extend TTY

    super ins, outs, errs

    @terminated = false
  end

  def input
    @ins.string
  end

  def output
    @outs.string
  end

  def error
    @errs.string
  end

  def terminated?
    @terminated
  end

  def terminate_interaction(status=0)
    @terminated = true

    raise TermError unless status == 0
    raise Gem::SystemExitException, status
  end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
slimgems-1.3.9.5 test/mockgemui.rb
slimgems-1.3.9.4 test/mockgemui.rb
slimgems-1.3.9.3 test/mockgemui.rb
slimgems-1.3.9.2 test/mockgemui.rb
slimgems-1.3.9.1 test/mockgemui.rb
slimgems-1.3.9 test/mockgemui.rb
slimgems-1.3.8 test/mockgemui.rb
rubygems-update-1.4.2 test/mockgemui.rb
rubygems-update-1.4.1 test/mockgemui.rb
rubygems-update-1.4.0 test/mockgemui.rb
rubygems-update-1.3.7 test/mockgemui.rb
rubygems-update-1.3.6 test/mockgemui.rb