guessmethod 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,7 +1,8 @@
1
- == 0.0.3 2007-07-18
1
+ == 0.0.4 2007-07-18
2
2
 
3
- * 1 major bit:
4
- * added an override for const_missing, now you can mistype even more!
5
3
  * a few minor bits:
6
- * DRYed up getting the replacement candidates
7
- * actively dirtied code that needed cleaning (I'm looking at you GuessMethod::Outputter)
4
+ * renamed GuessMethodClassMethods to the more correct GuessConstant
5
+ * changed the gem description in the Rakefile
6
+ * moved const_missing aliasing to GuessConstant
7
+ * tweaked the readme
8
+ * auto included GuessMethod into Object
data/README.txt CHANGED
@@ -1,21 +1,23 @@
1
- README for guessmethod
2
- ======================
1
+ = About
2
+
3
+ GuessMethod is the aggressive spell checker for irb. Do you sometimes mistype a method's
4
+ name or misspell a constant? GuessMethod can step in and take care of it.
3
5
 
4
6
  = Usage
5
7
 
6
8
  <tt>require 'guessmethod'</tt>
7
9
 
8
- <tt>class String; include GuessMethod; end</tt>
9
-
10
10
  Now, you can accidentally call <tt>'1'.toi</tt> and Guess Method will step in and call
11
11
  <tt>'1'.to_i</tt> like you meant to.
12
12
 
13
+ If you accidentally try to access <tt>File::RDWr</tt>, you'll get <tt>File::RDWR</tt> instead.
14
+
13
15
  == Options
14
16
 
15
17
  <tt>GuessMethod::Options</tt> is a hash with configuration values. The keys :insert_weight,
16
18
  :delete_weight, and :substitution_weight change the behavior of the levenshtein calculation.
17
- :threshold determines how close a method name needs to be to be counted as a 'match'. Values
18
- over 2 can give you unpredictable results, especially for short method names.
19
+ :threshold determines how close a method or constant name needs to be to be counted as a 'match'.
20
+ Values over 2 can give you unpredictable results, especially for short names.
19
21
 
20
22
  = Warning
21
23
 
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ require File.join(File.dirname(__FILE__), 'lib', 'guessmethod', 'version')
21
21
 
22
22
  AUTHOR = 'Chris Shea' # can also be an array of Authors
23
23
  EMAIL = "chris@tie-rack.org"
24
- DESCRIPTION = "hijacks method_missing to act as a spellchecker"
24
+ DESCRIPTION = "an aggressive spell checker for irb"
25
25
  GEM_NAME = 'guessmethod' # what ppl will type to install your gem
26
26
 
27
27
  @config_file = "~/.rubyforge/user-config.yml"
data/lib/guessmethod.rb CHANGED
@@ -25,14 +25,7 @@ module GuessMethod
25
25
  alias_method :old_method_missing, :method_missing
26
26
  alias_method :method_missing, :guess_method_missing
27
27
 
28
- unless respond_to? :const_missing
29
- def self.const_missing(sym); super; end
30
- end
31
- base.extend(GuessMethodClassMethods)
32
- class << self
33
- alias_method :old_const_missing, :const_missing
34
- alias_method :const_missing, :guess_const_missing
35
- end
28
+ base.extend(GuessConstant)
36
29
  end
37
30
  end
38
31
 
@@ -143,13 +136,32 @@ module GuessMethod
143
136
 
144
137
  end
145
138
 
146
- module GuessMethodClassMethods
139
+ # The GuessConstant module aliases out const_missing and
140
+ # replaces it with its own, which attempts to find a
141
+ # similarly named constant for the object at hand.
142
+ # If it finds one, it returns that instead, and prints
143
+ # a message to stderr explaining as much. If it doesn't
144
+ # find a suitable constant, the orignial const_missing
145
+ # gets called.
146
+ module GuessConstant
147
+ def self.extended(base) #:nodoc:
148
+ base.class_eval do
149
+ unless respond_to? :const_missing
150
+ def self.const_missing(sym); super; end
151
+ end
152
+ class << self
153
+ alias_method :old_const_missing, :const_missing
154
+ alias_method :const_missing, :guess_const_missing
155
+ end
156
+ end
157
+ end
158
+
147
159
  def guess_const_missing(sym)
148
160
  possible_consts = GuessMethod::Guesser.find_closest(self.constants, sym)
149
161
  case possible_consts.size
150
162
  when 1
151
163
  call_const = possible_consts.first
152
- $stderr.puts GuessMethod::Outputter.replacing_const(sym, call_const, self) #FIXME
164
+ $stderr.puts GuessMethod::Outputter.replacing_const(sym, call_const, self)
153
165
  self.const_get(call_const)
154
166
  when 0
155
167
  $stderr.puts GuessMethod::Outputter.no_const_in_threshold(sym, self)
@@ -161,4 +173,6 @@ module GuessMethodClassMethods
161
173
  end
162
174
  end
163
175
 
164
- require 'guessmethod/version'
176
+ require 'guessmethod/version'
177
+
178
+ class Object; include GuessMethod; end
@@ -2,7 +2,7 @@ module GuessMethod #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  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.0.3</a>
36
+ <a href="http://rubyforge.org/projects/guessmethod" class="numbers">0.0.4</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;guessmethod&#8217;</h1>
39
39
 
@@ -68,24 +68,22 @@ const_missing handle the problem.</p>
68
68
  <pre>mvb:~ cms$ irb
69
69
  001:0&gt; require 'guessmethod'
70
70
  true
71
- 002:0&gt; class Object; include GuessMethod; end
72
- Object
73
- 003:0&gt; Stirng.tos
71
+ 002:0&gt; Stirng.tos
74
72
  attention: replacing non-existant constant Stirng with String for Object
75
73
  attention: sending to_s instead of tos to String:Class
76
74
  "String"
77
- 004:0&gt; ['1','2','3'].mp {|x| x.to_}
75
+ 003:0&gt; ['1','2','3'].mp {|x| x.to_}
78
76
  attention: sending map instead of mp to ["1", "2", "3"]:Array
79
77
  ambigious method: to_ possible matches to_a, to_i, to_s, to_f for "1":String
80
78
  NoMethodError: undefined method `to_' for "1":String
81
79
  from /usr/local/lib/ruby/gems/1.8/gems/guessmethod-0.0.3/lib/guessmethod.rb:23:in `old_method_missing'
82
80
  from /usr/local/lib/ruby/gems/1.8/gems/guessmethod-0.0.3/lib/guessmethod.rb:50:in `method_missing'
83
- from (irb):4
81
+ from (irb):3
84
82
  from /usr/local/lib/ruby/gems/1.8/gems/guessmethod-0.0.3/lib/guessmethod.rb:44:in `map'
85
83
  from /usr/local/lib/ruby/gems/1.8/gems/guessmethod-0.0.3/lib/guessmethod.rb:44:in `send'
86
84
  from /usr/local/lib/ruby/gems/1.8/gems/guessmethod-0.0.3/lib/guessmethod.rb:44:in `method_missing'
87
- from (irb):4
88
- 005:0&gt; eixt
85
+ from (irb):3
86
+ 004:0&gt; eixt
89
87
  attention: sending exit instead of eixt to main:Object
90
88
  mvb:~ cms$</pre>
91
89
 
@@ -112,7 +110,7 @@ mvb:~ cms$</pre>
112
110
 
113
111
  <p>Comments are welcome. Send an email to chris @@ tie-rack .. org.</p>
114
112
  <p class="coda">
115
- <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 22nd July 2007<br>
113
+ website generated via <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>'s <a href="http://newgem.rubyforge.org/">newgem</a>, on 23rd July 2007<br>
116
114
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
117
115
  </p>
118
116
  </div>
data/website/index.txt CHANGED
@@ -26,24 +26,22 @@ h2. Demonstration of usage
26
26
  <pre>mvb:~ cms$ irb
27
27
  001:0> require 'guessmethod'
28
28
  true
29
- 002:0> class Object; include GuessMethod; end
30
- Object
31
- 003:0> Stirng.tos
29
+ 002:0> Stirng.tos
32
30
  attention: replacing non-existant constant Stirng with String for Object
33
31
  attention: sending to_s instead of tos to String:Class
34
32
  "String"
35
- 004:0> ['1','2','3'].mp {|x| x.to_}
33
+ 003:0> ['1','2','3'].mp {|x| x.to_}
36
34
  attention: sending map instead of mp to ["1", "2", "3"]:Array
37
35
  ambigious method: to_ possible matches to_a, to_i, to_s, to_f for "1":String
38
36
  NoMethodError: undefined method `to_' for "1":String
39
37
  from /usr/local/lib/ruby/gems/1.8/gems/guessmethod-0.0.3/lib/guessmethod.rb:23:in `old_method_missing'
40
38
  from /usr/local/lib/ruby/gems/1.8/gems/guessmethod-0.0.3/lib/guessmethod.rb:50:in `method_missing'
41
- from (irb):4
39
+ from (irb):3
42
40
  from /usr/local/lib/ruby/gems/1.8/gems/guessmethod-0.0.3/lib/guessmethod.rb:44:in `map'
43
41
  from /usr/local/lib/ruby/gems/1.8/gems/guessmethod-0.0.3/lib/guessmethod.rb:44:in `send'
44
42
  from /usr/local/lib/ruby/gems/1.8/gems/guessmethod-0.0.3/lib/guessmethod.rb:44:in `method_missing'
45
- from (irb):4
46
- 005:0> eixt
43
+ from (irb):3
44
+ 004:0> eixt
47
45
  attention: sending exit instead of eixt to main:Object
48
46
  mvb:~ cms$</pre>
49
47
 
@@ -37,7 +37,7 @@
37
37
  </div>
38
38
  <%= body %>
39
39
  <p class="coda">
40
- <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, <%= modified.pretty %><br>
40
+ website generated via <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>'s <a href="http://newgem.rubyforge.org/">newgem</a>, on <%= modified.pretty %><br>
41
41
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
42
42
  </p>
43
43
  </div>
metadata CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: guessmethod
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.3
7
- date: 2007-07-22 00:00:00 -06:00
8
- summary: hijacks method_missing to act as a spellchecker
6
+ version: 0.0.4
7
+ date: 2007-07-23 00:00:00 -06:00
8
+ summary: an aggressive spell checker for irb
9
9
  require_paths:
10
10
  - lib
11
11
  email: chris@tie-rack.org
12
12
  homepage: http://guessmethod.rubyforge.org
13
13
  rubyforge_project: guessmethod
14
- description: hijacks method_missing to act as a spellchecker
14
+ description: an aggressive spell checker for irb
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin