guessmethod 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
 - data/Manifest.txt +7 -0
 - data/bin/grake +6 -0
 - data/lib/guessmethod/constant.rb +40 -0
 - data/lib/guessmethod/guesser.rb +21 -0
 - data/lib/guessmethod/method.rb +27 -0
 - data/lib/guessmethod/options.rb +10 -0
 - data/lib/guessmethod/outputter.rb +105 -0
 - data/lib/guessmethod/rake.rb +46 -0
 - data/lib/guessmethod/version.rb +3 -3
 - data/lib/guessmethod.rb +6 -174
 - data/website/index.html +22 -3
 - data/website/index.txt +16 -1
 - metadata +61 -47
 
    
        data/History.txt
    CHANGED
    
    | 
         @@ -1,3 +1,9 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            == 0.2.0 2007-12-06
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            * GuessRakeTask is all new.  It's GuessMethod for rake!
         
     | 
| 
      
 4 
     | 
    
         
            +
            * bin/grake
         
     | 
| 
      
 5 
     | 
    
         
            +
            * Split GuessMethod into various files in lib.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       1 
7 
     | 
    
         
             
            == 0.1.3 2007-11-16
         
     | 
| 
       2 
8 
     | 
    
         | 
| 
       3 
9 
     | 
    
         
             
            * Cleaned up / reworked comments and spec to reflect the fact that the original method/const_missing goes first.
         
     | 
    
        data/Manifest.txt
    CHANGED
    
    | 
         @@ -5,7 +5,14 @@ README.txt 
     | 
|
| 
       5 
5 
     | 
    
         
             
            Rakefile
         
     | 
| 
       6 
6 
     | 
    
         
             
            lib/guessmethod.rb
         
     | 
| 
       7 
7 
     | 
    
         
             
            lib/guessmethod/version.rb
         
     | 
| 
      
 8 
     | 
    
         
            +
            lib/guessmethod/guesser.rb
         
     | 
| 
      
 9 
     | 
    
         
            +
            lib/guessmethod/constant.rb
         
     | 
| 
      
 10 
     | 
    
         
            +
            lib/guessmethod/outputter.rb
         
     | 
| 
      
 11 
     | 
    
         
            +
            lib/guessmethod/method.rb
         
     | 
| 
      
 12 
     | 
    
         
            +
            lib/guessmethod/rake.rb
         
     | 
| 
      
 13 
     | 
    
         
            +
            lib/guessmethod/options.rb
         
     | 
| 
       8 
14 
     | 
    
         
             
            lib/string/levenshtein.rb
         
     | 
| 
      
 15 
     | 
    
         
            +
            bin/grake
         
     | 
| 
       9 
16 
     | 
    
         
             
            scripts/txt2html
         
     | 
| 
       10 
17 
     | 
    
         
             
            setup.rb
         
     | 
| 
       11 
18 
     | 
    
         
             
            spec/guessmethod_spec.rb
         
     | 
    
        data/bin/grake
    ADDED
    
    
| 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module GuessMethod
         
     | 
| 
      
 2 
     | 
    
         
            +
              # The GuessConstant module aliases out const_missing and
         
     | 
| 
      
 3 
     | 
    
         
            +
              # replaces it with its own, which attempts to find a
         
     | 
| 
      
 4 
     | 
    
         
            +
              # similarly named constant for the object at hand
         
     | 
| 
      
 5 
     | 
    
         
            +
              # if the original method_missing fails.
         
     | 
| 
      
 6 
     | 
    
         
            +
              module GuessConstant
         
     | 
| 
      
 7 
     | 
    
         
            +
                def self.extended(base)   #:nodoc:
         
     | 
| 
      
 8 
     | 
    
         
            +
                  base.class_eval do
         
     | 
| 
      
 9 
     | 
    
         
            +
                    class << self
         
     | 
| 
      
 10 
     | 
    
         
            +
                      alias_method :unguessed_const_missing, :const_missing
         
     | 
| 
      
 11 
     | 
    
         
            +
                      alias_method :const_missing, :guess_const_missing
         
     | 
| 
      
 12 
     | 
    
         
            +
                    end
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                def guess_const_missing(sym)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  if GuessMethodOptions[:active]
         
     | 
| 
      
 18 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 19 
     | 
    
         
            +
                      return unguessed_const_missing(sym)
         
     | 
| 
      
 20 
     | 
    
         
            +
                    rescue NameError => e
         
     | 
| 
      
 21 
     | 
    
         
            +
                      possible_consts = GuessMethodGuesser.find_closest(self.constants, sym)
         
     | 
| 
      
 22 
     | 
    
         
            +
                      case possible_consts.size
         
     | 
| 
      
 23 
     | 
    
         
            +
                      when 1
         
     | 
| 
      
 24 
     | 
    
         
            +
                        call_const = possible_consts.first
         
     | 
| 
      
 25 
     | 
    
         
            +
                        $stderr.puts GuessMethodOutputter.replacing_const(sym, call_const, self)
         
     | 
| 
      
 26 
     | 
    
         
            +
                        self.const_get(call_const)
         
     | 
| 
      
 27 
     | 
    
         
            +
                      when 0
         
     | 
| 
      
 28 
     | 
    
         
            +
                        $stderr.puts GuessMethodOutputter.no_const_in_threshold(sym, self)
         
     | 
| 
      
 29 
     | 
    
         
            +
                        raise e
         
     | 
| 
      
 30 
     | 
    
         
            +
                      else
         
     | 
| 
      
 31 
     | 
    
         
            +
                        $stderr.puts GuessMethodOutputter.ambigious_const(sym, possible_consts, self)
         
     | 
| 
      
 32 
     | 
    
         
            +
                        raise e
         
     | 
| 
      
 33 
     | 
    
         
            +
                      end
         
     | 
| 
      
 34 
     | 
    
         
            +
                    end
         
     | 
| 
      
 35 
     | 
    
         
            +
                  else
         
     | 
| 
      
 36 
     | 
    
         
            +
                    unguessed_const_missing(sym)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'guessmethod/options'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'string/levenshtein'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module GuessMethod
         
     | 
| 
      
 5 
     | 
    
         
            +
              # GuessMethodGuesser uses map, min, and levensthtein to find the closest
         
     | 
| 
      
 6 
     | 
    
         
            +
              # match(es) in an array of strings
         
     | 
| 
      
 7 
     | 
    
         
            +
              class GuessMethodGuesser
         
     | 
| 
      
 8 
     | 
    
         
            +
                def self.find_closest(haystack, needle)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  closest_distance = haystack.map {|x| x.to_s.downcase.levenshtein(needle.to_s.downcase,
         
     | 
| 
      
 10 
     | 
    
         
            +
                      GuessMethodOptions[:insert_weight], GuessMethodOptions[:delete_weight],
         
     | 
| 
      
 11 
     | 
    
         
            +
                      GuessMethodOptions[:substitution_weight])}.min || 0
         
     | 
