looksee 0.2.1 → 1.0.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/CHANGELOG +14 -0
- data/LICENSE +22 -0
- data/README.markdown +161 -0
- data/Rakefile +9 -36
- data/ext/extconf.rb +9 -0
- data/ext/mri/1.9.2/debug.h +36 -0
- data/ext/mri/1.9.2/id.h +170 -0
- data/ext/mri/1.9.2/method.h +103 -0
- data/ext/mri/1.9.2/node.h +483 -0
- data/ext/mri/1.9.2/thread_pthread.h +27 -0
- data/ext/mri/1.9.2/vm_core.h +707 -0
- data/ext/mri/1.9.2/vm_opts.h +51 -0
- data/ext/mri/env-1.8.h +27 -0
- data/ext/mri/eval_c-1.8.h +27 -0
- data/ext/mri/mri.c +269 -0
- data/ext/{looksee → mri}/node-1.9.h +0 -0
- data/ext/rbx/rbx.c +13 -0
- data/lib/looksee.rb +4 -385
- data/lib/looksee/adapter.rb +10 -0
- data/lib/looksee/adapter/base.rb +100 -0
- data/lib/looksee/adapter/rubinius.rb +73 -0
- data/lib/looksee/clean.rb +122 -0
- data/lib/looksee/columnizer.rb +73 -0
- data/lib/looksee/core_ext.rb +59 -0
- data/lib/looksee/editor.rb +58 -0
- data/lib/looksee/help.rb +54 -0
- data/lib/looksee/inspector.rb +55 -0
- data/lib/looksee/lookup_path.rb +95 -0
- data/lib/looksee/rbx.bundle +0 -0
- data/lib/looksee/shortcuts.rb +1 -105
- data/lib/looksee/version.rb +9 -1
- data/lib/looksee/wirble_compatibility.rb +2 -3
- data/spec/adapter_spec.rb +546 -0
- data/spec/columnizer_spec.rb +52 -0
- data/spec/core_ext_spec.rb +41 -0
- data/spec/editor_spec.rb +128 -0
- data/spec/inspector_spec.rb +178 -0
- data/spec/lookup_path_spec.rb +84 -0
- data/spec/spec_helper.rb +13 -127
- data/spec/support/core_ext.rb +25 -0
- data/spec/support/temporary_classes.rb +102 -0
- data/spec/support/test_adapter.rb +72 -0
- data/spec/wirble_compatibility_spec.rb +20 -23
- metadata +91 -57
- data/.autotest +0 -9
- data/History.txt +0 -22
- data/Manifest.txt +0 -21
- data/README.rdoc +0 -129
- data/ext/looksee/extconf.rb +0 -6
- data/ext/looksee/looksee.c +0 -144
- data/looksee.gemspec +0 -44
- data/script/console +0 -7
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/spec/looksee_spec.rb +0 -425
- data/tasks/extconf.rake +0 -13
- data/tasks/extconf/looksee.rake +0 -43
data/looksee.gemspec
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{looksee}
|
5
|
-
s.version = "0.2.1"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["George Ogata"]
|
9
|
-
s.date = %q{2009-08-30}
|
10
|
-
s.description = %q{Looksee lets you examine the method lookup path of objects in ways not
|
11
|
-
possible in plain ruby.}
|
12
|
-
s.email = ["george.ogata@gmail.com"]
|
13
|
-
s.extensions = ["ext/looksee/extconf.rb"]
|
14
|
-
s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
|
15
|
-
s.files = [".autotest", "History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "ext/looksee/extconf.rb", "ext/looksee/looksee.c", "ext/looksee/node-1.9.h", "lib/looksee.rb", "lib/looksee/shortcuts.rb", "lib/looksee/version.rb", "lib/looksee/wirble_compatibility.rb", "looksee.gemspec", "script/console", "script/destroy", "script/generate", "spec/looksee_spec.rb", "spec/spec_helper.rb", "spec/wirble_compatibility_spec.rb", "tasks/extconf.rake", "tasks/extconf/looksee.rake"]
|
16
|
-
s.homepage = %q{http://github.com/oggy/looksee}
|
17
|
-
s.rdoc_options = ["--main", "README.rdoc"]
|
18
|
-
s.require_paths = ["lib", "ext/looksee"]
|
19
|
-
s.rubyforge_project = %q{looksee}
|
20
|
-
s.rubygems_version = %q{1.3.5}
|
21
|
-
s.summary = %q{Looksee lets you examine the method lookup path of objects in ways not possible in plain ruby.}
|
22
|
-
|
23
|
-
if s.respond_to? :specification_version then
|
24
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
-
s.specification_version = 3
|
26
|
-
|
27
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_development_dependency(%q<newgem>, [">= 1.5.2"])
|
29
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.7"])
|
30
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
|
31
|
-
s.add_development_dependency(%q<hoe>, [">= 2.3.2"])
|
32
|
-
else
|
33
|
-
s.add_dependency(%q<newgem>, [">= 1.5.2"])
|
34
|
-
s.add_dependency(%q<rspec>, [">= 1.2.7"])
|
35
|
-
s.add_dependency(%q<mocha>, [">= 0.9.5"])
|
36
|
-
s.add_dependency(%q<hoe>, [">= 2.3.2"])
|
37
|
-
end
|
38
|
-
else
|
39
|
-
s.add_dependency(%q<newgem>, [">= 1.5.2"])
|
40
|
-
s.add_dependency(%q<rspec>, [">= 1.2.7"])
|
41
|
-
s.add_dependency(%q<mocha>, [">= 0.9.5"])
|
42
|
-
s.add_dependency(%q<hoe>, [">= 2.3.2"])
|
43
|
-
end
|
44
|
-
end
|
data/script/console
DELETED
data/script/destroy
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/destroy'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/generate'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/looksee_spec.rb
DELETED
@@ -1,425 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Looksee do
|
4
|
-
include TemporaryClasses
|
5
|
-
|
6
|
-
describe ".lookup_modules" do
|
7
|
-
#
|
8
|
-
# Wrapper for the method under test.
|
9
|
-
#
|
10
|
-
# Filter out modules which are hard to test against, and returns
|
11
|
-
# the list of module names. #inspect strings are used for names
|
12
|
-
# of singleton classes, since they have no name.
|
13
|
-
#
|
14
|
-
def filtered_lookup_modules(object)
|
15
|
-
result = Looksee.lookup_modules(object)
|
16
|
-
# Singleton classes have no name ('' in <1.9, nil in 1.9+). Use
|
17
|
-
# the inspect string instead.
|
18
|
-
names = result.map{|mod| mod.name.to_s.empty? ? mod.inspect : mod.name}
|
19
|
-
names.select{|name| deterministic_module_name?(name)}
|
20
|
-
end
|
21
|
-
|
22
|
-
#
|
23
|
-
# Return true if the given module name is of a module we can test
|
24
|
-
# for.
|
25
|
-
#
|
26
|
-
# This excludes ruby version dependent modules, and modules tossed
|
27
|
-
# into the hierarchy by testing frameworks.
|
28
|
-
#
|
29
|
-
def deterministic_module_name?(name)
|
30
|
-
junk_patterns = [
|
31
|
-
# pollution from testing libraries
|
32
|
-
'Mocha', 'Spec',
|
33
|
-
# RSpec adds this under ruby 1.8.6
|
34
|
-
'InstanceExecHelper',
|
35
|
-
# only in ruby 1.9
|
36
|
-
'BasicObject',
|
37
|
-
# something pulls this in under ruby 1.9
|
38
|
-
'PP',
|
39
|
-
]
|
40
|
-
|
41
|
-
# Singleton classes of junk are junk.
|
42
|
-
while name =~ /\A#<Class:(.*)>\z/
|
43
|
-
name = $1
|
44
|
-
end
|
45
|
-
|
46
|
-
name !~ /\A(#{junk_patterns.join('|')})/
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should contain an entry for each module in the object's lookup path" do
|
50
|
-
temporary_module :Mod1
|
51
|
-
temporary_module :Mod2
|
52
|
-
temporary_class :Base
|
53
|
-
temporary_class :Derived, :superclass => Base do
|
54
|
-
include Mod1
|
55
|
-
include Mod2
|
56
|
-
end
|
57
|
-
filtered_lookup_modules(Derived.new) == %w'Derived Mod2 Mod1 Base Object Kernel'
|
58
|
-
end
|
59
|
-
|
60
|
-
it "contain an entry for the object's singleton class if it exists" do
|
61
|
-
object = Object.new
|
62
|
-
object.singleton_class
|
63
|
-
|
64
|
-
result = filtered_lookup_modules(object)
|
65
|
-
result.shift.should =~ /\A#<Class:\#<Object:0x[\da-f]+>>\z/
|
66
|
-
result.should == %w"Object Kernel"
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should contain entries for singleton classes of all ancestors for class objects" do
|
70
|
-
temporary_class :C
|
71
|
-
result = filtered_lookup_modules(C)
|
72
|
-
result.should == %w'#<Class:C> #<Class:Object> Class Module Object Kernel'
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should work for immediate objects" do
|
76
|
-
filtered_lookup_modules(1).first.should == 'Fixnum'
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe ".lookup_path" do
|
81
|
-
it "should return a LookupPath object" do
|
82
|
-
object = Object.new
|
83
|
-
lookup_path = Looksee.lookup_path(object)
|
84
|
-
lookup_path.should be_a(Looksee::LookupPath)
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should return a LookupPath object for the given object" do
|
88
|
-
object = Object.new
|
89
|
-
Looksee.stubs(:default_lookup_path_options).returns({})
|
90
|
-
Looksee::LookupPath.expects(:for).with(object, {})
|
91
|
-
lookup_path = Looksee.lookup_path(object)
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should allow symbol arguments as shortcuts for true options" do
|
95
|
-
object = Object.new
|
96
|
-
Looksee.stubs(:default_lookup_path_options).returns({})
|
97
|
-
Looksee::LookupPath.expects(:for).with(object, {:public => true, :overridden => true})
|
98
|
-
Looksee.lookup_path(object, :public, :overridden)
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should merge the default options, with the symbols, and the options hash" do
|
102
|
-
object = Object.new
|
103
|
-
Looksee.stubs(:default_lookup_path_options).returns({:public => false, :protected => false, :private => false})
|
104
|
-
Looksee::LookupPath.expects(:for).with(object, {:public => false, :protected => true, :private => false})
|
105
|
-
Looksee.lookup_path(object, :protected, :private, :private => false)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "internal instance methods:" do
|
110
|
-
def self.target_method(name)
|
111
|
-
define_method(:target_method){name}
|
112
|
-
end
|
113
|
-
|
114
|
-
def self.it_should_list_methods_with_visibility(visibility)
|
115
|
-
it "should return the list of #{visibility} instance methods defined directly on a class" do
|
116
|
-
temporary_class :C
|
117
|
-
replace_methods C, visibility => [:one, :two]
|
118
|
-
Looksee.send(target_method, C).to_set.should == Set[:one, :two]
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should return the list of #{visibility} instance methods defined directly on a module" do
|
122
|
-
temporary_module :M
|
123
|
-
replace_methods M, visibility => [:one, :two]
|
124
|
-
Looksee.send(target_method, M).to_set.should == Set[:one, :two]
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should return the list of #{visibility} instance methods defined directly on a singleton class" do
|
128
|
-
temporary_class :C
|
129
|
-
c = C.new
|
130
|
-
replace_methods c.singleton_class, visibility => [:one, :two]
|
131
|
-
Looksee.send(target_method, c.singleton_class).to_set.should == Set[:one, :two]
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should return the list of #{visibility} instance methods defined directly on a class' singleton class" do
|
135
|
-
temporary_class :C
|
136
|
-
replace_methods C.singleton_class, visibility => [:one, :two], :class_singleton => true
|
137
|
-
Looksee.send(target_method, C.singleton_class).to_set.should == Set[:one, :two]
|
138
|
-
end
|
139
|
-
|
140
|
-
# Worth checking as ruby keeps undef'd methods in method tables.
|
141
|
-
it "should not return undefined methods" do
|
142
|
-
temporary_class :C
|
143
|
-
replace_methods C, visibility => [:removed]
|
144
|
-
C.send(:undef_method, :removed)
|
145
|
-
Looksee.send(target_method, C).to_set.should == Set[]
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def self.it_should_not_list_methods_with_visibility(visibility1, visibility2)
|
150
|
-
it "should not return any #{visibility1} or #{visibility2} instance methods" do
|
151
|
-
temporary_class :C
|
152
|
-
replace_methods C, {visibility1 => [:a], visibility2 => [:b]}
|
153
|
-
Looksee.send(target_method, C).to_set.should == Set[]
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe ".internal_public_instance_methods" do
|
158
|
-
target_method :internal_public_instance_methods
|
159
|
-
it_should_list_methods_with_visibility :public
|
160
|
-
it_should_not_list_methods_with_visibility :private, :protected
|
161
|
-
end
|
162
|
-
|
163
|
-
describe ".internal_protected_instance_methods" do
|
164
|
-
target_method :internal_protected_instance_methods
|
165
|
-
it_should_list_methods_with_visibility :protected
|
166
|
-
it_should_not_list_methods_with_visibility :public, :private
|
167
|
-
end
|
168
|
-
|
169
|
-
describe ".internal_private_instance_methods" do
|
170
|
-
target_method :internal_private_instance_methods
|
171
|
-
it_should_list_methods_with_visibility :private
|
172
|
-
it_should_not_list_methods_with_visibility :public, :protected
|
173
|
-
end
|
174
|
-
|
175
|
-
describe ".internal_undefined_instance_methods" do
|
176
|
-
it "should return the list of undefined instance methods directly on a class" do
|
177
|
-
temporary_class :C
|
178
|
-
C.send(:define_method, :f){}
|
179
|
-
C.send(:undef_method, :f)
|
180
|
-
Looksee.internal_undefined_instance_methods(C).should == [:f]
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should return the list of undefined instance methods directly on a module" do
|
184
|
-
temporary_module :M
|
185
|
-
M.send(:define_method, :f){}
|
186
|
-
M.send(:undef_method, :f)
|
187
|
-
Looksee.internal_undefined_instance_methods(M).should == [:f]
|
188
|
-
end
|
189
|
-
|
190
|
-
it "should return the list of undefined instance methods directly on a singleton class" do
|
191
|
-
temporary_class :C
|
192
|
-
c = C.new
|
193
|
-
c.singleton_class.send(:define_method, :f){}
|
194
|
-
c.singleton_class.send(:undef_method, :f)
|
195
|
-
Looksee.internal_undefined_instance_methods(c.singleton_class).should == [:f]
|
196
|
-
end
|
197
|
-
|
198
|
-
it "should return the list of undefined instance methods directly on a class' singleton class" do
|
199
|
-
temporary_class :C
|
200
|
-
C.singleton_class.send(:define_method, :f){}
|
201
|
-
C.singleton_class.send(:undef_method, :f)
|
202
|
-
Looksee.internal_undefined_instance_methods(C.singleton_class).should == [:f]
|
203
|
-
end
|
204
|
-
|
205
|
-
it "should not return defined methods" do
|
206
|
-
temporary_class :C
|
207
|
-
C.send(:define_method, :f){}
|
208
|
-
Looksee.internal_undefined_instance_methods(C).should == []
|
209
|
-
end
|
210
|
-
|
211
|
-
it "should not return removed methods" do
|
212
|
-
temporary_class :C
|
213
|
-
C.send(:define_method, :f){}
|
214
|
-
C.send(:remove_method, :f)
|
215
|
-
Looksee.internal_undefined_instance_methods(C).should == []
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
describe Looksee::LookupPath do
|
222
|
-
include TemporaryClasses
|
223
|
-
|
224
|
-
def stub_methods(mod, public, protected, private, undefined)
|
225
|
-
Looksee.stubs(:internal_public_instance_methods ).with(mod).returns(public)
|
226
|
-
Looksee.stubs(:internal_protected_instance_methods).with(mod).returns(protected)
|
227
|
-
Looksee.stubs(:internal_private_instance_methods ).with(mod).returns(private)
|
228
|
-
Looksee.stubs(:internal_undefined_instance_methods).with(mod).returns(undefined)
|
229
|
-
end
|
230
|
-
|
231
|
-
describe "#entries" do
|
232
|
-
it "should contain an entry for each module in the object's lookup path" do
|
233
|
-
object = Object.new
|
234
|
-
temporary_class :C
|
235
|
-
temporary_class :D
|
236
|
-
Looksee.stubs(:lookup_modules).with(object).returns([C, D])
|
237
|
-
Looksee::LookupPath.for(object).entries.map{|entry| entry.module_name}.should == %w'C D'
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
describe "grep" do
|
242
|
-
it "should only include methods matching the given regexp" do
|
243
|
-
temporary_class :C
|
244
|
-
temporary_class :D
|
245
|
-
stub_methods(C, ['axbyc', 'xy'], [], [], [])
|
246
|
-
stub_methods(D, ['axbyc', 'xdy'], [], [], [])
|
247
|
-
object = Object.new
|
248
|
-
Looksee.stubs(:lookup_modules).with(object).returns([C, D])
|
249
|
-
lookup_path = Looksee::LookupPath.for(object, :public => true, :overridden => true).grep(/x.y/)
|
250
|
-
lookup_path.entries.map{|entry| entry.module_name}.should == %w'C D'
|
251
|
-
lookup_path.entries[0].methods.to_set.should == Set['axbyc']
|
252
|
-
lookup_path.entries[1].methods.to_set.should == Set['axbyc', 'xdy']
|
253
|
-
end
|
254
|
-
|
255
|
-
it "should only include methods including the given string" do
|
256
|
-
temporary_class :C
|
257
|
-
temporary_class :D
|
258
|
-
stub_methods(C, ['axxa', 'axa'], [], [], [])
|
259
|
-
stub_methods(D, ['bxxb', 'axxa'], [], [], [])
|
260
|
-
object = Object.new
|
261
|
-
Looksee.stubs(:lookup_modules).with(object).returns([C, D])
|
262
|
-
lookup_path = Looksee::LookupPath.for(object, :public => true, :overridden => true).grep('xx')
|
263
|
-
lookup_path.entries.map{|entry| entry.module_name}.should == %w'C D'
|
264
|
-
lookup_path.entries[0].methods.to_set.should == Set['axxa']
|
265
|
-
lookup_path.entries[1].methods.to_set.should == Set['axxa', 'bxxb']
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
describe "#inspect" do
|
270
|
-
before do
|
271
|
-
Looksee.stubs(:default_lookup_path_options).returns({})
|
272
|
-
end
|
273
|
-
|
274
|
-
before do
|
275
|
-
Looksee.stubs(:styles).returns(Hash.new{'%s'})
|
276
|
-
end
|
277
|
-
|
278
|
-
describe "contents" do
|
279
|
-
before do
|
280
|
-
temporary_module :M
|
281
|
-
temporary_class :C do
|
282
|
-
include M
|
283
|
-
end
|
284
|
-
@object = Object.new
|
285
|
-
Looksee.stubs(:lookup_modules).with(@object).returns([C, M])
|
286
|
-
stub_methods(C, ['public1', 'public2'], ['protected1', 'protected2'], ['private1', 'private2'], ['undefined1', 'undefined2'])
|
287
|
-
stub_methods(M, ['public1', 'public2'], ['protected1', 'protected2'], ['private1', 'private2'], ['undefined1', 'undefined2'])
|
288
|
-
end
|
289
|
-
|
290
|
-
it "should show only public instance methods when only public methods are requested" do
|
291
|
-
lookup_path = Looksee::LookupPath.for(@object, :public => true, :overridden => true)
|
292
|
-
lookup_path.inspect.should == <<-EOS.demargin.chomp
|
293
|
-
|C
|
294
|
-
| public1 public2
|
295
|
-
|M
|
296
|
-
| public1 public2
|
297
|
-
EOS
|
298
|
-
end
|
299
|
-
|
300
|
-
it "should show modules and protected instance methods when only protected methods are requested" do
|
301
|
-
lookup_path = Looksee::LookupPath.for(@object, :protected => true, :overridden => true)
|
302
|
-
lookup_path.inspect.should == <<-EOS.demargin.chomp
|
303
|
-
|C
|
304
|
-
| protected1 protected2
|
305
|
-
|M
|
306
|
-
| protected1 protected2
|
307
|
-
EOS
|
308
|
-
end
|
309
|
-
|
310
|
-
it "should show modules and private instance methods when only private methods are requested" do
|
311
|
-
lookup_path = Looksee::LookupPath.for(@object, :private => true, :overridden => true)
|
312
|
-
lookup_path.inspect.should == <<-EOS.demargin.chomp
|
313
|
-
|C
|
314
|
-
| private1 private2
|
315
|
-
|M
|
316
|
-
| private1 private2
|
317
|
-
EOS
|
318
|
-
end
|
319
|
-
|
320
|
-
it "should show modules and undefined instance methods when only undefined methods are requested" do
|
321
|
-
lookup_path = Looksee::LookupPath.for(@object, :undefined => true, :overridden => true)
|
322
|
-
lookup_path.inspect.should == <<-EOS.demargin.chomp
|
323
|
-
|C
|
324
|
-
| undefined1 undefined2
|
325
|
-
|M
|
326
|
-
| undefined1 undefined2
|
327
|
-
EOS
|
328
|
-
end
|
329
|
-
|
330
|
-
it "should show modules with public and private instance methods when only public and private methods are requested" do
|
331
|
-
lookup_path = Looksee::LookupPath.for(@object, :public => true, :private => true, :overridden => true)
|
332
|
-
lookup_path.inspect.should == <<-EOS.demargin.chomp
|
333
|
-
|C
|
334
|
-
| private1 private2 public1 public2
|
335
|
-
|M
|
336
|
-
| private1 private2 public1 public2
|
337
|
-
EOS
|
338
|
-
end
|
339
|
-
|
340
|
-
it "should show singleton classes as class names in brackets" do
|
341
|
-
Looksee.stubs(:lookup_modules).with(C).returns([C.singleton_class])
|
342
|
-
stub_methods(C.singleton_class, ['public1', 'public2'], [], [], [])
|
343
|
-
lookup_path = Looksee::LookupPath.for(C, :public => true)
|
344
|
-
lookup_path.inspect.should == <<-EOS.demargin.chomp
|
345
|
-
|[C]
|
346
|
-
| public1 public2
|
347
|
-
EOS
|
348
|
-
end
|
349
|
-
|
350
|
-
it "should handle singleton classes of singleton classes correctly" do
|
351
|
-
Looksee.stubs(:lookup_modules).with(C.singleton_class).returns([C.singleton_class.singleton_class])
|
352
|
-
stub_methods(C.singleton_class.singleton_class, ['public1', 'public2'], [], [], [])
|
353
|
-
lookup_path = Looksee::LookupPath.for(C.singleton_class, :public => true)
|
354
|
-
lookup_path.inspect.should == <<-EOS.demargin.chomp
|
355
|
-
|[[C]]
|
356
|
-
| public1 public2
|
357
|
-
EOS
|
358
|
-
end
|
359
|
-
|
360
|
-
it "should not show any blank lines if a module has no methods" do
|
361
|
-
stub_methods(C, [], [], [], [])
|
362
|
-
lookup_path = Looksee::LookupPath.for(@object, :public => true, :overridden => true)
|
363
|
-
lookup_path.inspect.should == <<-EOS.demargin.chomp
|
364
|
-
|C
|
365
|
-
|M
|
366
|
-
| public1 public2
|
367
|
-
EOS
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
describe "styles" do
|
372
|
-
before do
|
373
|
-
styles = {
|
374
|
-
:module => "`%s'",
|
375
|
-
:public => "{%s}",
|
376
|
-
:protected => "[%s]",
|
377
|
-
:private => "<%s>",
|
378
|
-
:undefined => "~%s~",
|
379
|
-
:overridden => "(%s)",
|
380
|
-
}
|
381
|
-
Looksee.stubs(:styles).returns(styles)
|
382
|
-
end
|
383
|
-
|
384
|
-
it "should delimit each word with the configured delimiters" do
|
385
|
-
temporary_class :C
|
386
|
-
Looksee.stubs(:lookup_modules).returns([C])
|
387
|
-
stub_methods(C, ['public'], ['protected'], ['private'], ['undefined'])
|
388
|
-
lookup_path = Looksee::LookupPath.for(Object.new, :public => true, :protected => true, :private => true, :undefined => true, :overridden => true)
|
389
|
-
lookup_path.inspect.should == <<-EOS.demargin.chomp
|
390
|
-
|\`C\'
|
391
|
-
| <private> [protected] {public} ~undefined~
|
392
|
-
EOS
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
describe "layout" do
|
397
|
-
it "should wrap method lists at the configured number of columns, sorting vertically first, and aligning into a grid" do
|
398
|
-
temporary_class :C
|
399
|
-
Looksee.stubs(:lookup_modules).returns([C])
|
400
|
-
stub_methods(C, %w'aa b c dd ee f g hh i', [], [], [])
|
401
|
-
lookup_path = Looksee::LookupPath.for(Object.new, :public => true)
|
402
|
-
lookup_path.inspect(:width => 20).should == <<-EOS.demargin.chomp
|
403
|
-
|C
|
404
|
-
| aa c ee g i
|
405
|
-
| b dd f hh
|
406
|
-
EOS
|
407
|
-
end
|
408
|
-
|
409
|
-
it "should lay the methods of each module out independently" do
|
410
|
-
temporary_class :A
|
411
|
-
temporary_class :B
|
412
|
-
Looksee.stubs(:lookup_modules).returns([A, B])
|
413
|
-
stub_methods(A, ['a', 'long_long_long_long_name'], [], [], [])
|
414
|
-
stub_methods(B, ['long_long_long', 'short'], [], [], [])
|
415
|
-
lookup_path = Looksee::LookupPath.for(Object.new, :public => true)
|
416
|
-
lookup_path.inspect.should == <<-EOS.demargin.chomp
|
417
|
-
|A
|
418
|
-
| a long_long_long_long_name
|
419
|
-
|B
|
420
|
-
| long_long_long short
|
421
|
-
EOS
|
422
|
-
end
|
423
|
-
end
|
424
|
-
end
|
425
|
-
end
|