guessmethod 0.0.6 → 0.0.7
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/lib/guessmethod.rb +14 -10
- data/lib/guessmethod/version.rb +1 -1
- data/spec/guessmethod_spec.rb +14 -0
- data/website/index.html +1 -1
- metadata +1 -1
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.0.7 2007-08-06
|
2
|
+
|
3
|
+
* bug fix: GuessMethod::Options[:active] now correctly affects constant guessing
|
4
|
+
* little thing
|
5
|
+
* added a couple of tests to demonstrate that GuessMethod::Options[:active] does what it should
|
6
|
+
|
1
7
|
== 0.0.6 2007-08-06
|
2
8
|
|
3
9
|
* little things - trying to get guessmethod to pass firebrigade (http://firebrigade.seattlerb.org/gem/show/guessmethod)
|
data/lib/guessmethod.rb
CHANGED
@@ -168,17 +168,21 @@ module GuessConstant
|
|
168
168
|
end
|
169
169
|
|
170
170
|
def guess_const_missing(sym)
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
171
|
+
if Options[:active]
|
172
|
+
possible_consts = GuessMethod::Guesser.find_closest(self.constants, sym)
|
173
|
+
case possible_consts.size
|
174
|
+
when 1
|
175
|
+
call_const = possible_consts.first
|
176
|
+
$stderr.puts GuessMethod::Outputter.replacing_const(sym, call_const, self)
|
177
|
+
self.const_get(call_const)
|
178
|
+
when 0
|
179
|
+
$stderr.puts GuessMethod::Outputter.no_const_in_threshold(sym, self)
|
180
|
+
old_const_missing(sym)
|
181
|
+
else
|
182
|
+
$stderr.puts GuessMethod::Outputter.ambigious_const(sym, possible_consts, self)
|
183
|
+
old_const_missing(sym)
|
184
|
+
end
|
180
185
|
else
|
181
|
-
$stderr.puts GuessMethod::Outputter.ambigious_const(sym, possible_consts, self)
|
182
186
|
old_const_missing(sym)
|
183
187
|
end
|
184
188
|
end
|
data/lib/guessmethod/version.rb
CHANGED
data/spec/guessmethod_spec.rb
CHANGED
@@ -23,6 +23,20 @@ describe "GuessMethod naturally" do
|
|
23
23
|
lambda{Class.new.not_a_method}.should raise_error(NoMethodError)
|
24
24
|
end
|
25
25
|
|
26
|
+
it "should be off if it gets turned off" do
|
27
|
+
GuessMethod::Options[:active] = false
|
28
|
+
lambda{Class.nw}.should raise_error(NoMethodError)
|
29
|
+
lambda{Cass == Class}.should raise_error(NameError)
|
30
|
+
GuessMethod::Options[:active] = true
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should be on if it gets turned on" do
|
34
|
+
GuessMethod::Options[:active] = false
|
35
|
+
GuessMethod::Options[:active] = true
|
36
|
+
lambda{Class.nw}.should_not raise_error
|
37
|
+
Cass.should == Class
|
38
|
+
end
|
39
|
+
|
26
40
|
end
|
27
41
|
|
28
42
|
describe "On a method_missing-defining class, GuessMethod" do
|
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.
|
36
|
+
<a href="http://rubyforge.org/projects/guessmethod" class="numbers">0.0.7</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘guessmethod’</h1>
|
39
39
|
|