| 
      
 12 
     | 
    
         
            +
                  if closest_distance <= GuessMethodOptions[:threshold]
         
     | 
| 
      
 13 
     | 
    
         
            +
                    haystack.find_all {|x| x.to_s.downcase.levenshtein(needle.to_s.downcase,
         
     | 
| 
      
 14 
     | 
    
         
            +
                        GuessMethodOptions[:insert_weight], GuessMethodOptions[:delete_weight],
         
     | 
| 
      
 15 
     | 
    
         
            +
                        GuessMethodOptions[:substitution_weight]) == closest_distance}
         
     | 
| 
      
 16 
     | 
    
         
            +
                  else
         
     | 
| 
      
 17 
     | 
    
         
            +
                    []
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module GuessMethod
         
     | 
| 
      
 2 
     | 
    
         
            +
              
         
     | 
| 
      
 3 
     | 
    
         
            +
              def guess_method_missing(meth, *args, &block)
         
     | 
| 
      
 4 
     | 
    
         
            +
                if GuessMethodOptions[:active]
         
     | 
| 
      
 5 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 6 
     | 
    
         
            +
                    unguessed_method_missing(meth, *args, &block)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  rescue NoMethodError, NameError => e
         
     | 
| 
      
 8 
     | 
    
         
            +
                    possible_methods = GuessMethodGuesser.find_closest(self.methods, meth)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    case possible_methods.size
         
     | 
| 
      
 10 
     | 
    
         
            +
                    when 1
         
     | 
| 
      
 11 
     | 
    
         
            +
                      call_method = possible_methods.first
         
     | 
| 
      
 12 
     | 
    
         
            +
                      $stderr.puts GuessMethodOutputter.replacing_method(meth, call_method, self)
         
     | 
| 
      
 13 
     | 
    
         
            +
                      self.send(call_method, *args, &block)
         
     | 
| 
      
 14 
     | 
    
         
            +
                    when 0
         
     | 
| 
      
 15 
     | 
    
         
            +
                      $stderr.puts GuessMethodOutputter.no_method_in_threshold(meth, self)
         
     | 
| 
      
 16 
     | 
    
         
            +
                      raise e
         
     | 
| 
      
 17 
     | 
    
         
            +
                    else
         
     | 
| 
      
 18 
     | 
    
         
            +
                      $stderr.puts GuessMethodOutputter.ambiguous_method(meth, possible_methods, self)
         
     | 
| 
      
 19 
     | 
    
         
            +
                      raise e
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
                else
         
     | 
| 
      
 23 
     | 
    
         
            +
                  unguessed_method_missing(meth, *args, &block)
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
              
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,105 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module GuessMethod
         
     | 
| 
      
 2 
     | 
    
         
            +
              # GuessMethodOutputter uses a little Formatter class for colorization
         
     | 
| 
      
 3 
     | 
    
         
            +
              class GuessMethodOutputter
         
     | 
| 
      
 4 
     | 
    
         
            +
                
         
     | 
| 
      
 5 
     | 
    
         
            +
                class Formatter
         
     | 
| 
      
 6 
     | 
    
         
            +
                  ColorCodes = {
         
     | 
| 
      
 7 
     | 
    
         
            +
                    :bold  => '1',
         
     | 
| 
      
 8 
     | 
    
         
            +
                    :red   => '31',
         
     | 
| 
      
 9 
     | 
    
         
            +
                    :green => '32',
         
     | 
| 
      
 10 
     | 
    
         
            +
                    :cyan  => '36'
         
     | 
| 
      
 11 
     | 
    
         
            +
                  }
         
     | 
| 
      
 12 
     | 
    
         
            +
                  
         
     | 
| 
      
 13 
     | 
    
         
            +
                  # Returns an ANSI colorized string (for a limited set of options, see ColorCodes)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  def self.color(text, *colors)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    format = colors.map {|color| ColorCodes[color]}.join(';')
         
     | 
| 
      
 16 
     | 
    
         
            +
                    "\e[#{format}m#{text}\e[0m"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                def self.object(obj)  #:nodoc:
         
     | 
| 
      
 21 
     | 
    
         
            +
                  inspected = obj.inspect
         
     | 
| 
      
 22 
     | 
    
         
            +
                  if obj.inspect.length > GuessMethodOptions[:max_inspect_length]
         
     | 
| 
      
 23 
     | 
    
         
            +
                    Formatter.color("#<#{obj.class}:0x#{(obj.object_id*2).to_s(16)}>", :green)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  else
         
     | 
| 
      
 25 
     | 
    
         
            +
                    Formatter.color(obj.inspect, :green, :bold) << ':' << Formatter.color(obj.class, :green)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
                
         
     | 
| 
      
 29 
     | 
    
         
            +
                def self.ambiguous_method(meth, possibilities, obj) #:nodoc:
         
     | 
| 
      
 30 
     | 
    
         
            +
                  Formatter.color('ambigious method:', :red) <<
         
     | 
| 
      
 31 
     | 
    
         
            +
                  ' ' <<
         
     | 
| 
      
 32 
     | 
    
         
            +
                  Formatter.color(meth, :green) <<
         
     | 
| 
      
 33 
     | 
    
         
            +
                  ', possible matches ' <<
         
     | 
| 
      
 34 
     | 
    
         
            +
                  possibilities.map {|m| Formatter.color(m, :cyan)}.join(', ') <<
         
     | 
| 
      
 35 
     | 
    
         
            +
                  ' for ' <<
         
     | 
| 
      
 36 
     | 
    
         
            +
                  GuessMethodOutputter.object(obj)
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
                
         
     | 
| 
      
 39 
     | 
    
         
            +
                def self.no_method_in_threshold(meth, obj)  #:nodoc:
         
     | 
| 
      
 40 
     | 
    
         
            +
                  Formatter.color('no method in threshold: ', :red) <<
         
     | 
| 
      
 41 
     | 
    
         
            +
                  Formatter.color(meth, :green) <<
         
     | 
| 
      
 42 
     | 
    
         
            +
                  ' for ' <<
         
     | 
| 
      
 43 
     | 
    
         
            +
                  GuessMethodOutputter.object(obj)
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
                
         
     | 
| 
      
 46 
     | 
    
         
            +
                def self.replacing_method(meth, call_method, obj) #:nodoc:
         
     | 
| 
      
 47 
     | 
    
         
            +
                  Formatter.color('attention:', :red) <<
         
     | 
| 
      
 48 
     | 
    
         
            +
                  ' sending ' <<
         
     | 
| 
      
 49 
     | 
    
         
            +
                  Formatter.color(call_method, :cyan) <<
         
     | 
| 
      
 50 
     | 
    
         
            +
                  ' instead of ' <<
         
     | 
| 
      
 51 
     | 
    
         
            +
                  Formatter.color(meth, :cyan) <<
         
     | 
| 
      
 52 
     | 
    
         
            +
                  ' to ' <<
         
     | 
| 
      
 53 
     | 
    
         
            +
                  GuessMethodOutputter.object(obj)
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
                
         
     | 
| 
      
 56 
     | 
    
         
            +
                def self.ambigious_const(sym, possibilities, obj) #:nodoc:
         
     | 
| 
      
 57 
     | 
    
         
            +
                  Formatter.color('ambigious constant:', :red) <<
         
     | 
| 
      
 58 
     | 
    
         
            +
                  ' ' <<
         
     | 
| 
      
 59 
     | 
    
         
            +
                  Formatter.color(sym, :green) <<
         
     | 
| 
      
 60 
     | 
    
         
            +
                  ', possible matches ' <<
         
     | 
| 
      
 61 
     | 
    
         
            +
                  possibilities.map {|m| Formatter.color(m, :cyan)}.join(', ') <<
         
     | 
| 
      
 62 
     | 
    
         
            +
                  ' for ' <<
         
     | 
| 
      
 63 
     | 
    
         
            +
                  Formatter.color(obj, :green, :bold)
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
                
         
     | 
| 
      
 66 
     | 
    
         
            +
                def self.no_const_in_threshold(sym, obj) #:nodoc:
         
     | 
| 
      
 67 
     | 
    
         
            +
                  Formatter.color('no constant in threshold: ', :red) <<
         
     | 
| 
      
 68 
     | 
    
         
            +
                  Formatter.color(sym, :green) <<
         
     | 
| 
      
 69 
     | 
    
         
            +
                  ' for ' <<
         
     | 
| 
      
 70 
     | 
    
         
            +
                  Formatter.color(obj, :green, :bold)
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
                
         
     | 
| 
      
 73 
     | 
    
         
            +
                def self.replacing_const(sym, call_const, obj) #:nodoc:
         
     | 
| 
      
 74 
     | 
    
         
            +
                  Formatter.color('attention:', :red) <<
         
     | 
| 
      
 75 
     | 
    
         
            +
                  ' replacing non-existant constant ' <<
         
     | 
| 
      
 76 
     | 
    
         
            +
                  Formatter.color(sym, :cyan) <<
         
     | 
| 
      
 77 
     | 
    
         
            +
                  ' with ' <<
         
     | 
| 
      
 78 
     | 
    
         
            +
                  Formatter.color(call_const, :cyan) <<
         
     | 
| 
      
 79 
     | 
    
         
            +
                  ' for ' <<
         
     | 
| 
      
 80 
     | 
    
         
            +
                  Formatter.color(obj, :green, :bold)
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
                
         
     | 
| 
      
 83 
     | 
    
         
            +
                def self.replacing_rake_task(task, call_task) #:nodoc:
         
     | 
| 
      
 84 
     | 
    
         
            +
                  Formatter.color('attention:', :red) <<
         
     | 
| 
      
 85 
     | 
    
         
            +
                  ' invoking task ' <<
         
     | 
| 
      
 86 
     | 
    
         
            +
                  Formatter.color(call_task, :cyan) <<
         
     | 
| 
      
 87 
     | 
    
         
            +
                  ' instead of ' <<
         
     | 
| 
      
 88 
     | 
    
         
            +
                  Formatter.color(task, :cyan)
         
     | 
| 
      
 89 
     | 
    
         
            +
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
                
         
     | 
| 
      
 91 
     | 
    
         
            +
                def self.no_rake_task_in_threshold(task) #:nodoc:
         
     | 
| 
      
 92 
     | 
    
         
            +
                  Formatter.color('no rake task in threshold: ', :red) <<
         
     | 
| 
      
 93 
     | 
    
         
            +
                  Formatter.color(task, :green)
         
     | 
| 
      
 94 
     | 
    
         
            +
                end
         
     | 
| 
      
 95 
     | 
    
         
            +
                
         
     | 
| 
      
 96 
     | 
    
         
            +
                def self.ambigous_rake_task(task, possibilities) #:nodoc:
         
     | 
| 
      
 97 
     | 
    
         
            +
                  Formatter.color('ambigious rake task:', :red) <<
         
     | 
| 
      
 98 
     | 
    
         
            +
                  ' ' <<
         
     | 
| 
      
 99 
     | 
    
         
            +
                  Formatter.color(task, :green) <<
         
     | 
| 
      
 100 
     | 
    
         
            +
                  ', possible matches ' <<
         
     | 
| 
      
 101 
     | 
    
         
            +
                  possibilities.map {|m| Formatter.color(m, :cyan)}.join(', ')
         
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
                
         
     | 
| 
      
 104 
     | 
    
         
            +
              end
         
     | 
| 
      
 105 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,46 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'guessmethod/guesser'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'guessmethod/outputter'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # GuessRakeTask is pretty much a bad idea gone worse.  When included into
         
     | 
| 
      
 6 
     | 
    
         
            +
            # Rake::TaskManager, it overtakes TaskManager's [] method and tries to
         
     | 
| 
      
 7 
     | 
    
         
            +
            # guess when the task lookup fails.  Use via the grake command, or
         
     | 
| 
      
 8 
     | 
    
         
            +
            # by adding "require 'guessmethod/rake'" to the top of your Rakefiles.
         
     | 
| 
      
 9 
     | 
    
         
            +
            module GuessRakeTask
         
     | 
| 
      
 10 
     | 
    
         
            +
              
         
     | 
| 
      
 11 
     | 
    
         
            +
              def self.included(base)
         
     | 
| 
      
 12 
     | 
    
         
            +
                base.class_eval do
         
     | 
| 
      
 13 
     | 
    
         
            +
                  alias_method :unguessed_brackets, :[]
         
     | 
| 
      
 14 
     | 
    
         
            +
                  alias_method :[], :guess_brackets
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
              
         
     | 
| 
      
 18 
     | 
    
         
            +
              # GuessRakeTask's magic. Go for Rake::TaskManager's [] lookup first,
         
     | 
| 
      
 19 
     | 
    
         
            +
              # then guess at it if it fails.
         
     | 
| 
      
 20 
     | 
    
         
            +
              def guess_brackets(task_name, scopes=nil)
         
     | 
| 
      
 21 
     | 
    
         
            +
                begin
         
     | 
| 
      
 22 
     | 
    
         
            +
                  unguessed_brackets(task_name, scopes)
         
     | 
| 
      
 23 
     | 
    
         
            +
                rescue RuntimeError => e
         
     | 
| 
      
 24 
     | 
    
         
            +
                  possible_tasks = GuessMethod::GuessMethodGuesser.find_closest(@tasks.keys, task_name)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  case possible_tasks.size
         
     | 
| 
      
 26 
     | 
    
         
            +
                  when 1
         
     | 
| 
      
 27 
     | 
    
         
            +
                    task_to_call = possible_tasks.first
         
     | 
| 
      
 28 
     | 
    
         
            +
                    $stderr.puts GuessMethod::GuessMethodOutputter.replacing_rake_task(task_name, task_to_call)
         
     | 
