solutious/rudy

PATCH: make the Yes option (Annoy's enable_skip) something you can put in the config file

Closed this issue · 2 comments

Quick patch to add this feature. Works for me. I wish github let you attach files rather than paste.

diff -wur rudy-0.7.4.orig/lib/rudy/global.rb rudy-0.7.4/lib/rudy/global.rb
--- rudy-0.7.4.orig/lib/rudy/global.rb  2009-05-11 19:04:36.000000000 -0700
+++ rudy-0.7.4/lib/rudy/global.rb   2009-05-12 13:01:23.000000000 -0700
@@ -56,7 +56,7 @@
       if config.defaults?
         # Apply the "color" default before "nocolor" so nocolor has presedence
         @nocolor = !config.defaults.color unless config.defaults.color.nil?
-        %w[region zone environment role position user nocolor quiet].each do |name|
+        %w[region zone environment role position user nocolor quiet yes].each do |name|
           val = config.defaults.send(name)
           self.send("#{name}=", val) unless val.nil?
         end
@@ -101,6 +101,7 @@
       @position &&= @position.to_s.rjust(2, '0')  
       @format &&= @format.to_sym rescue nil
       @quiet ? Rudy.enable_quiet : Rudy.disable_quiet
+      @yes ? Rudy.enable_yes : Rudy.disable_yes
     end

     def apply_environment_variables
diff -wur rudy-0.7.4.orig/lib/rudy.rb rudy-0.7.4/lib/rudy.rb
--- rudy-0.7.4.orig/lib/rudy.rb 2009-05-11 19:04:36.000000000 -0700
+++ rudy-0.7.4/lib/rudy.rb  2009-05-12 13:01:57.000000000 -0700
@@ -88,6 +88,7 @@
     }.freeze

     @@quiet = false
+    @@yes = false
     @@debug = false
     @@sysinfo = SysInfo.new.freeze

@@ -95,10 +96,13 @@

   def Rudy.debug?; @@debug == true; end
   def Rudy.quiet?; @@quiet == true; end
+  def Rudy.yes?; @@yes == true; end
   def Rudy.enable_debug; @@debug = true; end
   def Rudy.enable_quiet; @@quiet = true; end
+  def Rudy.enable_yes; @@yes = true; end
   def Rudy.disable_debug; @@debug = false; end
   def Rudy.disable_quiet; @@quiet = false; end
+  def Rudy.disable_yes; @@yes = false; end

   def Rudy.sysinfo; @@sysinfo; end
   def sysinfo; @@sysinfo;  end

[Edit: (2009-05-12) Updated diff formatting -- delano]

Support yes in config file. Closed by d53a00b (sabat)

I've included the patch in the master and 0.8 branches. It won't be available in a gem until 0.8.0 (which will be out in a week or two).