~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to test/rubygems/mockgemui.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
require 'stringio'
2
 
require 'rubygems/user_interaction'
3
 
 
4
 
class MockGemUi < Gem::StreamUI
5
 
  class TermError < RuntimeError; end
6
 
 
7
 
  module TTY
8
 
 
9
 
    attr_accessor :tty
10
 
 
11
 
    def tty?()
12
 
      @tty = true unless defined?(@tty)
13
 
      @tty
14
 
    end
15
 
 
16
 
  end
17
 
 
18
 
  def initialize(input = "")
19
 
    ins = StringIO.new input
20
 
    outs = StringIO.new
21
 
    errs = StringIO.new
22
 
 
23
 
    ins.extend TTY
24
 
    outs.extend TTY
25
 
    errs.extend TTY
26
 
 
27
 
    super ins, outs, errs
28
 
 
29
 
    @terminated = false
30
 
  end
31
 
 
32
 
  def input
33
 
    @ins.string
34
 
  end
35
 
 
36
 
  def output
37
 
    @outs.string
38
 
  end
39
 
 
40
 
  def error
41
 
    @errs.string
42
 
  end
43
 
 
44
 
  def terminated?
45
 
    @terminated
46
 
  end
47
 
 
48
 
  def terminate_interaction(status=0)
49
 
    @terminated = true
50
 
 
51
 
    raise TermError unless status == 0
52
 
    raise Gem::SystemExitException, status
53
 
  end
54
 
 
55
 
end
56