find_method 0.1.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/.document +5 -0
- data/.gitignore +21 -0
- data/Gemfile +5 -0
- data/LICENSE +20 -0
- data/README.markdown +31 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/lib/find_method.rb +22 -0
- data/test/helper.rb +10 -0
- data/test/test_find_method.rb +30 -0
- metadata +91 -0
data/.document
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 David Padilla
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# find_method
|
2
|
+
|
3
|
+
Sometimes, you just remember part of a method name and you just don't want to go
|
4
|
+
through the whole list.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
require 'find_method'
|
9
|
+
|
10
|
+
AnyClass.find_method("module") # => ["module_eval", "module_exec", "included_modules"]
|
11
|
+
|
12
|
+
any_object = AnyClass.new
|
13
|
+
any_object.find_method("module") # => ["to_enum", "enum_for"]
|
14
|
+
|
15
|
+
### Rails
|
16
|
+
|
17
|
+
Just include it on your Gemfile
|
18
|
+
|
19
|
+
gem 'find_method'
|
20
|
+
|
21
|
+
You're using Bundler, right?
|
22
|
+
|
23
|
+
### That's it!
|
24
|
+
|
25
|
+
That's it
|
26
|
+
|
27
|
+
# About the Author
|
28
|
+
|
29
|
+
[Crowd Interactive](http://www.crowdint.com) is an American web design and development company that happens to work in Colima, Mexico.
|
30
|
+
We specialize in building and growing online retail stores. We don’t work with everyone – just companies we believe in. Call us today to see if there’s a fit.
|
31
|
+
Find more info [here](http://www.crowdint.com)!
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "find_method"
|
8
|
+
gem.summary = %Q{Find a method on a class or an instance using part of the name}
|
9
|
+
gem.description = %Q{Find a method on a class or an instance using part of the name}
|
10
|
+
gem.email = "david@crowdint.com"
|
11
|
+
gem.homepage = "http://github.com/crowdint/method_finder"
|
12
|
+
gem.authors = ["David Padilla"]
|
13
|
+
gem.add_development_dependency "shoulda", ">= 0"
|
14
|
+
end
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rake/testtask'
|
21
|
+
Rake::TestTask.new(:test) do |test|
|
22
|
+
test.libs << 'lib' << 'test'
|
23
|
+
test.pattern = 'test/**/test_*.rb'
|
24
|
+
test.verbose = true
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'rcov/rcovtask'
|
29
|
+
Rcov::RcovTask.new do |test|
|
30
|
+
test.libs << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
rescue LoadError
|
35
|
+
task :rcov do
|
36
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
task :test => :check_dependencies
|
41
|
+
|
42
|
+
task :default => :test
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "method_finder #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/find_method.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module FindMethod
|
2
|
+
module ClassMethods
|
3
|
+
def find_method(query)
|
4
|
+
methods.select {|m| Regexp.new(query).match(m)}
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module InstanceMethods
|
9
|
+
def find_method(query)
|
10
|
+
methods.select {|m| Regexp.new(query).match(m)}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.included(receiver)
|
15
|
+
receiver.extend ClassMethods
|
16
|
+
receiver.send :include, InstanceMethods
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Object
|
21
|
+
include FindMethod
|
22
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class RandomObject < Object
|
4
|
+
end
|
5
|
+
|
6
|
+
class TestFindMethod < Test::Unit::TestCase
|
7
|
+
context "Class" do
|
8
|
+
should "respond to find_method" do
|
9
|
+
assert_respond_to(RandomObject, :find_method)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "return the methods that look like the query" do
|
13
|
+
assert_same_elements(RandomObject.find_method("module"), ["module_eval", "module_exec", "included_modules"])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "Instance" do
|
18
|
+
def setup
|
19
|
+
@random_object = RandomObject.new
|
20
|
+
end
|
21
|
+
|
22
|
+
should "respond to find_method" do
|
23
|
+
assert_respond_to(@random_object, :find_method)
|
24
|
+
end
|
25
|
+
|
26
|
+
should "return the methods that look like the query" do
|
27
|
+
assert_same_elements(@random_object.find_method("enum"), ["to_enum", "enum_for"])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: find_method
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- David Padilla
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-26 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: shoulda
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Find a method on a class or an instance using part of the name
|
36
|
+
email: david@crowdint.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.markdown
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- Gemfile
|
48
|
+
- LICENSE
|
49
|
+
- README.markdown
|
50
|
+
- Rakefile
|
51
|
+
- VERSION
|
52
|
+
- lib/find_method.rb
|
53
|
+
- test/helper.rb
|
54
|
+
- test/test_find_method.rb
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://github.com/crowdint/method_finder
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options:
|
61
|
+
- --charset=UTF-8
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 1.3.7
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Find a method on a class or an instance using part of the name
|
89
|
+
test_files:
|
90
|
+
- test/helper.rb
|
91
|
+
- test/test_find_method.rb
|