methodfinder 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6956d01fde38cb630cad9346d877e060fff4920c7163016ff8b97cf20020ef27
4
- data.tar.gz: 695b0fd1fa89f26ab09dc6f30bda1b650d2ce6d0e9617c0ac5a8207f402ec575
3
+ metadata.gz: 9870bf45c6bbb10d2fe3c2d5ad509a3dace99d3b0bca753127bfa20a2185f2db
4
+ data.tar.gz: 424c6c14b3ec09c8b20370cb40ec2beb8e9ff9405008606d2a1ffdbc1a88c007
5
5
  SHA512:
6
- metadata.gz: 24d990971ab3dbdfbc3a7568b7145637dc8b222897200ee01d03364528248edcb1d7acd57db8b4afaab2949cb4b7dfa31ef3dfd5778ac1f6d4360afc9b2f0619
7
- data.tar.gz: 894bdbb10df681feae1dbd03892d436ce2faec0009414fa50cafab92dba1079dfb52e722bb9a763b21af6971cca007081b9bcff6c111718e349d7c97e92dd07a
6
+ metadata.gz: 475f9808360c53bc6b71861fa4ddb5c405a72ec685bb5517a5ff59704f61e034c56b802c4cc2f14fea18e55bdf811b44e03ed551c257864929294a5f0f4f6066
7
+ data.tar.gz: 6835cb818777f35e343d10f14ba905eb57f797ce251ad5b0120f336a05f2d466dc1658e9dedc4f6378919024b39f29010aa772af5ee18e668e8c6bbc708a7e97
data/CHANGELOG.md CHANGED
@@ -6,16 +6,9 @@
6
6
 
7
7
  **Implemented enhancements:**
8
8
 
