Sha256: 505a2ab0bc434f15e5a7d8c280d18293a2f5a4364ca8b5833313d6c4280da417

Contents?: true

Size: 873 Bytes

Versions: 2

Compression:

Stored size: 873 Bytes

Contents

#!/usr/bin/env ruby
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++


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
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubygems-update-1.3.0 test/mockgemui.rb
rubygems-update-1.3.1 test/mockgemui.rb