| 
      
 29 
     | 
    
         
            +
                    unguessed_brackets(task_to_call, scopes)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  when 0
         
     | 
| 
      
 31 
     | 
    
         
            +
                    $stderr.puts GuessMethod::GuessMethodOutputter.no_rake_task_in_threshold(task_name)
         
     | 
| 
      
 32 
     | 
    
         
            +
                    raise e
         
     | 
| 
      
 33 
     | 
    
         
            +
                  else
         
     | 
| 
      
 34 
     | 
    
         
            +
                    $stderr.puts GuessMethod::GuessMethodOutputter.ambigous_rake_task(task_name, possible_tasks)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    raise e
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
              
         
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            module Rake #:nodoc:
         
     | 
| 
      
 43 
     | 
    
         
            +
              module TaskManager #:nodoc:
         
     | 
| 
      
 44 
     | 
    
         
            +
                include GuessRakeTask
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/guessmethod/version.rb
    CHANGED
    
    
    
        data/lib/guessmethod.rb
    CHANGED
    
    | 
         @@ -1,20 +1,9 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'string/levenshtein'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
1 
     | 
    
         
             
            # The GuessMethod module aliases out method_missing and
         
     | 
| 
       4 
2 
     | 
    
         
             
            # replaces it with its own, which attempts to find a
         
     | 
| 
       5 
3 
     | 
    
         
             
            # similarly named method callable on the object at hand
         
     | 
| 
       6 
4 
     | 
    
         
             
            # if the objects original method_missing fails.
         
     | 
| 
       7 
5 
     | 
    
         
             
            module GuessMethod
         
     | 
| 
       8 
6 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
              GuessMethodOptions = {
         
     | 
| 
       10 
     | 
    
         
            -
                :insert_weight => 1,
         
     | 
| 
       11 
     | 
    
         
            -
                :delete_weight => 1,
         
     | 
| 
       12 
     | 
    
         
            -
                :substitution_weight => 1,
         
     | 
| 
       13 
     | 
    
         
            -
                :threshold => 2,
         
     | 
| 
       14 
     | 
    
         
            -
                :max_inspect_length => 25,
         
     | 
| 
       15 
     | 
    
         
            -
                :active => true
         
     | 
| 
       16 
     | 
    
         
            -
              }
         
     | 
| 
       17 
     | 
    
         
            -
              
         
     | 
| 
       18 
7 
     | 
    
         
             
              def self.included(base)
         
     | 
| 
       19 
8 
     | 
    
         
             
                base.class_eval do
         
     | 
| 
       20 
9 
     | 
    
         
             
                  unless method_defined? :method_missing
         
     | 
| 
         @@ -27,172 +16,15 @@ module GuessMethod 
     | 
|
| 
       27 
16 
     | 
    
         
             
                end
         
     | 
| 
       28 
17 
     | 
    
         
             
              end
         
     | 
| 
       29 
18 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
              def guess_method_missing(meth, *args, &block)
         
     | 
| 
       31 
     | 
    
         
            -
                if GuessMethodOptions[:active]
         
     | 
| 
       32 
     | 
    
         
            -
                  begin
         
     | 
| 
       33 
     | 
    
         
            -
                    unguessed_method_missing(meth, *args, &block)
         
     | 
| 
       34 
     | 
    
         
            -
                  rescue NoMethodError, NameError => e
         
     | 
| 
       35 
     | 
    
         
            -
                    possible_methods = GuessMethodGuesser.find_closest(self.methods, meth)
         
     | 
| 
       36 
     | 
    
         
            -
                    case possible_methods.size
         
     | 
| 
       37 
     | 
    
         
            -
                    when 1
         
     | 
| 
       38 
     | 
    
         
            -
                      call_method = possible_methods.first
         
     | 
| 
       39 
     | 
    
         
            -
                      $stderr.puts GuessMethodOutputter.replacing_method(meth, call_method, self)
         
     | 
| 
       40 
     | 
    
         
            -
                      self.send(call_method, *args, &block)
         
     | 
| 
       41 
     | 
    
         
            -
                    when 0
         
     | 
| 
       42 
     | 
    
         
            -
                      $stderr.puts GuessMethodOutputter.no_method_in_threshold(meth, self)
         
     | 
| 
       43 
     | 
    
         
            -
                      raise e
         
     | 
| 
       44 
     | 
    
         
            -
                    else
         
     | 
| 
       45 
     | 
    
         
            -
                      $stderr.puts GuessMethodOutputter.ambiguous_method(meth, possible_methods, self)
         
     | 
| 
       46 
     | 
    
         
            -
                      raise e
         
     | 
| 
       47 
     | 
    
         
            -
                    end
         
     | 
| 
       48 
     | 
    
         
            -
                  end
         
     | 
| 
       49 
     | 
    
         
            -
                else
         
     | 
| 
       50 
     | 
    
         
            -
                  unguessed_method_missing(meth, *args, &block)
         
     | 
| 
       51 
     | 
    
         
            -
                end
         
     | 
| 
       52 
     | 
    
         
            -
              end
         
     | 
| 
       53 
     | 
    
         
            -
              
         
     | 
| 
       54 
     | 
    
         
            -
              # The GuessConstant module aliases out const_missing and
         
     | 
| 
       55 
     | 
    
         
            -
              # replaces it with its own, which attempts to find a
         
     | 
| 
       56 
     | 
    
         
            -
              # similarly named constant for the object at hand
         
     | 
| 
       57 
     | 
    
         
            -
              # if the original method_missing fails.
         
     | 
| 
       58 
     | 
    
         
            -
              module GuessConstant
         
     | 
| 
       59 
     | 
    
         
            -
                def self.extended(base)   #:nodoc:
         
     | 
| 
       60 
     | 
    
         
            -
                  base.class_eval do
         
     | 
| 
       61 
     | 
    
         
            -
                    class << self
         
     | 
| 
       62 
     | 
    
         
            -
                      alias_method :unguessed_const_missing, :const_missing
         
     | 
| 
       63 
     | 
    
         
            -
                      alias_method :const_missing, :guess_const_missing
         
     | 
| 
       64 
     | 
    
         
            -
                    end
         
     | 
| 
       65 
     | 
    
         
            -
                  end
         
     | 
| 
       66 
     | 
    
         
            -
                end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                def guess_const_missing(sym)
         
     | 
| 
       69 
     | 
    
         
            -
                  if GuessMethodOptions[:active]
         
     | 
| 
       70 
     | 
    
         
            -
                    begin
         
     | 
| 
       71 
     | 
    
         
            -
                      return unguessed_const_missing(sym)
         
     | 
| 
       72 
     | 
    
         
            -
                    rescue NameError => e
         
     | 
| 
       73 
     | 
    
         
            -
                      possible_consts = GuessMethodGuesser.find_closest(self.constants, sym)
         
     | 