9
- - Add a changelog [\#19](https://github.com/citizen428/methodfinder/pull/19) ([chocolateboy](https://github.com/chocolateboy))
10
9
  - Cast the METHOD\_FINDER\_DEBUG environment variable to a boolean [\#17](https://github.com/citizen428/methodfinder/pull/17) ([chocolateboy](https://github.com/chocolateboy))
11
10
  - Switch to Bundler gem structure [\#16](https://github.com/citizen428/methodfinder/pull/16) ([citizen428](https://github.com/citizen428))
12
11
 
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
12
  ## [v2.2.1](https://github.com/citizen428/methodfinder/tree/v2.2.1) (2018-05-02)
20
13
  [Full Changelog](https://github.com/citizen428/methodfinder/compare/v2.2.0...v2.2.1)
21
14
 
@@ -62,7 +55,7 @@
62
55
 
63
56
  **Implemented enhancements:**
64
57
 
65
- - Add a method blacklist [\#4](https://github.com/citizen428/methodfinder/pull/4) ([janlelis](https://github.com/janlelis))
58
+ - Add a method ignore list [\#4](https://github.com/citizen428/methodfinder/pull/4) ([janlelis](https://github.com/janlelis))
66
59
 
67
60
  ## [v1.2.0](https://github.com/citizen428/methodfinder/tree/v1.2.0) (2011-04-08)
68
61
  [Full Changelog](https://github.com/citizen428/methodfinder/compare/v1.1.1...v1.2.0)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MethodFinder
4
- VERSION = '2.2.2'
4
+ VERSION = '2.2.3'
5
5
  end
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
@@ -39,6 +40,12 @@ module MethodFinder
39
40
  INSTANCE_METHOD_IGNORELIST = Hash.new { |h, k| h[k] = [] }
40
41
  # Ignoring class methods
41
42
  CLASS_METHOD_IGNORELIST = Hash.new { |h, k| h[k] = [] }
43
+ # IGNORING classes
44
+ CLASS_IGNORELIST = []
45
+
46
+ if RUBY_VERSION.start_with?('3')
47
+ CLASS_IGNORELIST << :SortedSet # this moved to a gem
48
+ end
42
49
 
43
50
  INSTANCE_METHOD_IGNORELIST[:Object] << :find_method # prevent stack overflow
44
51
  INSTANCE_METHOD_IGNORELIST[:Object] << :gem # funny testing stuff w/ Bundler
@@ -82,20 +89,32 @@ module MethodFinder
82
89
  # #=> ["Array#collect", "Array#collect!", "Enumerable#collect_concat", ...]
83
90
  def self.find(obj, res, *args, &block)
84
91
  find_methods(obj) do |met|
85
- o = obj.dup rescue obj
92
+ o = begin
93
+ obj.dup
94
+ rescue StandardError
95
+ obj
96
+ end
86
97
  m = o.method(met)
87
98
  next unless m.arity <= args.size
88
- STDERR.puts(met) if debug?
99
+
100
+ warn(met) if debug?
89
101
  a = args.empty? && ARGS.key?(met) ? ARGS[met] : args
90
- m.call(*a, &block) == res rescue nil
102
+ begin
103
+ m.call(*a, &block) == res
104
+ rescue StandardError
105
+ nil
106
+ end
91
107
  end
92
108
  end
93
109
 
94
110
  # Returns all currently defined modules and classes.
95
111
  def self.find_classes_and_modules
96
112
  with_redirected_streams do
97
- constants = Object.constants.sort.map { |c| Object.const_get(c) }
98
- constants.select { |c| c.class == Class || c.class == Module }
113
+ candidates = Object.constants - CLASS_IGNORELIST
114
+ constants = candidates.sort.map { |c| Object.const_get(c) }
115
+ constants.select do |c|
116
+ c.instance_of?(Class) || c.instance_of?(Module)
117
+ end
99
118
  end
100
119
  end
101
120
 
@@ -117,7 +136,11 @@ module MethodFinder
117
136
  # :doc:
118
137
  def self.find_in_class_or_module(klass, pattern = /./)
119
138
  klasses = Object.const_get(klass.to_s)
120
- class_methods = klasses.methods(false) rescue []
139
+ class_methods = begin
140
+ klasses.methods(false)
141
+ rescue StandardError
142
+ []
143
+ end
121
144
  instance_methods = klasses.instance_methods(false)
122
145
  all_methods = class_methods + instance_methods
123
146
  all_methods.grep(/#{pattern}/).sort
@@ -138,16 +161,24 @@ module MethodFinder
138
161
  # :nodoc:
139
162
  def self.find_unknown(obj, &block)
140
163
  find_methods(obj) do |met|
141
- STDERR.puts(met) if debug?
164
+ warn(met) if debug?
142
165
  obj.class.class_eval("alias :unknown #{met}", __FILE__, __LINE__)
143
- subject = obj.dup rescue obj # dup doesn't work for immutable types
144
- block.call(subject) rescue nil
166
+ subject = begin
167
+ obj.dup
168
+ rescue StandardError # dup doesn't work for immutable types
169
+ obj
170
+ end
171
+ begin
172
+ block.call(subject)
173
+ rescue StandardError
174
+ nil
175
+ end
145
176
  end
146
177
  end
147
178
 
148
- def self.find_methods(obj)
179
+ def self.find_methods(obj, &block)
149
180
  with_redirected_streams do
150
- found = methods_to_try(obj).select { |met| yield(met) }
181
+ found = methods_to_try(obj).select(&block)
151
182
  found.map { |m| "#{obj.method(m).owner}##{m}" }
152
183
  end
153
184
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: methodfinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Kohl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-12 00:00:00.000000000 Z
11
+ date: 2021-11-08 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.1.0
19
+ version: '2.2'
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.1.0
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: github_changelog_generator
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.14'
33
+ version: '1.16'
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: '1.14'
40
+ version: '1.16'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '6.0'
75
+ version: '6.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '6.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.22'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '6.0'
96
+ version: '1.22'
83
97
  description: A Smalltalk-like Method Finder for Ruby with some extra features
84
98
  email:
85
99
  - citizen428@gmail.com
@@ -107,14 +121,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
- version: '0'
124
+ version: '2.6'
111
125
  required_rubygems_version: !ruby/object:Gem::Requirement
112
126
  requirements:
113
127
  - - ">="
114
128
  - !ruby/object:Gem::Version
115
129
  version: '0'
116
130
  requirements: []
117
- rubygems_version: 3.1.4
131
+ rubygems_version: 3.2.22
118
132
  signing_key:
119
133
  specification_version: 4
120
134
  summary: A Smalltalk-like Method Finder for Ruby