looksee 1.0.0-universal-java-1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +14 -0
- data/LICENSE +22 -0
- data/README.markdown +161 -0
- data/Rakefile +10 -0
- 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/mri/node-1.9.h +35 -0
- data/ext/rbx/rbx.c +13 -0
- data/lib/looksee.rb +5 -0
- 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/jruby.jar +0 -0
- data/lib/looksee/lookup_path.rb +95 -0
- data/lib/looksee/rbx.bundle +0 -0
- data/lib/looksee/shortcuts.rb +3 -0
- data/lib/looksee/version.rb +11 -0
- data/lib/looksee/wirble_compatibility.rb +86 -0
- 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 +25 -0
- 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 +116 -0
- metadata +158 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'mocha'
|
3
|
+
require 'looksee'
|
4
|
+
|
5
|
+
require 'rbconfig'
|
6
|
+
require 'set'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
ROOT = File.dirname(File.dirname(__FILE__))
|
10
|
+
|
11
|
+
Dir['spec/support/*.rb'].each do |path|
|
12
|
+
require path
|
13
|
+
end
|
14
|
+
|
15
|
+
NATIVE_ADAPTER = Looksee.adapter
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.mock_with :mocha
|
19
|
+
config.before { Looksee.adapter = TestAdapter.new }
|
20
|
+
end
|
21
|
+
|
22
|
+
if Looksee.ruby_engine == 'jruby'
|
23
|
+
require 'jruby'
|
24
|
+
JRuby.objectspace = true
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Object
|
2
|
+
#
|
3
|
+
# Return this object's singleton class.
|
4
|
+
#
|
5
|
+
def singleton_class
|
6
|
+
class << self; self; end
|
7
|
+
end
|
8
|
+
|
9
|
+
#
|
10
|
+
# Return true if the given object include?-s this object.
|
11
|
+
#
|
12
|
+
def in?(object)
|
13
|
+
object.include?(self)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class String
|
18
|
+
#
|
19
|
+
# Remove a left margin delimited by '|'-characters. Useful for
|
20
|
+
# heredocs:
|
21
|
+
#
|
22
|
+
def demargin
|
23
|
+
gsub(/^ *\|/, '')
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#
|
2
|
+
# Include these in example groups to add facilities to create
|
3
|
+
# temporary classes and modules, which are swept up at the end of each
|
4
|
+
# example.
|
5
|
+
#
|
6
|
+
# Call make_class('ClassName') or make_module('ModuleName') to create
|
7
|
+
# a temporary class, then access them with plain constants (ClassName,
|
8
|
+
# ModuleName).
|
9
|
+
#
|
10
|
+
module TemporaryClasses
|
11
|
+
def self.included(mod)
|
12
|
+
mod.before do
|
13
|
+
@temporary_modules = []
|
14
|
+
end
|
15
|
+
|
16
|
+
mod.after do
|
17
|
+
@temporary_modules.each do |mod|
|
18
|
+
Object.send :remove_const, mod.name
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Create a temporary class with the given name and superclass.
|
25
|
+
#
|
26
|
+
def temporary_class(name, options={}, &block)
|
27
|
+
klass = Class.new(options[:superclass] || Object)
|
28
|
+
Object.const_set(name, klass)
|
29
|
+
klass.class_eval(&block) if block
|
30
|
+
@temporary_modules << klass
|
31
|
+
klass
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Create a temporary module with the given name.
|
36
|
+
#
|
37
|
+
def temporary_module(name, &block)
|
38
|
+
mod = Module.new
|
39
|
+
Object.const_set(name, mod)
|
40
|
+
mod.class_eval(&block) if block
|
41
|
+
@temporary_modules << mod
|
42
|
+
mod
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Remove all methods defined exactly on the given module.
|
47
|
+
#
|
48
|
+
# As Ruby's reflection on singleton classes of classes isn't quite
|
49
|
+
# adequate, you need to provide a :class_singleton option when such
|
50
|
+
# a class is given.
|
51
|
+
#
|
52
|
+
def remove_methods(mod, opts={})
|
53
|
+
names = all_instance_methods(mod)
|
54
|
+
|
55
|
+
# all_instance_methods can't get just the methods on a class
|
56
|
+
# singleton class. Filter out superclass methods here.
|
57
|
+
if opts[:class_singleton]
|
58
|
+
klass = ObjectSpace.each_object(mod){|klass| break klass}
|
59
|
+
names -= all_instance_methods(klass.superclass.singleton_class)
|
60
|
+
end
|
61
|
+
|
62
|
+
names.sort_by{|name| name.in?([:remove_method, :send]) ? 1 : 0}.flatten
|
63
|
+
names.each do |name|
|
64
|
+
mod.send :remove_method, name
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Replace the methods of the given module with those named.
|
70
|
+
#
|
71
|
+
# +methods+ is a hash of visibilities to names.
|
72
|
+
#
|
73
|
+
# As Ruby's reflection on singleton classes of classes isn't quite
|
74
|
+
# adequate, you need to provide a :class_singleton option when such
|
75
|
+
# a class is given.
|
76
|
+
#
|
77
|
+
# e.g.:
|
78
|
+
#
|
79
|
+
# replace_methods MyClass, :public => [:a, :b]
|
80
|
+
#
|
81
|
+
def replace_methods(mod, options={})
|
82
|
+
remove_methods(mod, options)
|
83
|
+
mod.module_eval do
|
84
|
+
[:public, :protected, :private].each do |visibility|
|
85
|
+
Array(options[visibility]).each do |name|
|
86
|
+
define_method(name){}
|
87
|
+
send visibility, name
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
private # ---------------------------------------------------------
|
94
|
+
|
95
|
+
def all_instance_methods(mod)
|
96
|
+
names =
|
97
|
+
mod.public_instance_methods(false) +
|
98
|
+
mod.protected_instance_methods(false) +
|
99
|
+
mod.private_instance_methods(false)
|
100
|
+
names.map{|name| name.to_sym} # they're strings in ruby <1.9
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
class TestAdapter < Looksee::Adapter::Base
|
2
|
+
def lookup_modules(object)
|
3
|
+
ancestors[object]
|
4
|
+
end
|
5
|
+
|
6
|
+
def internal_public_instance_methods(mod)
|
7
|
+
public_methods[mod]
|
8
|
+
end
|
9
|
+
|
10
|
+
def internal_protected_instance_methods(mod)
|
11
|
+
protected_methods[mod]
|
12
|
+
end
|
13
|
+
|
14
|
+
def internal_private_instance_methods(mod)
|
15
|
+
private_methods[mod]
|
16
|
+
end
|
17
|
+
|
18
|
+
def internal_undefined_instance_methods(mod)
|
19
|
+
undefined_methods[mod]
|
20
|
+
end
|
21
|
+
|
22
|
+
def singleton_class?(object)
|
23
|
+
NATIVE_ADAPTER.singleton_class?(object)
|
24
|
+
end
|
25
|
+
|
26
|
+
def singleton_instance(object)
|
27
|
+
NATIVE_ADAPTER.singleton_instance(object)
|
28
|
+
end
|
29
|
+
|
30
|
+
def module_name(object)
|
31
|
+
NATIVE_ADAPTER.module_name(object)
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_methods(mod, public, protected, private, undefined)
|
35
|
+
self.public_methods[mod] = public
|
36
|
+
self.protected_methods[mod] = protected
|
37
|
+
self.private_methods[mod] = private
|
38
|
+
self.undefined_methods[mod] = undefined
|
39
|
+
end
|
40
|
+
|
41
|
+
def source_location(method)
|
42
|
+
source_locations[[method.owner.name.to_s, method.name.to_s]]
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_source_location(mod, method, location)
|
46
|
+
source_locations[[mod.name.to_s, method.to_s]] = location
|
47
|
+
end
|
48
|
+
|
49
|
+
def ancestors
|
50
|
+
@ancestors ||= Hash.new { |h, k| h[k] = [] }
|
51
|
+
end
|
52
|
+
|
53
|
+
def public_methods
|
54
|
+
@public_methods ||= Hash.new { |h, k| h[k] = [] }
|
55
|
+
end
|
56
|
+
|
57
|
+
def protected_methods
|
58
|
+
@protected_methods ||= Hash.new { |h, k| h[k] = [] }
|
59
|
+
end
|
60
|
+
|
61
|
+
def private_methods
|
62
|
+
@private_methods ||= Hash.new { |h, k| h[k] = [] }
|
63
|
+
end
|
64
|
+
|
65
|
+
def undefined_methods
|
66
|
+
@undefined_methods ||= Hash.new { |h, k| h[k] = [] }
|
67
|
+
end
|
68
|
+
|
69
|
+
def source_locations
|
70
|
+
@source_locations ||= {}
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
gem 'wirble' # die if wirble unavailable
|
3
|
+
|
4
|
+
describe Looksee::WirbleCompatibility do
|
5
|
+
describe "when looksee is loaded" do
|
6
|
+
#
|
7
|
+
# Run the given ruby string, and return the standard output.
|
8
|
+
#
|
9
|
+
def init_irb_with(code)
|
10
|
+
code = <<-EOS.demargin
|
11
|
+
|#{code}
|
12
|
+
|#{setup_code}
|
13
|
+
|c.ls
|
14
|
+
EOS
|
15
|
+
code = code.chomp.gsub(/\n/, ';') # only print value of last line
|
16
|
+
irb = File.join Config::CONFIG['bindir'], 'irb'
|
17
|
+
lib_dir = File.expand_path('lib')
|
18
|
+
# irb hangs when using readline without a tty
|
19
|
+
output = IO.popen("#{irb} -f --noreadline --noprompt --noverbose -I#{lib_dir} 2>&1", 'r+') do |io|
|
20
|
+
io.puts code
|
21
|
+
io.flush
|
22
|
+
io.close_write
|
23
|
+
io.read
|
24
|
+
end
|
25
|
+
# Ruby 1.9.2 prints an extra newline on exit.
|
26
|
+
output.chomp! if RUBY_VERSION >= '1.9.2'
|
27
|
+
output
|
28
|
+
end
|
29
|
+
|
30
|
+
def setup_code
|
31
|
+
<<-EOS.demargin
|
32
|
+
|C = Class.new
|
33
|
+
|c = C.new
|
34
|
+
|#{File.read('spec/support/test_adapter.rb')}
|
35
|
+
|
|
36
|
+
|Looksee.styles = Hash.new{'%s'}
|
37
|
+
|Looksee.styles[:public] = "\\e[1;32m%s\\e[0m"
|
38
|
+
|NATIVE_ADAPTER = Looksee.adapter
|
39
|
+
|Looksee.adapter = TestAdapter.new
|
40
|
+
|Looksee.adapter.ancestors[c] = [C]
|
41
|
+
|Looksee.adapter.public_methods[C] = [:a]
|
42
|
+
EOS
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should work if wirble is not loaded" do
|
46
|
+
output = init_irb_with(<<-EOS.demargin)
|
47
|
+
|require 'irb'
|
48
|
+
|require 'looksee'
|
49
|
+
|require 'wirble'
|
50
|
+
|Wirble.init
|
51
|
+
|Wirble.colorize
|
52
|
+
EOS
|
53
|
+
output.should == <<-EOS.demargin
|
54
|
+
|C
|
55
|
+
| \e[1;32ma\e[0m
|
56
|
+
EOS
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should work if wirble is loaded, but not initialized" do
|
60
|
+
output = init_irb_with(<<-EOS.demargin)
|
61
|
+
|require 'irb'
|
62
|
+
|require 'wirble'
|
63
|
+
|require 'looksee'
|
64
|
+
|Wirble.init
|
65
|
+
|Wirble.colorize
|
66
|
+
EOS
|
67
|
+
output.should == <<-EOS.demargin
|
68
|
+
|C
|
69
|
+
| \e[1;32ma\e[0m
|
70
|
+
EOS
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should work if wirble is loaded and initialized, but colorizing is off" do
|
74
|
+
output = init_irb_with(<<-EOS.demargin)
|
75
|
+
|require 'irb'
|
76
|
+
|require 'wirble'
|
77
|
+
|Wirble.init
|
78
|
+
|require 'looksee'
|
79
|
+
|Wirble.colorize
|
80
|
+
EOS
|
81
|
+
output.should == <<-EOS.demargin
|
82
|
+
|C
|
83
|
+
| \e[1;32ma\e[0m
|
84
|
+
EOS
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should work if wirble is loaded, initialized, and colorizing is on" do
|
88
|
+
output = init_irb_with(<<-EOS.demargin)
|
89
|
+
|require 'irb'
|
90
|
+
|require 'wirble'
|
91
|
+
|Wirble.init
|
92
|
+
|Wirble.colorize
|
93
|
+
|require 'looksee'
|
94
|
+
EOS
|
95
|
+
output.should == <<-EOS.demargin
|
96
|
+
|C
|
97
|
+
| \e[1;32ma\e[0m
|
98
|
+
EOS
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should work if wirble colorizing is enabled twice" do
|
102
|
+
output = init_irb_with(<<-EOS.demargin)
|
103
|
+
|require 'irb'
|
104
|
+
|require 'looksee'
|
105
|
+
|require 'wirble'
|
106
|
+
|Wirble.init
|
107
|
+
|Wirble.colorize
|
108
|
+
|Wirble.colorize
|
109
|
+
EOS
|
110
|
+
output.should == <<-EOS.demargin
|
111
|
+
|C
|
112
|
+
| \e[1;32ma\e[0m
|
113
|
+
EOS
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: looksee
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: universal-java-1.6
|
11
|
+
authors:
|
12
|
+
- George Ogata
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-03-09 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: ritual
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 2
|
30
|
+
- 0
|
31
|
+
version: 0.2.0
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rspec
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 2
|
43
|
+
- 0
|
44
|
+
- 0
|
45
|
+
version: 2.0.0
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: mocha
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id003
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: wirble
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
type: :development
|
71
|
+
version_requirements: *id004
|
72
|
+
description:
|
73
|
+
email:
|
74
|
+
- george.ogata@gmail.com
|
75
|
+
executables: []
|
76
|
+
|
77
|
+
extensions: []
|
78
|
+
|
79
|
+
extra_rdoc_files:
|
80
|
+
- CHANGELOG
|
81
|
+
- LICENSE
|
82
|
+
- README.markdown
|
83
|
+
files:
|
84
|
+
- lib/looksee.rb
|
85
|
+
- lib/looksee/adapter.rb
|
86
|
+
- lib/looksee/clean.rb
|
87
|
+
- lib/looksee/columnizer.rb
|
88
|
+
- lib/looksee/core_ext.rb
|
89
|
+
- lib/looksee/editor.rb
|
90
|
+
- lib/looksee/help.rb
|
91
|
+
- lib/looksee/inspector.rb
|
92
|
+
- lib/looksee/jruby.jar
|
93
|
+
- lib/looksee/lookup_path.rb
|
94
|
+
- lib/looksee/rbx.bundle
|
95
|
+
- lib/looksee/shortcuts.rb
|
96
|
+
- lib/looksee/version.rb
|
97
|
+
- lib/looksee/wirble_compatibility.rb
|
98
|
+
- lib/looksee/adapter/base.rb
|
99
|
+
- lib/looksee/adapter/rubinius.rb
|
100
|
+
- ext/mri/mri.c
|
101
|
+
- ext/rbx/rbx.c
|
102
|
+
- ext/mri/env-1.8.h
|
103
|
+
- ext/mri/eval_c-1.8.h
|
104
|
+
- ext/mri/node-1.9.h
|
105
|
+
- ext/mri/1.9.2/debug.h
|
106
|
+
- ext/mri/1.9.2/id.h
|
107
|
+
- ext/mri/1.9.2/method.h
|
108
|
+
- ext/mri/1.9.2/node.h
|
109
|
+
- ext/mri/1.9.2/thread_pthread.h
|
110
|
+
- ext/mri/1.9.2/vm_core.h
|
111
|
+
- ext/mri/1.9.2/vm_opts.h
|
112
|
+
- ext/extconf.rb
|
113
|
+
- CHANGELOG
|
114
|
+
- LICENSE
|
115
|
+
- Rakefile
|
116
|
+
- README.markdown
|
117
|
+
has_rdoc: true
|
118
|
+
homepage: http://github.com/oggy/looksee
|
119
|
+
licenses: []
|
120
|
+
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
version: "0"
|
140
|
+
requirements: []
|
141
|
+
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 1.3.6
|
144
|
+
signing_key:
|
145
|
+
specification_version: 3
|
146
|
+
summary: Supercharged method introspection in IRB.
|
147
|
+
test_files:
|
148
|
+
- spec/adapter_spec.rb
|
149
|
+
- spec/columnizer_spec.rb
|
150
|
+
- spec/core_ext_spec.rb
|
151
|
+
- spec/editor_spec.rb
|
152
|
+
- spec/inspector_spec.rb
|
153
|
+
- spec/lookup_path_spec.rb
|
154
|
+
- spec/spec_helper.rb
|
155
|
+
- spec/wirble_compatibility_spec.rb
|
156
|
+
- spec/support/core_ext.rb
|
157
|
+
- spec/support/temporary_classes.rb
|
158
|
+
- spec/support/test_adapter.rb
|