| 
       74 
     | 
    
         
            -
                      case possible_consts.size
         
     | 
| 
       75 
     | 
    
         
            -
                      when 1
         
     | 
| 
       76 
     | 
    
         
            -
                        call_const = possible_consts.first
         
     | 
| 
       77 
     | 
    
         
            -
                        $stderr.puts GuessMethodOutputter.replacing_const(sym, call_const, self)
         
     | 
| 
       78 
     | 
    
         
            -
                        self.const_get(call_const)
         
     | 
| 
       79 
     | 
    
         
            -
                      when 0
         
     | 
| 
       80 
     | 
    
         
            -
                        $stderr.puts GuessMethodOutputter.no_const_in_threshold(sym, self)
         
     | 
| 
       81 
     | 
    
         
            -
                        raise e
         
     | 
| 
       82 
     | 
    
         
            -
                      else
         
     | 
| 
       83 
     | 
    
         
            -
                        $stderr.puts GuessMethodOutputter.ambigious_const(sym, possible_consts, self)
         
     | 
| 
       84 
     | 
    
         
            -
                        raise e
         
     | 
| 
       85 
     | 
    
         
            -
                      end
         
     | 
| 
       86 
     | 
    
         
            -
                    end
         
     | 
| 
       87 
     | 
    
         
            -
                  else
         
     | 
| 
       88 
     | 
    
         
            -
                    unguessed_const_missing(sym)
         
     | 
| 
       89 
     | 
    
         
            -
                  end
         
     | 
| 
       90 
     | 
    
         
            -
                end
         
     | 
| 
       91 
     | 
    
         
            -
              end
         
     | 
| 
       92 
     | 
    
         
            -
              
         
     | 
| 
       93 
     | 
    
         
            -
              # GuessMethodGuesser uses map, min, and levensthtein to find the closest
         
     | 
| 
       94 
     | 
    
         
            -
              # match(es) in an array of strings
         
     | 
| 
       95 
     | 
    
         
            -
              class GuessMethodGuesser
         
     | 
| 
       96 
     | 
    
         
            -
                def self.find_closest(haystack, needle)
         
     | 
| 
       97 
     | 
    
         
            -
                  closest_distance = haystack.map {|x| x.to_s.downcase.levenshtein(needle.to_s.downcase,
         
     | 
| 
       98 
     | 
    
         
            -
                      GuessMethodOptions[:insert_weight], GuessMethodOptions[:delete_weight],
         
     | 
| 
       99 
     | 
    
         
            -
                      GuessMethodOptions[:substitution_weight])}.min || 0
         
     | 
| 
       100 
     | 
    
         
            -
                  if closest_distance <= GuessMethodOptions[:threshold]
         
     | 
| 
       101 
     | 
    
         
            -
                    haystack.find_all {|x| x.to_s.downcase.levenshtein(needle.to_s.downcase,
         
     | 
| 
       102 
     | 
    
         
            -
                        GuessMethodOptions[:insert_weight], GuessMethodOptions[:delete_weight],
         
     | 
| 
       103 
     | 
    
         
            -
                        GuessMethodOptions[:substitution_weight]) == closest_distance}
         
     | 
| 
       104 
     | 
    
         
            -
                  else
         
     | 
| 
       105 
     | 
    
         
            -
                    []
         
     | 
| 
       106 
     | 
    
         
            -
                  end
         
     | 
| 
       107 
     | 
    
         
            -
                end
         
     | 
| 
       108 
     | 
    
         
            -
              end
         
     | 
| 
       109 
     | 
    
         
            -
              
         
     | 
| 
       110 
     | 
    
         
            -
              # GuessMethodOutputter uses a little Formatter class for colorization
         
     | 
| 
       111 
     | 
    
         
            -
              class GuessMethodOutputter
         
     | 
| 
       112 
     | 
    
         
            -
                
         
     | 
| 
       113 
     | 
    
         
            -
                class Formatter
         
     | 
| 
       114 
     | 
    
         
            -
                  ColorCodes = {
         
     | 
| 
       115 
     | 
    
         
            -
                    :bold  => '1',
         
     | 
| 
       116 
     | 
    
         
            -
                    :red   => '31',
         
     | 
| 
       117 
     | 
    
         
            -
                    :green => '32',
         
     | 
| 
       118 
     | 
    
         
            -
                    :cyan  => '36'
         
     | 
| 
       119 
     | 
    
         
            -
                  }
         
     | 
| 
       120 
     | 
    
         
            -
                  
         
     | 
| 
       121 
     | 
    
         
            -
                  # Returns an ANSI colorized string (for a limited set of options, see ColorCodes)
         
     | 
| 
       122 
     | 
    
         
            -
                  def self.color(text, *colors)
         
     | 
| 
       123 
     | 
    
         
            -
                    format = colors.map {|color| ColorCodes[color]}.join(';')
         
     | 
| 
       124 
     | 
    
         
            -
                    "\e[#{format}m#{text}\e[0m"
         
     | 
| 
       125 
     | 
    
         
            -
                  end
         
     | 
| 
       126 
     | 
    
         
            -
                end
         
     | 
| 
       127 
     | 
    
         
            -
                
         
     | 
| 
       128 
     | 
    
         
            -
                def self.object(obj)  #:nodoc:
         
     | 
| 
       129 
     | 
    
         
            -
                  inspected = obj.inspect
         
     | 
| 
       130 
     | 
    
         
            -
                  if obj.inspect.length > GuessMethodOptions[:max_inspect_length]
         
     | 
| 
       131 
     | 
    
         
            -
                    Formatter.color("#<#{obj.class}:0x#{(obj.object_id*2).to_s(16)}>", :green)
         
     | 
| 
       132 
     | 
    
         
            -
                  else
         
     | 
| 
       133 
     | 
    
         
            -
                    Formatter.color(obj.inspect, :green, :bold) << ':' << Formatter.color(obj.class, :green)
         
     | 
| 
       134 
     | 
    
         
            -
                  end
         
     | 
| 
       135 
     | 
    
         
            -
                end
         
     | 
| 
       136 
     | 
    
         
            -
                
         
     | 
| 
       137 
     | 
    
         
            -
                def self.ambiguous_method(meth, possibilities, obj) #:nodoc:
         
     | 
| 
       138 
     | 
    
         
            -
                  Formatter.color('ambigious method:', :red) <<
         
     | 
| 
       139 
     | 
    
         
            -
                  ' ' <<
         
     | 
| 
       140 
     | 
    
         
            -
                  Formatter.color(meth, :green) <<
         
     | 
| 
       141 
     | 
    
         
            -
                  ' possible matches ' <<
         
     | 
| 
       142 
     | 
    
         
            -
                  possibilities.map {|m| Formatter.color(m, :cyan)}.join(', ') <<
         
     | 
| 
       143 
     | 
    
         
            -
                  ' for ' <<
         
     | 
| 
       144 
     | 
    
         
            -
                  GuessMethodOutputter.object(obj)
         
     | 
| 
       145 
     | 
    
         
            -
                end
         
     | 
| 
       146 
     | 
    
         
            -
                
         
     | 
| 
       147 
     | 
    
         
            -
                def self.no_method_in_threshold(meth, obj)  #:nodoc:
         
     | 
| 
       148 
     | 
    
         
            -
                  Formatter.color('no method in threshold: ', :red) <<
         
     | 
| 
       149 
     | 
    
         
            -
                  Formatter.color(meth, :green) <<
         
     | 
| 
       150 
     | 
    
         
            -
                  ' for ' <<
         
     | 
| 
       151 
     | 
    
         
            -
                  GuessMethodOutputter.object(obj)
         
     | 
| 
       152 
     | 
    
         
            -
                end
         
     | 
| 
       153 
     | 
    
         
            -
                
         
     | 
| 
       154 
     | 
    
         
            -
                def self.replacing_method(meth, call_method, obj) #:nodoc:
         
     | 
| 
       155 
     | 
    
         
            -
                  Formatter.color('attention:', :red) <<
         
     | 
| 
       156 
     | 
    
         
            -
                  ' sending ' <<
         
     | 
| 
       157 
     | 
    
         
            -
                  Formatter.color(call_method, :cyan) <<
         
     | 
| 
       158 
     | 
    
         
            -
                  ' instead of ' <<
         
     | 
| 
       159 
     | 
    
         
            -
                  Formatter.color(meth, :cyan) <<
         
     | 
| 
       160 
     | 
    
         
            -
                  ' to ' <<
         
     | 
| 
       161 
     | 
    
         
            -
                  GuessMethodOutputter.object(obj)
         
     | 
| 
       162 
     | 
    
         
            -
                end
         
     | 
| 
       163 
     | 
    
         
            -
                
         
     | 
| 
       164 
     | 
    
         
            -
                def self.ambigious_const(sym, possibilities, obj) #:nodoc:
         
     | 
| 
       165 
     | 
    
         
            -
                  Formatter.color('ambigious constant:', :red) <<
         
     | 
| 
       166 
     | 
    
         
            -
                  ' ' <<
         
     | 
| 
       167 
     | 
    
         
            -
                  Formatter.color(sym, :green) <<
         
     | 
| 
       168 
     | 
    
         
            -
                  ' possible matches ' <<
         
     | 
| 
       169 
     | 
    
         
            -
                  possibilities.map {|m| Formatter.color(m, :cyan)}.join(', ') <<
         
     | 
| 
       170 
     | 
    
         
            -
                  ' for ' <<
         
     | 
| 
       171 
     | 
    
         
            -
                  Formatter.color(obj, :green, :bold)
         
     | 
| 
       172 
     | 
    
         
            -
                end
         
     | 
| 
       173 
     | 
    
         
            -
                
         
     | 
| 
       174 
     | 
    
         
            -
                def self.no_const_in_threshold(sym, obj) #:nodoc:
         
     | 
| 
       175 
     | 
    
         
            -
                  Formatter.color('no constant in threshold: ', :red) <<
         
     | 
| 
       176 
     | 
    
         
            -
                  Formatter.color(sym, :green) <<
         
     | 
| 
       177 
     | 
    
         
            -
                  ' for ' <<
         
     | 
| 
       178 
     | 
    
         
            -
                  Formatter.color(obj, :green, :bold)
         
     | 
| 
       179 
     | 
    
         
            -
                end
         
     | 
| 
       180 
     | 
    
         
            -
                
         
     | 
| 
       181 
     | 
    
         
            -
                def self.replacing_const(sym, call_const, obj) #:nodoc:
         
     | 
| 
       182 
     | 
    
         
            -
                  Formatter.color('attention:', :red) <<
         
     | 
| 
       183 
     | 
    
         
            -
                  ' replacing non-existant constant ' <<
         
     | 
| 
       184 
     | 
    
         
            -
                  Formatter.color(sym, :cyan) <<
         
     | 
| 
       185 
     | 
    
         
            -
                  ' with ' <<
         
     | 
| 
       186 
     | 
    
         
            -
                  Formatter.color(call_const, :cyan) <<
         
     | 
| 
       187 
     | 
    
         
            -
                  ' for ' <<
         
     | 
| 
       188 
     | 
    
         
            -
                  Formatter.color(obj, :green, :bold)
         
     | 
| 
       189 
     | 
    
         
            -
                end
         
     | 
| 
       190 
     | 
    
         
            -
                
         
     | 
| 
       191 
     | 
    
         
            -
              end
         
     | 
| 
       192 
     | 
    
         
            -
              
         
     | 
| 
       193 
19 
     | 
    
         
             
            end
         
     | 
| 
       194 
20 
     | 
    
         | 
| 
      
 21 
     | 
    
         
            +
            require 'guessmethod/guesser'
         
     | 
| 
      
 22 
     | 
    
         
            +
            require 'guessmethod/constant'
         
     | 
| 
      
 23 
     | 
    
         
            +
            require 'guessmethod/method'
         
     | 
| 
      
 24 
     | 
    
         
            +
            require 'guessmethod/outputter'
         
     | 
| 
      
 25 
     | 
    
         
            +
            require 'guessmethod/options'
         
     | 
| 
       195 
26 
     | 
    
         
             
            require 'guessmethod/version'
         
     | 
| 
      
 27 
     | 
    
         
            +
            require 'string/levenshtein'
         
     | 
| 
       196 
28 
     | 
    
         | 
| 
       197 
29 
     | 
    
         
             
            class Object; include GuessMethod; end
         
     | 
| 
       198 
30 
     | 
    
         
             
            class Module; extend GuessMethod::GuessConstant; end
         
     | 
    
        data/website/index.html
    CHANGED
    
    | 
         @@ -33,7 +33,7 @@ 
     | 
|
| 
       33 
33 
     | 
    
         
             
                <h1>Guess Method</h1>
         
     | 
| 
       34 
34 
     | 
    
         
             
                <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/guessmethod"; return false'>
         
     | 
| 
       35 
35 
     | 
    
         
             
                  <p>Get Version</p>
         
     | 
| 
       36 
     | 
    
         
            -
                  <a href="http://rubyforge.org/projects/guessmethod" class="numbers">0. 
     | 
| 
      
 36 
     | 
    
         
            +
                  <a href="http://rubyforge.org/projects/guessmethod" class="numbers">0.2.0</a>
         
     | 
| 
       37 
37 
     | 
    
         
             
                </div>
         
     | 
| 
       38 
38 
     | 
    
         
             
                <h1>→ ‘guessmethod’</h1>
         
     | 
| 
       39 
39 
     | 
    
         | 
| 
         @@ -41,10 +41,17 @@ 
     | 
|
| 
       41 
41 
     | 
    
         
             
            	<h2>What</h2>
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
            	<p>GuessMethod is an aggressive spell checker for irb 
     | 
