methodfinder 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.markdown +8 -8
  2. data/lib/methodfinder.rb +4 -2
  3. metadata +3 -3
@@ -18,13 +18,13 @@ arguments, `MethodFinder.find` will list all methods that produce the
18
18
  given result when called on the receiver with the provided arguments.
19
19
 
20
20
  >> MethodFinder.find(10,1,3)
21
- => [:%, :<=>, :>>, :[], :modulo, :remainder]
21
+ => ["Fixnum#%", "Fixnum#<=>", "Fixnum#>>", "Fixnum#[]", "Integer#gcd", "Fixnum#modulo", "Numeric#remainder"]
22
22
  >> MethodFinder.find("abc","ABC")
23
- => [:swapcase, :swapcase!, :upcase, :upcase!]
23
+ => ["String#swapcase", "String#swapcase!", "String#upcase", "String#upcase!"]
24
24
  >> MethodFinder.find(10,100,2)
25
- => [:**]
25
+ => ["Fixnum#**"]
26
26
  >> MethodFinder.find(['a','b','c'],['A','B','C']) { |x| x.upcase }
27
- => [:collect, :collect!, :map, :map!]
27
+ => ["Array#collect", "Array#collect!", "Enumerable#collect_concat", "Enumerable#flat_map", "Array#map", "Array#map!"]
28
28
 
29
29
  ### Object#find_method
30
30
 
@@ -34,9 +34,9 @@ alternate interface to pretty much the same functionality as
34
34
  the return value of the method.
35
35
 
36
36
  >> %w[a b c].find_method { |a| a.unknown(1) ; a == %w[a c] }
37
- => [:delete_at, :slice!]
37
+ => ["Array#delete_at", "Array#slice!"]
38
38
  >> 10.find_method { |n| n.unknown(3) == 1 }
39
- => [:%, :<=>, :>>, :[], :gcd, :modulo, :remainder]
39
+ => ["Fixnum#%", "Fixnum#<=>", "Fixnum#>>", "Fixnum#[]", "Integer#gcd", "Fixnum#modulo", "Numeric#remainder"]
40
40
 
41
41
  Inside `find_method`'s block, the receiver is available as block
42
42
  argument and the special method `unknown` is used as a placeholder for
@@ -46,7 +46,7 @@ You can also call `find_method` without passing a block. This is the
46
46
  same as calling `MethodFinder.find`.
47
47
 
48
48
  >> 10.find_method(1,3)
49
- [:%, :<=>, :>>, :[], :modulo, :remainder]
49
+ => ["Fixnum#%", "Fixnum#<=>", "Fixnum#>>", "Fixnum#[]", "Integer#gcd", "Fixnum#modulo", "Numeric#remainder"]
50
50
 
51
51
  #### Blacklists
52
52
 
@@ -113,7 +113,7 @@ what eventually became `Object#find_method`.
113
113
  * Brian Morearty for pointing out an
114
114
  [incompatibility with Ruby 1.8.7](https://github.com/citizen428/methodfinder/pull/5)
115
115
  and adding the [blockless version](https://github.com/citizen428/methodfinder/pull/6) of `Object#find_method`.
116
-
116
+ * Stefan Kanev for [adding Pry support](https://github.com/citizen428/methodfinder/pull/7).
117
117
  License
118
118
  ---
119
119
 
@@ -3,11 +3,12 @@ require 'stringio'
3
3
  class Object
4
4
  def find_method(*args, &block)
5
5
  if block_given?
6
- MethodFinder.methods_to_try(self).select do |met|
6
+ mets = MethodFinder.methods_to_try(self).select do |met|
7
7
  self.class.class_eval %{ alias :unknown #{met} }
8
8
  obj = self.dup rescue self
9
9
  yield obj rescue nil
10
10
  end
11
+ mets.map { |m| [self.method(m).owner, m].join("#") }
11
12
  else
12
13
  MethodFinder.find(self, *args)
13
14
  end
@@ -35,7 +36,7 @@ class MethodFinder
35
36
  def find(obj, res, *args, &block)
36
37
  redirect_streams
37
38
 
38
- methods_to_try(obj).select do |met|
39
+ mets = methods_to_try(obj).select do |met|
39
40
  o = obj.dup rescue obj
40
41
  m = o.method(met)
41
42
  if m.arity <= args.size
@@ -43,6 +44,7 @@ class MethodFinder
43
44
  m.call(*a, &block) == res rescue nil
44
45
  end
45
46
  end
47
+ mets.map { |m| [obj.method(m).owner, m].join("#") }
46
48
  ensure
47
49
  restore_streams
48
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: methodfinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-25 00:00:00.000000000Z
12
+ date: 2011-12-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: citizen428@gmail.com
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
40
  version: '0'
41
41
  requirements: []
42
42
  rubyforge_project:
43
- rubygems_version: 1.8.10
43
+ rubygems_version: 1.8.11
44
44
  signing_key:
45
45
  specification_version: 3
46
46
  summary: A Smalltalk-like Method Finder for Ruby