matthew-method_lister 0.2.3 → 0.3.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.
|
@@ -3,8 +3,8 @@ module MethodLister
|
|
|
3
3
|
attr_reader :object
|
|
4
4
|
VISIBILITIES = [:public, :protected, :private]
|
|
5
5
|
|
|
6
|
-
def initialize(options={})
|
|
7
|
-
@object =
|
|
6
|
+
def initialize(object, options={})
|
|
7
|
+
@object = object
|
|
8
8
|
@methods = Hash.new
|
|
9
9
|
VISIBILITIES.each do |visibility|
|
|
10
10
|
@methods[visibility] = options[visibility] || Array.new
|
data/lib/method_lister/finder.rb
CHANGED
|
@@ -45,16 +45,16 @@ module MethodLister
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def record_methods_for(klass_or_module)
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
record_result(
|
|
49
|
+
klass_or_module,
|
|
50
50
|
:public => klass_or_module.public_instance_methods(false),
|
|
51
51
|
:protected => klass_or_module.protected_instance_methods(false),
|
|
52
52
|
:private => klass_or_module.private_instance_methods(false)
|
|
53
53
|
)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
def
|
|
57
|
-
@results << FindResult.new(
|
|
56
|
+
def record_result(*args)
|
|
57
|
+
@results << FindResult.new(*args)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def modules_for(obj_type, klass_or_module)
|
|
@@ -90,7 +90,7 @@ module MethodLister
|
|
|
90
90
|
ancestor.private_instance_methods(false)
|
|
91
91
|
end.flatten.uniq
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
record_result(object,
|
|
94
94
|
:public => singleton_methods & public_methods,
|
|
95
95
|
:protected => singleton_methods & protected_methods,
|
|
96
96
|
:private => private_methods - ancestor_privates)
|
data/spec/find_result_spec.rb
CHANGED
|
@@ -9,24 +9,23 @@ describe MethodLister::FindResult do
|
|
|
9
9
|
@all = @public + @protected + @private
|
|
10
10
|
|
|
11
11
|
@object = Object.new
|
|
12
|
-
@empty_result = MethodLister::FindResult.new(
|
|
13
|
-
@only_public = MethodLister::FindResult.new(
|
|
12
|
+
@empty_result = MethodLister::FindResult.new(@object)
|
|
13
|
+
@only_public = MethodLister::FindResult.new(@object,
|
|
14
14
|
:public => @public)
|
|
15
|
-
@only_protected = MethodLister::FindResult.new(
|
|
15
|
+
@only_protected = MethodLister::FindResult.new(@object,
|
|
16
16
|
:protected => @protected)
|
|
17
|
-
@only_private = MethodLister::FindResult.new(
|
|
17
|
+
@only_private = MethodLister::FindResult.new(@object,
|
|
18
18
|
:private => @private)
|
|
19
|
-
@mixed_result = MethodLister::FindResult.new(
|
|
19
|
+
@mixed_result = MethodLister::FindResult.new(@object,
|
|
20
20
|
:public => @public,
|
|
21
21
|
:protected => @protected,
|
|
22
22
|
:private => @private)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
describe "#object" do
|
|
26
|
-
it "
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
end.should raise_error(ArgumentError)
|
|
26
|
+
it "works even if object is nil" do
|
|
27
|
+
result = MethodLister::FindResult.new(nil, :public => @public)
|
|
28
|
+
result.object.should be_nil
|
|
30
29
|
end
|
|
31
30
|
|
|
32
31
|
it "knows its associated object" do
|
|
@@ -136,7 +135,7 @@ describe MethodLister::FindResult do
|
|
|
136
135
|
describe "#==" do
|
|
137
136
|
it "is equal if both have the same methods and object" do
|
|
138
137
|
@mixed_result.should == MethodLister::FindResult.new(
|
|
139
|
-
|
|
138
|
+
@mixed_result.object,
|
|
140
139
|
:public => @mixed_result.methods(:public),
|
|
141
140
|
:protected => @mixed_result.methods(:protected),
|
|
142
141
|
:private => @mixed_result.methods(:private)
|
|
@@ -145,7 +144,7 @@ describe MethodLister::FindResult do
|
|
|
145
144
|
|
|
146
145
|
it "is not equal if both have same methods but different objects" do
|
|
147
146
|
@mixed_result.should_not == MethodLister::FindResult.new(
|
|
148
|
-
|
|
147
|
+
Object.new,
|
|
149
148
|
:public => @mixed_result.methods(:public),
|
|
150
149
|
:protected => @mixed_result.methods(:protected),
|
|
151
150
|
:private => @mixed_result.methods(:private)
|
|
@@ -154,7 +153,7 @@ describe MethodLister::FindResult do
|
|
|
154
153
|
|
|
155
154
|
it "is not equal if both have the same object but different methods" do
|
|
156
155
|
@mixed_result.should_not == MethodLister::FindResult.new(
|
|
157
|
-
|
|
156
|
+
@mixed_result.object,
|
|
158
157
|
:public => ["something_else"]
|
|
159
158
|
)
|
|
160
159
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: matthew-method_lister
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthew O'Connor
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date:
|
|
12
|
+
date: 2009-05-16 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|