methodfinder 2.2.2 → 2.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -6
- data/lib/methodfinder/version.rb +1 -1
- data/lib/methodfinder.rb +51 -16
- metadata +28 -28
- data/CHANGELOG.md +0 -87
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4880f6b6a48cd921e8f7b0124eb090007b92d4ab3d36759826be3c3ea182cd00
|
4
|
+
data.tar.gz: 34f0bd666f85d8e380c6c0eb9e89b4bf05dbd34b17676c9117d666ca12e82910
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 964f6acb7bc9ac74bcbd7710c56db87c580b6a8c9b4c80413679e94aef95270ee46480a40e1df747d630f0aebdcd8d51d75523e0d5925797175f17ab7c58c8b1
|
7
|
+
data.tar.gz: b29c4b0149f7148710a6f97dc7b41c95397a00678de5be11ce8b2d16113401e9632937269f7029a9e8f78664ecaf7eedf1c4663666fb773f45d8839bfa9a2ff3
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MethodFinder
|
2
2
|
|
3
|
-
![
|
3
|
+
[![builds.sr.ht status](https://builds.sr.ht/~citizen428/methodfinder.svg)](https://builds.sr.ht/~citizen428/methodfinder?)
|
4
4
|
[![Gem Version](https://img.shields.io/gem/v/methodfinder.svg)](https://rubygems.org/gems/methodfinder)
|
5
5
|
|
6
6
|
<!-- toc -->
|
@@ -192,8 +192,10 @@ git commits and tags, and push the `.gem` file to
|
|
192
192
|
|
193
193
|
## CONTRIBUTING
|
194
194
|
|
195
|
-
|
196
|
-
https://
|
195
|
+
Development happens primarily on [Sourcehut](https://sr.ht/~citizen428/methodfinder/) where you can
|
196
|
+
[file bugs](https://sr.ht/~citizen428/methodfinder/trackers), [discuss on the mailing list](https://sr.ht/~citizen428/methodfinder/lists) or [send patches](https://git.sr.ht/~citizen428/methodfinder/send-email).
|
197
|
+
|
198
|
+
If you really have to you can also contribute via https://github.com/citizen428/methodfinder, but I really prefer Sourcehut.
|
197
199
|
|
198
200
|
## SEE ALSO
|
199
201
|
|
@@ -203,15 +205,15 @@ https://github.com/citizen428/methodfinder.
|
|
203
205
|
|
204
206
|
### Misc
|
205
207
|
|
206
|
-
- [Other Implementations](https://
|
208
|
+
- [Other Implementations](https://man.sr.ht/~citizen428/MethodFinder/) - a list of related projects in Ruby and other languages
|
207
209
|
|
208
210
|
## VERSION
|
209
211
|
|
210
|
-
2.2.
|
212
|
+
2.2.4
|
211
213
|
|
212
214
|
## AUTHOR
|
213
215
|
|
214
|
-
- [Michael Kohl](https://
|
216
|
+
- [Michael Kohl](https://citizen428.net/)
|
215
217
|
|
216
218
|
## LICENSE
|
217
219
|
|
data/lib/methodfinder/version.rb
CHANGED
data/lib/methodfinder.rb
CHANGED
@@ -24,6 +24,7 @@ class Object
|
|
24
24
|
# #=> ["Fixnum#%", "Fixnum#<=>", "Fixnum#>>", ...]
|
25
25
|
def find_method(*args, &block)
|
26
26
|
return MethodFinder.find(self, *args) unless block_given?
|
27
|
+
|
27
28
|
MethodFinder.find_unknown(self, &block)
|
28
29
|
end
|
29
30
|
end
|
@@ -32,13 +33,20 @@ module MethodFinder
|
|
32
33
|
# Default arguments for methods
|
33
34
|
# :nodoc:
|
34
35
|
ARGS = {
|
35
|
-
cycle: [1] # prevent cycling forever
|
36
|
+
cycle: [1], # prevent cycling forever
|
37
|
+
tally: [], # Since Ruby 3.1 Enumberable tally takes an optional hash
|
36
38
|
}.freeze
|
37
39
|
|
38
40
|
# Ignoring methods, e.g. { :Object => [:ri, :vim] }
|
39
41
|
INSTANCE_METHOD_IGNORELIST = Hash.new { |h, k| h[k] = [] }
|
40
42
|
# Ignoring class methods
|
41
43
|
CLASS_METHOD_IGNORELIST = Hash.new { |h, k| h[k] = [] }
|
44
|
+
# IGNORING classes
|
45
|
+
CLASS_IGNORELIST = []
|
46
|
+
|
47
|
+
if RUBY_VERSION.start_with?('3')
|
48
|
+
CLASS_IGNORELIST << :SortedSet # this moved to a gem
|
49
|
+
end
|
42
50
|
|
43
51
|
INSTANCE_METHOD_IGNORELIST[:Object] << :find_method # prevent stack overflow
|
44
52
|
INSTANCE_METHOD_IGNORELIST[:Object] << :gem # funny testing stuff w/ Bundler
|
@@ -54,7 +62,7 @@ module MethodFinder
|
|
54
62
|
# $ METHOD_FINDER_DEBUG=0 irb # false
|
55
63
|
# $ METHOD_FINDER_DEBUG=false irb # false
|
56
64
|
# $ METHOD_FINDER_DEBUG= irb # false
|
57
|
-
@debug = !ENV.fetch('METHOD_FINDER_DEBUG', '').match(/\A(0|false)?\z/i)
|
65
|
+
@debug = !ENV.fetch('METHOD_FINDER_DEBUG', '').match?(/\A(0|false)?\z/i)
|
58
66
|
|
59
67
|
# Checks whether or not debugging is currently enabled
|
60
68
|
# :doc:
|
@@ -82,20 +90,32 @@ module MethodFinder
|
|
82
90
|
# #=> ["Array#collect", "Array#collect!", "Enumerable#collect_concat", ...]
|
83
91
|
def self.find(obj, res, *args, &block)
|
84
92
|
find_methods(obj) do |met|
|
85
|
-
o =
|
93
|
+
o = begin
|
94
|
+
obj.dup
|
95
|
+
rescue StandardError
|
96
|
+
obj
|
97
|
+
end
|
86
98
|
m = o.method(met)
|
87
99
|
next unless m.arity <= args.size
|
88
|
-
|
89
|
-
|
90
|
-
|
100
|
+
|
101
|
+
warn(met) if debug?
|
102
|
+
a = ARGS.key?(met) ? ARGS[met] : args
|
103
|
+
begin
|
104
|
+
m.call(*a, &block) == res
|
105
|
+
rescue StandardError
|
106
|
+
nil
|
107
|
+
end
|
91
108
|
end
|
92
109
|
end
|
93
110
|
|
94
111
|
# Returns all currently defined modules and classes.
|
95
112
|
def self.find_classes_and_modules
|
96
113
|
with_redirected_streams do
|
97
|
-
|
98
|
-
constants.
|
114
|
+
candidates = Object.constants - CLASS_IGNORELIST
|
115
|
+
constants = candidates.sort.map { |c| Object.const_get(c) }
|
116
|
+
constants.select do |c|
|
117
|
+
c.instance_of?(Class) || c.instance_of?(Module)
|
118
|
+
end
|
99
119
|
end
|
100
120
|
end
|
101
121
|
|
@@ -117,7 +137,11 @@ module MethodFinder
|
|
117
137
|
# :doc:
|
118
138
|
def self.find_in_class_or_module(klass, pattern = /./)
|
119
139
|
klasses = Object.const_get(klass.to_s)
|
120
|
-
class_methods =
|
140
|
+
class_methods = begin
|
141
|
+
klasses.methods(false)
|
142
|
+
rescue StandardError
|
143
|
+
[]
|
144
|
+
end
|
121
145
|
instance_methods = klasses.instance_methods(false)
|
122
146
|
all_methods = class_methods + instance_methods
|
123
147
|
all_methods.grep(/#{pattern}/).sort
|
@@ -138,16 +162,24 @@ module MethodFinder
|
|
138
162
|
# :nodoc:
|
139
163
|
def self.find_unknown(obj, &block)
|
140
164
|
find_methods(obj) do |met|
|
141
|
-
|
165
|
+
warn(met) if debug?
|
142
166
|
obj.class.class_eval("alias :unknown #{met}", __FILE__, __LINE__)
|
143
|
-
subject =
|
144
|
-
|
167
|
+
subject = begin
|
168
|
+
obj.dup
|
169
|
+
rescue StandardError # dup doesn't work for immutable types
|
170
|
+
obj
|
171
|
+
end
|
172
|
+
begin
|
173
|
+
block.call(subject)
|
174
|
+
rescue StandardError
|
175
|
+
nil
|
176
|
+
end
|
145
177
|
end
|
146
178
|
end
|
147
179
|
|
148
|
-
def self.find_methods(obj)
|
180
|
+
def self.find_methods(obj, &block)
|
149
181
|
with_redirected_streams do
|
150
|
-
found = methods_to_try(obj).select
|
182
|
+
found = methods_to_try(obj).select(&block)
|
151
183
|
found.map { |m| "#{obj.method(m).owner}##{m}" }
|
152
184
|
end
|
153
185
|
end
|
@@ -156,8 +188,11 @@ module MethodFinder
|
|
156
188
|
def self.with_redirected_streams
|
157
189
|
orig_stdout = $stdout
|
158
190
|
orig_stderr = $stderr
|
159
|
-
|
160
|
-
|
191
|
+
|
192
|
+
unless debug?
|
193
|
+
$stdout = StringIO.new
|
194
|
+
$stderr = StringIO.new
|
195
|
+
end
|
161
196
|
|
162
197
|
yield
|
163
198
|
ensure
|
metadata
CHANGED
@@ -1,85 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: methodfinder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Kohl
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: '2.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '5.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '5.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '6.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '6.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.22'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1.22'
|
83
83
|
description: A Smalltalk-like Method Finder for Ruby with some extra features
|
84
84
|
email:
|
85
85
|
- citizen428@gmail.com
|
@@ -87,19 +87,19 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- CHANGELOG.md
|
91
90
|
- LICENSE.txt
|
92
91
|
- README.md
|
93
92
|
- lib/methodfinder.rb
|
94
93
|
- lib/methodfinder/version.rb
|
95
|
-
homepage:
|
94
|
+
homepage: https://sr.ht/~citizen428/methodfinder/
|
96
95
|
licenses:
|
97
96
|
- MIT
|
98
97
|
metadata:
|
99
|
-
bug_tracker_uri: https://
|
100
|
-
source_code_uri: https://
|
101
|
-
|
102
|
-
|
98
|
+
bug_tracker_uri: https://todo.sr.ht/~citizen428/methodfinder
|
99
|
+
source_code_uri: https://git.sr.ht/~citizen428/methodfinder/tree
|
100
|
+
mailing_list_uri: https://lists.sr.ht/~citizen428/public-inbox
|
101
|
+
wiki_uri: https://man.sr.ht/~citizen428/MethodFinder/
|
102
|
+
post_install_message:
|
103
103
|
rdoc_options: []
|
104
104
|
require_paths:
|
105
105
|
- lib
|
@@ -107,15 +107,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '2.6'
|
111
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
rubygems_version: 3.
|
118
|
-
signing_key:
|
117
|
+
rubygems_version: 3.3.17
|
118
|
+
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: A Smalltalk-like Method Finder for Ruby
|
121
121
|
test_files: []
|
data/CHANGELOG.md
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
## [Unreleased](https://github.com/citizen428/methodfinder/tree/HEAD)
|
4
|
-
|
5
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v2.2.1...HEAD)
|
6
|
-
|
7
|
-
**Implemented enhancements:**
|
8
|
-
|
9
|
-
- Add a changelog [\#19](https://github.com/citizen428/methodfinder/pull/19) ([chocolateboy](https://github.com/chocolateboy))
|
10
|
-
- Cast the METHOD\_FINDER\_DEBUG environment variable to a boolean [\#17](https://github.com/citizen428/methodfinder/pull/17) ([chocolateboy](https://github.com/chocolateboy))
|
11
|
-
- Switch to Bundler gem structure [\#16](https://github.com/citizen428/methodfinder/pull/16) ([citizen428](https://github.com/citizen428))
|
12
|
-
|
13
|
-
**Merged pull requests:**
|
14
|
-
|
15
|
-
- Documentation tweaks [\#22](https://github.com/citizen428/methodfinder/pull/22) ([chocolateboy](https://github.com/chocolateboy))
|
16
|
-
- Bump activesupport from 5.2.0 to 6.0.3.1 [\#21](https://github.com/citizen428/methodfinder/pull/21) ([dependabot[bot]](https://github.com/apps/dependabot))
|
17
|
-
- Update rake requirement from ~\> 10.0 to ~\> 13.0 [\#20](https://github.com/citizen428/methodfinder/pull/20) ([dependabot[bot]](https://github.com/apps/dependabot))
|
18
|
-
|
19
|
-
## [v2.2.1](https://github.com/citizen428/methodfinder/tree/v2.2.1) (2018-05-02)
|
20
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v2.2.0...v2.2.1)
|
21
|
-
|
22
|
-
## [v2.2.0](https://github.com/citizen428/methodfinder/tree/v2.2.0) (2018-05-02)
|
23
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v2.1.0...v2.2.0)
|
24
|
-
|
25
|
-
**Implemented enhancements:**
|
26
|
-
|
27
|
-
- README.md tweaks [\#14](https://github.com/citizen428/methodfinder/pull/14) ([chocolateboy](https://github.com/chocolateboy))
|
28
|
-
|
29
|
-
**Fixed bugs:**
|
30
|
-
|
31
|
-
- It's not possible to pass a hash as the last argument [\#10](https://github.com/citizen428/methodfinder/issues/10)
|
32
|
-
- Fix failing Travis builds [\#15](https://github.com/citizen428/methodfinder/pull/15) ([chocolateboy](https://github.com/chocolateboy))
|
33
|
-
- Propagate keywords \(i.e. :debug\) from find\_method to find [\#11](https://github.com/citizen428/methodfinder/pull/11) ([chocolateboy](https://github.com/chocolateboy))
|
34
|
-
|
35
|
-
## [v2.1.0](https://github.com/citizen428/methodfinder/tree/v2.1.0) (2017-02-05)
|
36
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v2.0.0...v2.1.0)
|
37
|
-
|
38
|
-
**Implemented enhancements:**
|
39
|
-
|
40
|
-
- Allow tested method names to be dumped to STDERR via an environment variable [\#9](https://github.com/citizen428/methodfinder/pull/9) ([chocolateboy](https://github.com/chocolateboy))
|
41
|
-
- Compatibility updates, fixes and workarounds [\#8](https://github.com/citizen428/methodfinder/pull/8) ([chocolateboy](https://github.com/chocolateboy))
|
42
|
-
|
43
|
-
## [v2.0.0](https://github.com/citizen428/methodfinder/tree/v2.0.0) (2013-10-30)
|
44
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v1.2.5...v2.0.0)
|
45
|
-
|
46
|
-
## [v1.2.5](https://github.com/citizen428/methodfinder/tree/v1.2.5) (2011-12-18)
|
47
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v1.2.4...v1.2.5)
|
48
|
-
|
49
|
-
## [v1.2.4](https://github.com/citizen428/methodfinder/tree/v1.2.4) (2011-10-26)
|
50
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v1.2.2...v1.2.4)
|
51
|
-
|
52
|
-
**Implemented enhancements:**
|
53
|
-
|
54
|
-
- Make methodfinder play nice with Pry [\#7](https://github.com/citizen428/methodfinder/pull/7) ([skanev](https://github.com/skanev))
|
55
|
-
- Instance syntax and fix tests [\#6](https://github.com/citizen428/methodfinder/pull/6) ([BMorearty](https://github.com/BMorearty))
|
56
|
-
|
57
|
-
## [v1.2.2](https://github.com/citizen428/methodfinder/tree/v1.2.2) (2011-04-23)
|
58
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v1.2.1...v1.2.2)
|
59
|
-
|
60
|
-
## [v1.2.1](https://github.com/citizen428/methodfinder/tree/v1.2.1) (2011-04-16)
|
61
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v1.2.0...v1.2.1)
|
62
|
-
|
63
|
-
**Implemented enhancements:**
|
64
|
-
|
65
|
-
- Add a method blacklist [\#4](https://github.com/citizen428/methodfinder/pull/4) ([janlelis](https://github.com/janlelis))
|
66
|
-
|
67
|
-
## [v1.2.0](https://github.com/citizen428/methodfinder/tree/v1.2.0) (2011-04-08)
|
68
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v1.1.1...v1.2.0)
|
69
|
-
|
70
|
-
## [v1.1.1](https://github.com/citizen428/methodfinder/tree/v1.1.1) (2011-04-05)
|
71
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v1.1.0...v1.1.1)
|
72
|
-
|
73
|
-
**Implemented enhancements:**
|
74
|
-
|
75
|
-
- Alternative block interface [\#3](https://github.com/citizen428/methodfinder/issues/3)
|
76
|
-
|
77
|
-
## [v1.1.0](https://github.com/citizen428/methodfinder/tree/v1.1.0) (2011-03-31)
|
78
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v1.0.1...v1.1.0)
|
79
|
-
|
80
|
-
**Closed issues:**
|
81
|
-
|
82
|
-
- Small typo in the readme [\#2](https://github.com/citizen428/methodfinder/issues/2)
|
83
|
-
|
84
|
-
## [v1.0.1](https://github.com/citizen428/methodfinder/tree/v1.0.1) (2011-03-11)
|
85
|
-
[Full Changelog](https://github.com/citizen428/methodfinder/compare/v1.0.0...v1.0.1)
|
86
|
-
|
87
|
-
## [v1.0.0](https://github.com/citizen428/methodfinder/tree/v1.0.0) (2011-02-10)
|