Created
November 6, 2011 03:10
-
-
Save pasberth/1342407 to your computer and use it in GitHub Desktop.
typoを検出するッ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| module Kernel | |
| alias typofixer_original_method_missing method_missing | |
| def method_missing funcname, *args, &blk | |
| at = caller | |
| begin | |
| typofixer_original_method_missing funcname, *args, &blk | |
| rescue NoMethodError, NameError => e | |
| funcname = funcname.to_s | |
| (methods + private_methods).each do |my_method| | |
| my_method = my_method.to_s | |
| if (funcname.length / 2) < (0..funcname.length).inject(0) { |r, i| funcname[i] == my_method[i] ? r + 1 : r } | |
| puts "もしかして: #{my_method}" | |
| puts at | |
| return send my_method, *args, &blk | |
| end | |
| end | |
| raise e | |
| end | |
| end | |
| end | |
| clane # => もしかして: clone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment