looksee 3.1.1 → 4.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +9 -0
  3. data/README.markdown +61 -81
  4. data/ext/extconf.rb +3 -7
  5. data/ext/mri/2.3.0/internal.h +1404 -0
  6. data/ext/mri/2.3.0/method.h +213 -0
  7. data/ext/mri/mri.c +21 -264
  8. data/ext/rbx/rbx.c +0 -9
  9. data/lib/looksee/JRuby.jar +0 -0
  10. data/lib/looksee/adapter/base.rb +19 -54
  11. data/lib/looksee/adapter/rubinius.rb +3 -62
  12. data/lib/looksee/clean.rb +5 -1
  13. data/lib/looksee/editor.rb +1 -1
  14. data/lib/looksee/help.rb +3 -2
  15. data/lib/looksee/lookup_path.rb +7 -3
  16. data/lib/looksee/version.rb +1 -1
  17. data/spec/looksee/adapter_spec.rb +72 -365
  18. data/spec/looksee/editor_spec.rb +1 -1
  19. data/spec/looksee/inspector_spec.rb +21 -21
  20. data/spec/looksee/lookup_path_spec.rb +34 -21
  21. data/spec/spec_helper.rb +2 -0
  22. data/spec/support/temporary_classes.rb +10 -14
  23. data/spec/support/test_adapter.rb +2 -53
  24. metadata +6 -29
  25. data/ext/mri/1.9.2/debug.h +0 -36
  26. data/ext/mri/1.9.2/id.h +0 -170
  27. data/ext/mri/1.9.2/method.h +0 -103
  28. data/ext/mri/1.9.2/node.h +0 -483
  29. data/ext/mri/1.9.2/thread_pthread.h +0 -27
  30. data/ext/mri/1.9.2/vm_core.h +0 -707
  31. data/ext/mri/1.9.2/vm_opts.h +0 -51
  32. data/ext/mri/1.9.3/atomic.h +0 -56
  33. data/ext/mri/1.9.3/debug.h +0 -41
  34. data/ext/mri/1.9.3/id.h +0 -175
  35. data/ext/mri/1.9.3/internal.h +0 -227
  36. data/ext/mri/1.9.3/internal_falcon.h +0 -248
  37. data/ext/mri/1.9.3/method.h +0 -105
  38. data/ext/mri/1.9.3/node.h +0 -503
  39. data/ext/mri/1.9.3/thread_pthread.h +0 -51
  40. data/ext/mri/1.9.3/vm_core.h +0 -755
  41. data/ext/mri/1.9.3/vm_opts.h +0 -51
  42. data/ext/mri/2.0.0/internal.h +0 -378
  43. data/ext/mri/2.0.0/method.h +0 -138
  44. data/ext/mri/env-1.8.h +0 -27
  45. data/ext/mri/eval_c-1.8.h +0 -27
  46. data/ext/mri/node-1.9.h +0 -35
  47. data/lib/looksee/mri.bundle +0 -0
@@ -99,7 +99,7 @@ describe Looksee::Editor do
99
99
  end
100
100
 
101
101
  it "should raise NoSourceLocationError and not run the editor if no source location is available" do
102
- Looksee.adapter.stub(source_location: nil)
102
+ UnboundMethod.any_instance.stub(source_location: nil)
103
103
  expect { editor.edit(object, :f) }.to raise_error(Looksee::NoSourceLocationError)
104
104
  editor_invocation.should be_nil
105
105
  end
@@ -17,8 +17,8 @@ describe Looksee::Inspector do
17
17
 
18
18
  describe "output width" do
19
19
  before do
20
- Looksee.adapter.public_methods[C] = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj']
21
- Looksee.adapter.public_methods[M] = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh']
20
+ add_methods C, public: ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj']
21
+ add_methods M, public: ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh']
22
22
  @lookup_path = Looksee::LookupPath.new(@object)
23
23
  end
24
24
 
@@ -67,78 +67,78 @@ describe Looksee::Inspector do
67
67
  end
68
68
 
69
69
  it "should not show any blank lines if a module has no methods" do
70
- Looksee.adapter.public_methods[M] = [:public1, :public2]
70
+ add_methods M, public: [:pub1, :pub2]
71
71
  lookup_path = Looksee::LookupPath.new(@object)
72
72
  inspector = Looksee::Inspector.new(lookup_path, :visibilities => [:public])
73
73
  inspector.inspect.should == <<-EOS.demargin.chomp
74
74
  |M
75
- | public1 public2
75
+ | pub1 pub2
76
76
  |C
77
77
  EOS
78
78
  end
79
79
 
80
80
  it "should show singleton classes as class names in brackets" do
81
81
  Looksee.adapter.ancestors[C] = [C.singleton_class]
82
- Looksee.adapter.public_methods[C.singleton_class] = [:public1, :public2]
82
+ add_methods C.singleton_class, public: [:pub1, :pub2]
83
83
  lookup_path = Looksee::LookupPath.new(C)
84
84
  inspector = Looksee::Inspector.new(lookup_path, :visibilities => [:public])
85
85
  inspector.inspect.should == <<-EOS.demargin.chomp
86
86
  |[C]
87
- | public1 public2
87
+ | pub1 pub2
88
88
  EOS
89
89
  end
90
90
 
91
91
  it "should handle singleton classes of singleton classes correctly" do
92
92
  Looksee.adapter.ancestors[C.singleton_class] = [C.singleton_class.singleton_class]
93
- Looksee.adapter.public_methods[C.singleton_class.singleton_class] = [:public1, :public2]
93
+ add_methods C.singleton_class.singleton_class, public: [:pub1, :pub2]
94
94
  lookup_path = Looksee::LookupPath.new(C.singleton_class)
95
95
  inspector = Looksee::Inspector.new(lookup_path, :visibilities => [:public])
96
96
  inspector.inspect.should == <<-EOS.demargin.chomp
97
97
  |[[C]]
98
- | public1 public2
98
+ | pub1 pub2
99
99
  EOS
100
100
  end
101
101
 
102
102
  it "should only show methods of the selected visibilities" do
103
103
  temporary_class :E
104
- Looksee.adapter.set_methods(E, [:public], [:protected], [:private], [:undefined])
104
+ add_methods(E, public: [:pub], protected: [:pro], private: [:pri], undefined: [:und])
105
105
  Looksee.adapter.ancestors[@object] = [E]
106
106
  lookup_path = Looksee::LookupPath.new(@object)
107
107
  inspector = Looksee::Inspector.new(lookup_path, :visibilities => [:protected])
108
108
  inspector.inspect.should == <<-EOS.demargin.chomp
109
109
  |E
110
- | protected
110
+ | pro
111
111
  EOS
112
112
  end
113
113
 
114
114
  it "should show overridden methods if selected" do
115
- Looksee.adapter.set_methods(C, [:public], [:protected], [:private], [:undefined])
116
- Looksee.adapter.set_methods(M, [:public], [:protected], [:private], [:undefined])
115
+ add_methods(C, public: [:pub], protected: [:pro], private: [:pri], undefined: [:und])
116
+ add_methods(M, public: [:pub], protected: [:pro], private: [:pri], undefined: [:und])
117
117
  lookup_path = Looksee::LookupPath.new(@object)
118
118
  inspector = Looksee::Inspector.new(lookup_path, :visibilities => [:public, :overridden])
119
119
  inspector.inspect.should == <<-EOS.demargin.chomp
120
120
  |M
121
- | public
121
+ | pub
122
122
  |C
123
- | public
123
+ | pub
124
124
  EOS
125
125
  end
126
126
 
127
127
  it "should not show overridden methods if not selected" do
128
- Looksee.adapter.set_methods(C, [:public], [:protected], [:private], [:undefined])
129
- Looksee.adapter.set_methods(M, [:public], [:protected], [:private], [:undefined])
128
+ add_methods(C, public: [:pub], protected: [:pro], private: [:pri], undefined: [:und])
129
+ add_methods(M, public: [:pub], protected: [:pro], private: [:pri], undefined: [:und])
130
130
  lookup_path = Looksee::LookupPath.new(@object)
131
131
  inspector = Looksee::Inspector.new(lookup_path, :visibilities => [:public, :nooverridden])
132
132
  inspector.inspect.should == <<-EOS.demargin.chomp
133
133
  |M
134
134
  |C
135
- | public
135
+ | pub
136
136
  EOS
137
137
  end
138
138
 
139
139
  it "should only show methods that match the given filters, if any are given" do
140
- Looksee.adapter.public_methods[C] = [:ab, :ax, :ba, :xa]
141
- Looksee.adapter.public_methods[M] = [:ab, :ax, :ba, :xa]
140
+ add_methods C, public: [:ab, :ax, :ba, :xa]
141
+ add_methods M, public: [:ab, :ax, :ba, :xa]
142
142
  lookup_path = Looksee::LookupPath.new(@object)
143
143
  inspector = Looksee::Inspector.new(lookup_path, :visibilities => [:public, :overridden], :filters => [/^a/, 'b'])
144
144
  inspector.inspect.should == <<-EOS.demargin.chomp
@@ -167,12 +167,12 @@ describe Looksee::Inspector do
167
167
  temporary_class :C
168
168
  c = C.new
169
169
  Looksee.adapter.ancestors[c] = [C]
170
- Looksee.adapter.set_methods(C, [:public], [:protected], [:private], [:undefined])
170
+ add_methods(C, public: [:pub], protected: [:pro], private: [:pri], undefined: [:und])
171
171
  lookup_path = Looksee::LookupPath.new(c)
172
172
  inspector = Looksee::Inspector.new(lookup_path, :visibilities => [:public, :protected, :private, :undefined, :overridden])
173
173
  inspector.inspect.should == <<-EOS.demargin.chomp
174
174
  |\`C\'
175
- | <private> [protected] {public} ~undefined~
175
+ | <pri> [pro] {pub} ~und~
176
176
  EOS
177
177
  end
178
178
  end
@@ -11,8 +11,20 @@ describe Looksee::LookupPath do
11
11
  temporary_class(:C) { include M }
12
12
  @object = Object.new
13
13
  Looksee.adapter.ancestors[@object] = [C, M]
14
- Looksee.adapter.set_methods(M, [:public1, :public2], [:protected1, :protected2], [:private1, :private2], [:undefined1, :undefined2])
15
- Looksee.adapter.set_methods(C, [:public1, :public2], [:protected1, :protected2], [:private1, :private2], [:undefined1, :undefined2])
14
+ add_methods(
15
+ M,
16
+ public: [:pub1, :pub2],
17
+ protected: [:pro1, :pro2],
18
+ private: [:pri1, :pri2],
19
+ undefined: [:und1, :und2],
20
+ )
21
+ add_methods(
22
+ C,
23
+ public: [:pub1, :pub2],
24
+ protected: [:pro1, :pro2],
25
+ private: [:pri1, :pri2],
26
+ undefined: [:und1, :und2],
27
+ )
16
28
  @lookup_path = Looksee::LookupPath.new(@object)
17
29
  end
18
30
 
@@ -22,22 +34,22 @@ describe Looksee::LookupPath do
22
34
 
23
35
  it "should include methods of all visibilities, including overridden ones" do
24
36
  @lookup_path.entries[0].methods.should == {
25
- 'public1' => :public , 'public2' => :public,
26
- 'protected1' => :protected, 'protected2' => :protected,
27
- 'private1' => :private , 'private2' => :private,
28
- 'undefined1' => :undefined, 'undefined2' => :undefined,
37
+ 'pub1' => :public, 'pub2' => :public,
38
+ 'pro1' => :protected, 'pro2' => :protected,
39
+ 'pri1' => :private, 'pri2' => :private,
40
+ 'und1' => :undefined, 'und2' => :undefined,
29
41
  }
30
42
  @lookup_path.entries[1].methods.should == {
31
- 'public1' => :public , 'public2' => :public,
32
- 'protected1' => :protected, 'protected2' => :protected,
33
- 'private1' => :private , 'private2' => :private,
34
- 'undefined1' => :undefined, 'undefined2' => :undefined,
43
+ 'pub1' => :public, 'pub2' => :public,
44
+ 'pro1' => :protected, 'pro2' => :protected,
45
+ 'pri1' => :private, 'pri2' => :private,
46
+ 'und1' => :undefined, 'und2' => :undefined,
35
47
  }
36
48
  end
37
49
 
38
50
  it "should know which methods have been overridden" do
39
- @lookup_path.entries[0].overridden?('public1').should == false
40
- @lookup_path.entries[1].overridden?('public1').should == true
51
+ @lookup_path.entries[0].overridden?('pub1').should == false
52
+ @lookup_path.entries[1].overridden?('pub1').should == true
41
53
  end
42
54
  end
43
55
 
@@ -52,7 +64,7 @@ describe Looksee::LookupPath do
52
64
  lookup_path = Looksee::LookupPath.new(@object)
53
65
  method = lookup_path.find('f')
54
66
  method.owner.should == C
55
- method.name.should == (RUBY_VERSION < "1.9.0" ? 'f' : :f)
67
+ method.name.should == :f
56
68
  end
57
69
 
58
70
  it "should find methods in included modules" do
@@ -60,7 +72,7 @@ describe Looksee::LookupPath do
60
72
  lookup_path = Looksee::LookupPath.new(@object)
61
73
  method = lookup_path.find('g')
62
74
  method.owner.should == M
63
- method.name.should == (RUBY_VERSION < "1.9.0" ? 'g' : :g)
75
+ method.name.should == :g
64
76
  end
65
77
 
66
78
  it "should return nil if the method does not exist" do
@@ -68,19 +80,20 @@ describe Looksee::LookupPath do
68
80
  lookup_path.find('g').should be_nil
69
81
  end
70
82
 
71
- it "should return nil if the method has been undefined" do
72
- C.send(:undef_method, :f)
73
- lookup_path = Looksee::LookupPath.new(@object)
74
- lookup_path.find('f').should be_nil
83
+ unless RUBY_VERSION >= '2.3.0'
84
+ it "should return nil if the method has been undefined" do
85
+ add_methods(C, undefined: [:f])
86
+ lookup_path = Looksee::LookupPath.new(@object)
87
+ lookup_path.find('f').should be_nil
88
+ end
75
89
  end
76
90
  end
77
91
 
78
92
  describe Looksee::LookupPath::Entry do
79
93
  it "should iterate over methods in alphabetical order" do
80
94
  temporary_class(:C)
81
- @object = C.new
82
- Looksee.adapter.stub(internal_public_instance_methods: [:a, :c, :b])
83
- @lookup_path = Looksee::LookupPath.new(@object)
95
+ add_methods(C, public: [:a, :c, :b])
96
+ @lookup_path = Looksee::LookupPath.new(C.new)
84
97
  @lookup_path.entries.first.map{|name, visibility| name}.should == ['a', 'b', 'c']
85
98
  end
86
99
  end
@@ -2,6 +2,8 @@ $:.unshift File.expand_path('..', File.dirname(__FILE__))
2
2
  ENV['LOOKSEE_METHOD'] = nil
3
3
 
4
4
  require 'rspec'
5
+ require 'pry' unless ENV['CI']
6
+
5
7
  require 'looksee'
6
8
 
7
9
  require 'rbconfig'
@@ -47,10 +47,6 @@ module TemporaryClasses
47
47
  #
48
48
  # +methods+ is a hash of visibilities to names.
49
49
  #
50
- # As Ruby's reflection on singleton classes of classes isn't quite
51
- # adequate, you need to provide a :class_singleton option when such
52
- # a class is given.
53
- #
54
50
  # e.g.:
55
51
  #
56
52
  # replace_methods MyClass, :public => [:a, :b]
@@ -63,16 +59,16 @@ module TemporaryClasses
63
59
  send visibility, name
64
60
  end
65
61
  end
66
- end
67
- end
68
-
69
- private # ---------------------------------------------------------
70
62
 
71
- def all_instance_methods(mod)
72
- names =
73
- mod.public_instance_methods(false) +
74
- mod.protected_instance_methods(false) +
75
- mod.private_instance_methods(false)
76
- names.map{|name| name.to_sym} # they're strings in ruby <1.9
63
+ if (methods = options[:undefined])
64
+ Array(methods).each do |name|
65
+ define_method(name){} unless method_defined?(name)
66
+ undef_method(name)
67
+ end
68
+ if Looksee.adapter.is_a?(TestAdapter)
69
+ Looksee.adapter.set_undefined_methods(mod, methods)
70
+ end
71
+ end
72
+ end
77
73
  end
78
74
  end
@@ -10,74 +10,23 @@ class TestAdapter < Looksee::Adapter::Base
10
10
  ancestors[object]
11
11
  end
12
12
 
13
- def internal_public_instance_methods(mod)
14
- public_methods[mod]
15
- end
16
-
17
- def internal_protected_instance_methods(mod)
18
- protected_methods[mod]
19
- end
20
-
21
- def internal_private_instance_methods(mod)
22
- private_methods[mod]
23
- end
24
-
25
13
  def internal_undefined_instance_methods(mod)
26
14
  undefined_methods[mod]
27
15
  end
28
16
 
29
- def included_class?(object)
30
- NATIVE_ADAPTER.included_class?(object)
31
- end
32
-
33
- def singleton_class?(object)
34
- NATIVE_ADAPTER.singleton_class?(object)
35
- end
36
-
37
17
  def singleton_instance(object)
38
18
  NATIVE_ADAPTER.singleton_instance(object)
39
19
  end
40
20
 
41
- def module_name(object)
42
- NATIVE_ADAPTER.module_name(object)
43
- end
44
-
45
- def set_methods(mod, public, protected, private, undefined)
46
- self.public_methods[mod] = public
47
- self.protected_methods[mod] = protected
48
- self.private_methods[mod] = private
49
- self.undefined_methods[mod] = undefined
50
- end
51
-
52
- def source_location(method)
53
- source_locations[[method.owner.name.to_s, method.name.to_s]]
54
- end
55
-
56
- def set_source_location(mod, method, location)
57
- source_locations[[mod.name.to_s, method.to_s]] = location
21
+ def set_undefined_methods(mod, names)
22
+ self.undefined_methods[mod] = names
58
23
  end
59
24
 
60
25
  def ancestors
61
26
  @ancestors ||= Hash.new { |h, k| h[k] = [] }
62
27
  end
63
28
 
64
- def public_methods
65
- @public_methods ||= Hash.new { |h, k| h[k] = [] }
66
- end
67
-
68
- def protected_methods
69
- @protected_methods ||= Hash.new { |h, k| h[k] = [] }
70
- end
71
-
72
- def private_methods
73
- @private_methods ||= Hash.new { |h, k| h[k] = [] }
74
- end
75
-
76
29
  def undefined_methods
77
30
  @undefined_methods ||= Hash.new { |h, k| h[k] = [] }
78
31
  end
79
-
80
- def source_locations
81
- @source_locations ||= {}
82
- end
83
32
  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: 3.1.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Ogata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-02 00:00:00.000000000 Z
11
+ date: 2016-08-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -26,35 +26,16 @@ files:
26
26
  - README.markdown
27
27
  - Rakefile
28
28
  - ext/extconf.rb
29
- - ext/mri/1.9.2/debug.h
30
- - ext/mri/1.9.2/id.h
31
- - ext/mri/1.9.2/method.h
32
- - ext/mri/1.9.2/node.h
33
- - ext/mri/1.9.2/thread_pthread.h
34
- - ext/mri/1.9.2/vm_core.h
35
- - ext/mri/1.9.2/vm_opts.h
36
- - ext/mri/1.9.3/atomic.h
37
- - ext/mri/1.9.3/debug.h
38
- - ext/mri/1.9.3/id.h
39
- - ext/mri/1.9.3/internal.h
40
- - ext/mri/1.9.3/internal_falcon.h
41
- - ext/mri/1.9.3/method.h
42
- - ext/mri/1.9.3/node.h
43
- - ext/mri/1.9.3/thread_pthread.h
44
- - ext/mri/1.9.3/vm_core.h
45
- - ext/mri/1.9.3/vm_opts.h
46
- - ext/mri/2.0.0/internal.h
47
- - ext/mri/2.0.0/method.h
48
29
  - ext/mri/2.1.0/internal.h
49
30
  - ext/mri/2.1.0/method.h
50
31
  - ext/mri/2.2.0/internal.h
51
32
  - ext/mri/2.2.0/method.h
52
- - ext/mri/env-1.8.h
53
- - ext/mri/eval_c-1.8.h
33
+ - ext/mri/2.3.0/internal.h
34
+ - ext/mri/2.3.0/method.h
54
35
  - ext/mri/mri.c
55
- - ext/mri/node-1.9.h
56
36
  - ext/rbx/rbx.c
57
37
  - lib/looksee.rb
38
+ - lib/looksee/JRuby.jar
58
39
  - lib/looksee/adapter.rb
59
40
  - lib/looksee/adapter/base.rb
60
41
  - lib/looksee/adapter/rubinius.rb
@@ -65,7 +46,6 @@ files:
65
46
  - lib/looksee/help.rb
66
47
  - lib/looksee/inspector.rb
67
48
  - lib/looksee/lookup_path.rb
68
- - lib/looksee/mri.bundle
69
49
  - lib/looksee/version.rb
70
50
  - spec/looksee/adapter_spec.rb
71
51
  - spec/looksee/clean_spec.rb
@@ -90,10 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
70
  requirements:
91
71
  - - ">="
92
72
  - !ruby/object:Gem::Version
93
- version: 1.9.3
94
- - - "<"
95
- - !ruby/object:Gem::Version
96
- version: '2.3'
73
+ version: '2.1'
97
74
  required_rubygems_version: !ruby/object:Gem::Requirement
98
75
  requirements:
99
76
  - - ">="
@@ -1,36 +0,0 @@
1
- /**********************************************************************
2
-
3
- debug.h - YARV Debug function interface
4
-
5
- $Author: akr $
6
- created at: 04/08/25 02:33:49 JST
7
-
8
- Copyright (C) 2004-2007 Koichi Sasada
9
-
10
- **********************************************************************/
11
-
12
- #ifndef RUBY_DEBUG_H
13
- #define RUBY_DEBUG_H
14
-
15
- #include "ruby/ruby.h"
16
- #include "node.h"
17
-
18
- #define dpv(h,v) ruby_debug_print_value(-1, 0, h, v)
19
- #define dp(v) ruby_debug_print_value(-1, 0, "", v)
20
- #define dpi(i) ruby_debug_print_id(-1, 0, "", i)
21
- #define dpn(n) ruby_debug_print_node(-1, 0, "", n)
22
-
23
- #define bp() ruby_debug_breakpoint()
24
-
25
- VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v);
26
- ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id);
27
- NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node);
28
- int ruby_debug_print_indent(int level, int debug_level, int indent_level);
29
- void ruby_debug_breakpoint(void);
30
- void ruby_debug_gc_check_func(void);
31
-
32
- #ifdef RUBY_DEBUG_ENV
33
- void ruby_set_debug_option(const char *str);
34
- #endif
35
-
36
- #endif /* RUBY_DEBUG_H */