| 
      
 44 
     | 
    
         
            +
            	<p>GuessMethod is an aggressive spell checker for irb… and rake!  Don’t let sloppy typing
         
     | 
| 
       45 
45 
     | 
    
         
             
            slow you down.  Let GuessMethod take care of you.</p>
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         | 
| 
      
 48 
     | 
    
         
            +
            	<p>Throw <code>require 'guessmethod'</code> in your .irbrc for the GuessMethod magic.</p>
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            	<p>Try <code>require 'guessmethod/rake'</code> in your rakefiles or use the new <code>grake</code>
         
     | 
| 
      
 52 
     | 
    
         
            +
            command for GuessRakeTask magic.  But <span class="caps">BE CAREFUL</span>!</p>
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
       48 
55 
     | 
    
         
             
            	<h3>How</h3>
         
     | 
| 
       49 
56 
     | 
    
         | 
| 
       50 
57 
     | 
    
         | 
| 
         @@ -57,6 +64,9 @@ constant.  You can see that GuessMethod has already outgrown its name.</p> 
     | 
|
| 
       57 
64 
     | 
    
         
             
            const_missing handle the problem.</p>
         
     | 
| 
       58 
65 
     | 
    
         | 
| 
       59 
66 
     | 
    
         | 
| 
      
 67 
     | 
    
         
            +
            	<p>GuessRakeTask works along similar lines.</p>
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
       60 
70 
     | 
    
         
             
            	<h2>Installing</h2>
         
     | 
| 
       61 
71 
     | 
    
         | 
| 
       62 
72 
     | 
    
         | 
| 
         @@ -81,6 +91,15 @@ attention: sending to_f instead of tof to "3":String 
     | 
|
| 
       81 
91 
     | 
    
         
             
            [1.0, 2.0, 3.0]
         
     | 
| 
       82 
92 
     | 
    
         
             
            005:0> eixt
         
     | 
| 
       83 
93 
     | 
    
         
             
            attention: sending exit instead of eixt to main:Object
         
     | 
| 
      
 94 
     | 
    
         
            +
            </pre>
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            	<p>Or, see the magic of grake:</p>
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            <pre>mvb:~/hot-rails-app cms$ grake db:migrat 
         
     | 
| 
      
 100 
     | 
    
         
            +
            (in /Users/cms/hot-rails-app)
         
     | 
| 
      
 101 
     | 
    
         
            +
            attention: invoking task db:migrate instead of db:migrat
         
     | 
| 
      
 102 
     | 
    
         
            +
            ...
         
     | 
| 
       84 
103 
     | 
    
         
             
            </pre>
         
     | 
| 
       85 
104 
     | 
    
         | 
| 
       86 
105 
     | 
    
         
             
            	<p>There are a number of options available which affect how GuessMethod works.</p>
         
     | 
| 
         @@ -128,7 +147,7 @@ attention: sending exit instead of eixt to main:Object 
     | 
|
| 
       128 
147 
     | 
    
         | 
| 
       129 
148 
     | 
    
         
             
            	<p>Comments are welcome. Send an email to chris @@ tie-rack .. org.</p>
         
     | 
| 
       130 
149 
     | 
    
         
             
                <p class="coda">
         
     | 
| 
       131 
     | 
    
         
            -
                  website generated via <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>'s <a href="http://newgem.rubyforge.org/">newgem</a>, on  
     | 
| 
      
 150 
     | 
    
         
            +
                  website generated via <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>'s <a href="http://newgem.rubyforge.org/">newgem</a>, on 6th December 2007<br>
         
     | 
| 
       132 
151 
     | 
    
         
             
                  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
         
     | 
| 
       133 
152 
     | 
    
         
             
                </p>
         
     | 
| 
       134 
153 
     | 
    
         
             
            </div>
         
     | 
    
        data/website/index.txt
    CHANGED
    
    | 
         @@ -5,9 +5,14 @@ h1. → 'guessmethod' 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            h2. What
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            GuessMethod is an aggressive spell checker for irb 
     | 
| 
      
 8 
     | 
    
         
            +
            GuessMethod is an aggressive spell checker for irb... and rake!  Don't let sloppy typing
         
     | 
| 
       9 
9 
     | 
    
         
             
            slow you down.  Let GuessMethod take care of you.
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
      
 11 
     | 
    
         
            +
            Throw <code>require 'guessmethod'</code> in your .irbrc for the GuessMethod magic.
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            Try <code>require 'guessmethod/rake'</code> in your rakefiles or use the new <code>grake</code>
         
     | 
| 
      
 14 
     | 
    
         
            +
            command for GuessRakeTask magic.  But BE CAREFUL!
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       11 
16 
     | 
    
         
             
            h3. How
         
     | 
| 
       12 
17 
     | 
    
         | 
| 
       13 
18 
     | 
    
         
             
            GuessMethod aliases out method_missing and const_missing and replaces it with
         
     | 
| 
         @@ -17,6 +22,8 @@ constant.  You can see that GuessMethod has already outgrown its name. 
     | 
|
| 
       17 
22 
     | 
    
         
             
            When GuessMethod can't figure anything out, it lets the original method_missing or
         
     | 
| 
       18 
23 
     | 
    
         
             
            const_missing handle the problem.
         
     | 
| 
       19 
24 
     | 
    
         | 
| 
      
 25 
     | 
    
         
            +
            GuessRakeTask works along similar lines.
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       20 
27 
     | 
    
         
             
            h2. Installing
         
     | 
| 
       21 
28 
     | 
    
         | 
| 
       22 
29 
     | 
    
         
             
            <pre syntax="ruby">sudo gem install guessmethod</pre>
         
     | 
| 
         @@ -41,6 +48,14 @@ attention: sending to_f instead of tof to "3":String 
     | 
|
| 
       41 
48 
     | 
    
         
             
            attention: sending exit instead of eixt to main:Object
         
     | 
| 
       42 
49 
     | 
    
         
             
            </pre>
         
     | 
| 
       43 
50 
     | 
    
         | 
| 
      
 51 
     | 
    
         
            +
            Or, see the magic of grake:
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            <pre>mvb:~/hot-rails-app cms$ grake db:migrat 
         
     | 
| 
      
 54 
     | 
    
         
            +
            (in /Users/cms/hot-rails-app)
         
     | 
| 
      
 55 
     | 
    
         
            +
            attention: invoking task db:migrate instead of db:migrat
         
     | 
| 
      
 56 
     | 
    
         
            +
            ...
         
     | 
| 
      
 57 
     | 
    
         
            +
            </pre>
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
       44 
59 
     | 
    
         
             
            There are a number of options available which affect how GuessMethod works.
         
     | 
| 
       45 
60 
     | 
    
         | 
| 
       46 
