[Rubygems-developers] Anothor UI wrinkle.

Hugh Sasse hgs at dmu.ac.uk
Tue Jul 12 13:40:44 EDT 2005


On Tue, 12 Jul 2005, Doug Kearns wrote:

> Yes. I'm just starting to have a look at RubyGems and this is one of the
> first things I noticed.
>
> You can, of course, specify --include-dependencies as an option to
> 'install' but if you forget it's nice to have 'All' and 'None' as
> options.

A bit more flesh on the bones:


--- ./user_interaction.rb.orig  2004-08-27 19:35:32.000000000 +0100
+++ ./user_interaction.rb       2005-07-12 12:36:51.540093000 +0100
@@ -116,6 +116,52 @@
        end
        return result
      end
+
+    # Ask yes, no, skip all, or all or quit.
+    # Returns a true for yes, false for no, :skip for skip,
+    # :all, for all and  :quit for quit (if quit param is true).
+    def ask_yes_no_all(question, default=nil, quit = false)
+      qstr = case default
+      when nil
+        'ynasq'
+      when true
+        'Ynasq'
+      when false
+        'yNasq'
+      when :all
+        'ynAsq'
+      when :skip
+        'ynaSq'
+      when :quit
+        'ynasQ'
+      end
+      qstr.sub!(/q/i, '') unless quit
+
+      result = nil
+      say " y = yes (once), n = no (once), ..."
+      say " a = yes to all , s = skip (i.e. no) to all."
+      say " q = quit" if quit
+      say "Capitalisation signifies default""
+      while result.nil?
+        result = ask("#{question} [#{qstr}]")
+        result = case result
+        when /^y.*/i
+          true
+        when /^n.*/i
+          false
+        when /^a.*/i
+          :all
+        when /^s.*/i
+          :skip
+        when /^q.*/i
+          :quit if quit
+        else
+          default
+        end
+      end
+      return result
+    end
+

      # Ask a question.  Returns an answer.
      def ask(question)
--- ./remote_installer.rb.orig  2005-03-24 05:25:32.000000000 +0000
+++ ./remote_installer.rb       2005-07-12 18:34:55.576997000 +0100
@@ -477,9 +477,18 @@
      def install_dependencies(dependencies, force, install_dir)
        return if @options[:ignore_dependencies]
        installed_gems = []
+      all = nil
        dependencies.each do |dependency|
-        if @options[:include_dependencies] ||
-           ask_yes_no("Install required dependency #{dependency.name}?", true)
+        if @options[:include_dependencies] || all  ||
+           case ask_yes_no_all("Install required dependency #{dependency.name}?", true)
+            when :all
+              all = true
+              true
+            when true
+              true
+            else
+              false
+            end
            remote_installer =  RemoteInstaller.new(@options)
            installed_gems << remote_installer.install(
             dependency.name,


Any suggestions of a good way to test the living daylights out of
this?  I've not done any tests on it yet....

         Hugh


More information about the Rubygems-developers mailing list