Module: Gem::DefaultUserInteraction

Included in:
StreamUI::SimpleProgressReporter, StreamUI::VerboseProgressReporter, TestCase, UserInteraction
Defined in:
lib/rubygems/test_case.rb,
lib/rubygems/user_interaction.rb

Overview

Module that defines the default UserInteraction. Any class including this module will have access to the ui method that returns the default UI.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.uiObject

Return the default UI.


26
27
28
# File 'lib/rubygems/user_interaction.rb', line 26

def self.ui
  @ui ||= Gem::ConsoleUI.new
end

.ui=(new_ui) ⇒ Object

Set the default UI. If the default UI is never explicitly set, a simple console based UserInteraction will be used automatically.


34
35
36
# File 'lib/rubygems/user_interaction.rb', line 34

def self.ui=(new_ui)
  @ui = new_ui
end

.use_ui(new_ui) ⇒ Object

Use new_ui for the duration of block.


41
42
43
44
45
46
47
# File 'lib/rubygems/user_interaction.rb', line 41

def self.use_ui(new_ui)
  old_ui = @ui
  @ui = new_ui
  yield
ensure
  @ui = old_ui
end

Instance Method Details

#uiObject

See DefaultUserInteraction::ui


52
53
54
# File 'lib/rubygems/user_interaction.rb', line 52

def ui
  Gem::DefaultUserInteraction.ui
end

#ui=(new_ui) ⇒ Object

See DefaultUserInteraction::ui=


59
60
61
# File 'lib/rubygems/user_interaction.rb', line 59

def ui=(new_ui)
  Gem::DefaultUserInteraction.ui = new_ui
end

#use_ui(new_ui, &block) ⇒ Object

See DefaultUserInteraction::use_ui


66
67
68
# File 'lib/rubygems/user_interaction.rb', line 66

def use_ui(new_ui, &block)
  Gem::DefaultUserInteraction.use_ui(new_ui, &block)
end