61 
     | 
    
         
             
            * <code>GuessMethodOptions[:insert_weight]</code>, <code>GuessMethodOptions[:delete_weight]</code>, <code>GuessMethodOptions[:substitution_weight]</code> change how the levenshtein distance is calculated between method and constant names.  The default values are all 1.
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,33 +1,38 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
     | 
    
         
            -
            rubygems_version: 0.9.4
         
     | 
| 
       3 
     | 
    
         
            -
            specification_version: 1
         
     | 
| 
       4 
2 
     | 
    
         
             
            name: guessmethod
         
     | 
| 
       5 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       6 
     | 
    
         
            -
              version: 0. 
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            summary: an aggressive spell checker for irb
         
     | 
| 
       9 
     | 
    
         
            -
            require_paths: 
         
     | 
| 
       10 
     | 
    
         
            -
            - lib
         
     | 
| 
       11 
     | 
    
         
            -
            email: chris@tie-rack.org
         
     | 
| 
       12 
     | 
    
         
            -
            homepage: http://guessmethod.rubyforge.org
         
     | 
| 
       13 
     | 
    
         
            -
            rubyforge_project: guessmethod
         
     | 
| 
       14 
     | 
    
         
            -
            description: an aggressive spell checker for irb
         
     | 
| 
       15 
     | 
    
         
            -
            autorequire: 
         
     | 
| 
       16 
     | 
    
         
            -
            default_executable: 
         
     | 
| 
       17 
     | 
    
         
            -
            bindir: bin
         
     | 
| 
       18 
     | 
    
         
            -
            has_rdoc: true
         
     | 
| 
       19 
     | 
    
         
            -
            required_ruby_version: !ruby/object:Gem::Version::Requirement 
         
     | 
| 
       20 
     | 
    
         
            -
              requirements: 
         
     | 
| 
       21 
     | 
    
         
            -
              - - ">"
         
     | 
| 
       22 
     | 
    
         
            -
                - !ruby/object:Gem::Version 
         
     | 
| 
       23 
     | 
    
         
            -
                  version: 0.0.0
         
     | 
| 
       24 
     | 
    
         
            -
              version: 
         
     | 
| 
       25 
     | 
    
         
            -
            platform: ruby
         
     | 
| 
       26 
     | 
    
         
            -
            signing_key: 
         
     | 
| 
       27 
     | 
    
         
            -
            cert_chain: 
         
     | 
| 
       28 
     | 
    
         
            -
            post_install_message: 
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ""
         
     | 
| 
       29 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       30 
7 
     | 
    
         
             
            - Chris Shea
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2007-12-06 00:00:00 -07:00
         
     | 
| 
      
 13 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 14 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 16 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 17 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 18 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 19 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 20 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 21 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 22 
     | 
    
         
            +
                    version: "0.7"
         
     | 
| 
      
 23 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 24 
     | 
    
         
            +
            description: an aggressive spell checker for irb
         
     | 
| 
      
 25 
     | 
    
         
            +
            email: chris@tie-rack.org
         
     | 
| 
      
 26 
     | 
    
         
            +
            executables: 
         
     | 
| 
      
 27 
     | 
    
         
            +
            - grake
         
     | 
| 
      
 28 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            extra_rdoc_files: 
         
     | 
| 
      
 31 
     | 
    
         
            +
            - History.txt
         
     | 
| 
      
 32 
     | 
    
         
            +
            - License.txt
         
     | 
| 
      
 33 
     | 
    
         
            +
            - Manifest.txt
         
     | 
| 
      
 34 
     | 
    
         
            +
            - README.txt
         
     | 
| 
      
 35 
     | 
    
         
            +
            - website/index.txt
         
     | 
| 
       31 
36 
     | 
    
         
             
            files: 
         
     | 
| 
       32 
37 
     | 
    
         
             
            - History.txt
         
     | 
| 
       33 
38 
     | 
    
         
             
            - License.txt
         
     | 
| 
         @@ -36,7 +41,14 @@ files: 
     | 
|
| 
       36 
41 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       37 
42 
     | 
    
         
             
            - lib/guessmethod.rb
         
     | 
| 
       38 
43 
     | 
    
         
             
            - lib/guessmethod/version.rb
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/guessmethod/guesser.rb
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib/guessmethod/constant.rb
         
     | 
| 
      
 46 
     | 
    
         
            +
            - lib/guessmethod/outputter.rb
         
     | 
| 
      
 47 
     | 
    
         
            +
            - lib/guessmethod/method.rb
         
     | 
| 
      
 48 
     | 
    
         
            +
            - lib/guessmethod/rake.rb
         
     | 
| 
      
 49 
     | 
    
         
            +
            - lib/guessmethod/options.rb
         
     | 
| 
       39 
50 
     | 
    
         
             
            - lib/string/levenshtein.rb
         
     | 
| 
      
 51 
     | 
    
         
            +
            - bin/grake
         
     | 
| 
       40 
52 
     | 
    
         
             
            - scripts/txt2html
         
     | 
| 
       41 
53 
     | 
    
         
             
            - setup.rb
         
     | 
| 
       42 
54 
     | 
    
         
             
            - spec/guessmethod_spec.rb
         
     | 
| 
         @@ -47,30 +59,32 @@ files: 
     | 
|
| 
       47 
59 
     | 
    
         
             
            - website/javascripts/rounded_corners_lite.inc.js
         
     | 
| 
       48 
60 
     | 
    
         
             
            - website/stylesheets/screen.css
         
     | 
| 
       49 
61 
     | 
    
         
             
            - website/template.rhtml
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
      
 62 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 63 
     | 
    
         
            +
            homepage: http://guessmethod.rubyforge.org
         
     | 
| 
      
 64 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
       52 
65 
     | 
    
         
             
            rdoc_options: 
         
     | 
| 
       53 
66 
     | 
    
         
             
            - --main
         
     | 
| 
       54 
67 
     | 
    
         
             
            - README.txt
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
            -  
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
            -  
     | 
| 
       60 
     | 
    
         
            -
            -  
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
      
 68 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 69 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 70 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 72 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 73 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 74 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 75 
     | 
    
         
            +
              version: 
         
     | 
| 
      
 76 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 77 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 78 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 79 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 80 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 81 
     | 
    
         
            +
              version: 
         
     | 
| 
       65 
82 
     | 
    
         
             
            requirements: []
         
     | 
| 
       66 
83 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
         
     | 
| 
       75 
     | 
    
         
            -
                    version: "0.7"
         
     | 
| 
       76 
     | 
    
         
            -
                version: 
         
     | 
| 
      
 84 
     | 
    
         
            +
            rubyforge_project: guessmethod
         
     | 
| 
      
 85 
     | 
    
         
            +
            rubygems_version: 0.9.5
         
     | 
| 
      
 86 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 87 
     | 
    
         
            +
            specification_version: 2
         
     | 
| 
      
 88 
     | 
    
         
            +
            summary: an aggressive spell checker for irb
         
     | 
| 
      
 89 
     | 
    
         
            +
            test_files: []
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     |