[Rubygems-developers] Abstracted user interaction now complete...

Richard Kilmer rich at infoether.com
Fri Jun 11 12:00:07 EDT 2004


I abstracted the user interaction in RubyGems.  I replaced the
puts/print/gets/STDERR.puts/exit/exit! with a set of mixin module methods in
the module:

Gem::UserInteraction (lib/rubygems/user_interaction.rb)

All classes that called any of those prior functions now include
UserInteraction.  UserInteraction define the following methods:

 choose_from_list(question, list)
  => present question and array of strings (list) and return string, num

 ask(question)
  => ask a question, return the response (string)

 say(statement="")
  => output statement

 alert(statement, question=nil)
  => output INFO message and 'ask' optional question
 
 alert_warning(statement, question=nil)
  => output WARNING message and 'ask' optional question

 alert_error(statement, question=nil)
  => output ERROR message and 'ask' optional question

 terminate_interaction!(status=-1)
  => this should close the gems session immediately (exit!)

 terminate_interaction(status=0)
  => this should close the gems session (exit)

The goal is to create a helper class which will make replacing these module
methods on the fly with methods that 'hook' them and replace the default
(STDOUT/STDERR/STDIN) IO with an alternative (such as a graphical
interface).

Now onto building the gem <command> functions!

All functional tests continue (after a bit 'o work) to pass!

-rich




More information about the Rubygems-developers mailing list