looksee 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/ext/mri/mri.c +8 -0
- data/lib/looksee/JRuby.jar +0 -0
- data/lib/looksee/adapter/base.rb +6 -1
- data/lib/looksee/lookup_path.rb +1 -1
- data/lib/looksee/version.rb +1 -1
- data/spec/looksee/adapter_spec.rb +19 -9
- data/spec/looksee/clean_spec.rb +1 -1
- data/spec/looksee/editor_spec.rb +3 -6
- data/spec/looksee/inspector_spec.rb +1 -0
- data/spec/looksee/lookup_path_spec.rb +15 -12
- data/spec/spec_helper.rb +9 -1
- data/spec/support/test_adapter.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b329abd3db89e86131b91f3d9fb3f7c6dfa84f6e
|
4
|
+
data.tar.gz: 07f340c3a34e5ca7a769c99cd0355030b70c2939
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 369e6f4f8f4128b969b9e446190438d6eaa83a9815a42cf77fa3c86a7fa027c221b98ff439d4d6a9ade2ae17651712ade1fbb955260120e82e5465fc4a4f1000
|
7
|
+
data.tar.gz: 595ecc16a319e375a34159656c5c7ccb99fb4230641d97e7fdaab8bcfde66aa01ea724a72de583b8a8c35db9571b1c1b939e545b7693683e31d7b0e67e7928b1
|
data/CHANGELOG
CHANGED
data/ext/mri/mri.c
CHANGED
@@ -213,6 +213,13 @@ VALUE Looksee_singleton_instance(VALUE self, VALUE singleton_class) {
|
|
213
213
|
}
|
214
214
|
}
|
215
215
|
|
216
|
+
VALUE Looksee_real_module(VALUE self, VALUE module_or_included_class) {
|
217
|
+
if (BUILTIN_TYPE(module_or_included_class) == T_ICLASS)
|
218
|
+
return RBASIC(module_or_included_class)->klass;
|
219
|
+
else
|
220
|
+
return module_or_included_class;
|
221
|
+
}
|
222
|
+
|
216
223
|
VALUE Looksee_module_name(VALUE self, VALUE module) {
|
217
224
|
if (BUILTIN_TYPE(module) == T_CLASS || BUILTIN_TYPE(module) == T_MODULE) {
|
218
225
|
VALUE name = rb_mod_name(module);
|
@@ -294,6 +301,7 @@ void Init_mri(void) {
|
|
294
301
|
rb_define_method(mMRI, "included_class?", Looksee_included_class_p, 1);
|
295
302
|
rb_define_method(mMRI, "singleton_class?", Looksee_singleton_class_p, 1);
|
296
303
|
rb_define_method(mMRI, "singleton_instance", Looksee_singleton_instance, 1);
|
304
|
+
rb_define_method(mMRI, "real_module", Looksee_real_module, 1);
|
297
305
|
rb_define_method(mMRI, "module_name", Looksee_module_name, 1);
|
298
306
|
#if RUBY_VERSION < 190
|
299
307
|
rb_define_method(mMRI, "source_location", Looksee_source_location, 1);
|
data/lib/looksee/JRuby.jar
CHANGED
Binary file
|
data/lib/looksee/adapter/base.rb
CHANGED
@@ -31,7 +31,8 @@ module Looksee
|
|
31
31
|
if included_class?(mod) || object.is_a?(Module)
|
32
32
|
description = module_name(object)
|
33
33
|
if description.empty?
|
34
|
-
|
34
|
+
is_class = real_module(object).is_a?(Class)
|
35
|
+
description = "unnamed #{is_class ? 'Class' : 'Module'}"
|
35
36
|
end
|
36
37
|
else
|
37
38
|
description = "#{module_name(object.class)} instance"
|
@@ -44,6 +45,10 @@ module Looksee
|
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
48
|
+
def real_module(module_or_included_class)
|
49
|
+
module_or_included_class
|
50
|
+
end
|
51
|
+
|
47
52
|
def internal_superclass(klass)
|
48
53
|
raise NotImplementedError, "abstract"
|
49
54
|
end
|
data/lib/looksee/lookup_path.rb
CHANGED
data/lib/looksee/version.rb
CHANGED
@@ -227,44 +227,44 @@ describe "Looksee.adapter" do
|
|
227
227
|
describe "#singleton_class?" do
|
228
228
|
it "should return true if the object is a singleton class of an object" do
|
229
229
|
object = (class << Object.new; self; end)
|
230
|
-
@adapter.singleton_class?(object).should
|
230
|
+
@adapter.singleton_class?(object).should == true
|
231
231
|
end
|
232
232
|
|
233
233
|
it "should return true if the object is a singleton class of a class" do
|
234
234
|
object = (class << Class.new; self; end)
|
235
|
-
@adapter.singleton_class?(object).should
|
235
|
+
@adapter.singleton_class?(object).should == true
|
236
236
|
end
|
237
237
|
|
238
238
|
it "should return true if the object is a singleton class of a singleton class" do
|
239
239
|
object = (class << (class << Class.new; self; end); self; end)
|
240
|
-
@adapter.singleton_class?(object).should
|
240
|
+
@adapter.singleton_class?(object).should == true
|
241
241
|
end
|
242
242
|
|
243
243
|
it "should return false if the object is just a class" do
|
244
244
|
object = Class.new
|
245
|
-
@adapter.singleton_class?(object).should
|
245
|
+
@adapter.singleton_class?(object).should == false
|
246
246
|
end
|
247
247
|
|
248
248
|
it "should return false if the object is just a module" do
|
249
249
|
object = Module.new
|
250
|
-
@adapter.singleton_class?(object).should
|
250
|
+
@adapter.singleton_class?(object).should == false
|
251
251
|
end
|
252
252
|
|
253
253
|
it "should return false if the object is just an object" do
|
254
254
|
object = Object.new
|
255
|
-
@adapter.singleton_class?(object).should
|
255
|
+
@adapter.singleton_class?(object).should == false
|
256
256
|
end
|
257
257
|
|
258
258
|
it "should return false if the object is TrueClass" do
|
259
|
-
@adapter.singleton_class?(TrueClass).should
|
259
|
+
@adapter.singleton_class?(TrueClass).should == false
|
260
260
|
end
|
261
261
|
|
262
262
|
it "should return false if the object is FalseClass" do
|
263
|
-
@adapter.singleton_class?(FalseClass).should
|
263
|
+
@adapter.singleton_class?(FalseClass).should == false
|
264
264
|
end
|
265
265
|
|
266
266
|
it "should return false if the object is NilClass" do
|
267
|
-
@adapter.singleton_class?(NilClass).should
|
267
|
+
@adapter.singleton_class?(NilClass).should == false
|
268
268
|
end
|
269
269
|
end
|
270
270
|
|
@@ -401,6 +401,16 @@ describe "Looksee.adapter" do
|
|
401
401
|
end
|
402
402
|
end
|
403
403
|
|
404
|
+
describe "for an included class of an unnamed module" do
|
405
|
+
it "should describe the object as 'unnamed Module'" do
|
406
|
+
klass = Class.new do
|
407
|
+
include Module.new
|
408
|
+
end
|
409
|
+
mod = @adapter.lookup_modules(klass.new)[1]
|
410
|
+
@adapter.describe_module(mod).should == 'unnamed Module'
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
404
414
|
describe "for a singleton class of an object" do
|
405
415
|
it "should describe the object in brackets" do
|
406
416
|
begin
|
data/spec/looksee/clean_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe Looksee do
|
|
4
4
|
describe ".[]" do
|
5
5
|
before do
|
6
6
|
@object = Object.new
|
7
|
-
Looksee.stub(:
|
7
|
+
Looksee.stub(default_specifiers: [:public, :overridden])
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should return an Inspector for the object's lookup path" do
|
data/spec/looksee/editor_spec.rb
CHANGED
@@ -65,11 +65,8 @@ describe Looksee::Editor do
|
|
65
65
|
set_up_editor
|
66
66
|
|
67
67
|
file, line = *source_location
|
68
|
-
|
69
|
-
|
70
|
-
Looksee.adapter.set_methods(C, [:f], [], [], [])
|
71
|
-
Looksee.adapter.set_source_location(C, :f, source_location)
|
72
|
-
Looksee.adapter.ancestors[object] = [C, Object]
|
68
|
+
open(file, 'w') { |f| f.puts "class C\n def f\n end\nend" }
|
69
|
+
load file
|
73
70
|
end
|
74
71
|
|
75
72
|
after do
|
@@ -102,7 +99,7 @@ describe Looksee::Editor do
|
|
102
99
|
end
|
103
100
|
|
104
101
|
it "should raise NoSourceLocationError and not run the editor if no source location is available" do
|
105
|
-
Looksee.adapter.
|
102
|
+
Looksee.adapter.stub(source_location: nil)
|
106
103
|
expect { editor.edit(object, :f) }.to raise_error(Looksee::NoSourceLocationError)
|
107
104
|
editor_invocation.should be_nil
|
108
105
|
end
|
@@ -4,6 +4,8 @@ describe Looksee::LookupPath do
|
|
4
4
|
include TemporaryClasses
|
5
5
|
|
6
6
|
describe "#entries" do
|
7
|
+
use_test_adapter
|
8
|
+
|
7
9
|
before do
|
8
10
|
temporary_module :M
|
9
11
|
temporary_class(:C) { include M }
|
@@ -34,8 +36,8 @@ describe Looksee::LookupPath do
|
|
34
36
|
end
|
35
37
|
|
36
38
|
it "should know which methods have been overridden" do
|
37
|
-
@lookup_path.entries[0].overridden?('public1').should
|
38
|
-
@lookup_path.entries[1].overridden?('public1').should
|
39
|
+
@lookup_path.entries[0].overridden?('public1').should == false
|
40
|
+
@lookup_path.entries[1].overridden?('public1').should == true
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
@@ -43,10 +45,7 @@ describe Looksee::LookupPath do
|
|
43
45
|
before do
|
44
46
|
temporary_module(:M) { def f; end }
|
45
47
|
temporary_class(:C) { include M; def f; end }
|
46
|
-
@object =
|
47
|
-
Looksee.adapter.ancestors[@object] = [C, M]
|
48
|
-
Looksee.adapter.set_methods(M, [:f], [], [], [])
|
49
|
-
Looksee.adapter.set_methods(C, [:f], [], [], [])
|
48
|
+
@object = C.new
|
50
49
|
end
|
51
50
|
|
52
51
|
it "should return the unoverridden UnboundMethod for the given method name" do
|
@@ -56,6 +55,14 @@ describe Looksee::LookupPath do
|
|
56
55
|
method.name.should == (RUBY_VERSION < "1.9.0" ? 'f' : :f)
|
57
56
|
end
|
58
57
|
|
58
|
+
it "should find methods in included modules" do
|
59
|
+
M.class_eval { def g; end }
|
60
|
+
lookup_path = Looksee::LookupPath.new(@object)
|
61
|
+
method = lookup_path.find('g')
|
62
|
+
method.owner.should == M
|
63
|
+
method.name.should == (RUBY_VERSION < "1.9.0" ? 'g' : :g)
|
64
|
+
end
|
65
|
+
|
59
66
|
it "should return nil if the method does not exist" do
|
60
67
|
lookup_path = Looksee::LookupPath.new(@object)
|
61
68
|
lookup_path.find('g').should be_nil
|
@@ -63,8 +70,6 @@ describe Looksee::LookupPath do
|
|
63
70
|
|
64
71
|
it "should return nil if the method has been undefined" do
|
65
72
|
C.send(:undef_method, :f)
|
66
|
-
Looksee.adapter.public_methods[C].delete(:f)
|
67
|
-
Looksee.adapter.undefined_methods[C] << :f
|
68
73
|
lookup_path = Looksee::LookupPath.new(@object)
|
69
74
|
lookup_path.find('f').should be_nil
|
70
75
|
end
|
@@ -73,11 +78,9 @@ describe Looksee::LookupPath do
|
|
73
78
|
describe Looksee::LookupPath::Entry do
|
74
79
|
it "should iterate over methods in alphabetical order" do
|
75
80
|
temporary_class(:C)
|
76
|
-
@object =
|
77
|
-
Looksee.adapter.
|
78
|
-
Looksee.adapter.ancestors[@object] = [C]
|
81
|
+
@object = C.new
|
82
|
+
Looksee.adapter.stub(internal_public_instance_methods: [:a, :c, :b])
|
79
83
|
@lookup_path = Looksee::LookupPath.new(@object)
|
80
|
-
@lookup_path.entries.size.should == 1
|
81
84
|
@lookup_path.entries.first.map{|name, visibility| name}.should == ['a', 'b', 'c']
|
82
85
|
end
|
83
86
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -17,5 +17,13 @@ end
|
|
17
17
|
NATIVE_ADAPTER = Looksee.adapter
|
18
18
|
|
19
19
|
RSpec.configure do |config|
|
20
|
-
config.
|
20
|
+
config.extend TestAdapter::Mixin
|
21
|
+
|
22
|
+
config.expect_with :rspec do |c|
|
23
|
+
c.syntax = [:should, :expect]
|
24
|
+
end
|
25
|
+
|
26
|
+
config.mock_with :rspec do |c|
|
27
|
+
c.syntax = [:should, :expect]
|
28
|
+
end
|
21
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: looksee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Ogata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|