looksee 5.0.0 → 5.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/README.markdown +97 -73
- data/ext/mri/mri.c +4 -0
- data/lib/looksee/clean.rb +1 -0
- data/lib/looksee/help.rb +2 -0
- data/lib/looksee/inspector.rb +2 -11
- data/lib/looksee/pretty_print_hack.rb +14 -0
- data/lib/looksee/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e79d312ff99899463a1ae1c3ef7c223bd2761cd51d03fdb4349cb3620c06f624
|
4
|
+
data.tar.gz: 2c5e23a018a88ef8c7bed8c3e9ea230ed81fb58dcd6f2479b3752cbe5e44cac3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef17ec0b836a791aac8b814b9f825aceff66ea346f1ba3f2a6e9504e686d439013583b2c362b2e2c5626d32ca9ec58fd2f1dfecf95f9b503ccb2fd2ee08ceca5
|
7
|
+
data.tar.gz: 5e0d129f6977c2b32b8671168b9fd1ab5e5bc26a1efc0e07e88176ac80c8675d459210c639ef54ad51b088971acb75964886571a8aac81e04a7cc241ac736d51
|
data/CHANGELOG
CHANGED
data/README.markdown
CHANGED
@@ -13,73 +13,97 @@ Pop this in your `.irbrc`:
|
|
13
13
|
|
14
14
|
require 'looksee'
|
15
15
|
|
16
|
-
Now each object has a method `
|
17
|
-
|
18
|
-
irb> [].
|
19
|
-
=>
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
Now each object has a method `look`, which shows you all its methods.
|
17
|
+
|
18
|
+
irb> [].look
|
19
|
+
=>
|
20
|
+
BasicObject
|
21
|
+
! __send__ instance_exec singleton_method_undefined
|
22
|
+
!= equal? method_missing
|
23
|
+
== initialize singleton_method_added
|
24
|
+
__id__ instance_eval singleton_method_removed
|
23
25
|
Kernel
|
24
|
-
!~
|
25
|
-
<=>
|
26
|
-
===
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
Rational
|
34
|
-
String
|
35
|
-
__callee__
|
36
|
-
__dir__
|
37
|
-
__method__
|
38
|
-
`
|
39
|
-
abort
|
40
|
-
at_exit
|
41
|
-
autoload
|
42
|
-
autoload?
|
43
|
-
binding
|
44
|
-
block_given?
|
45
|
-
caller
|
46
|
-
caller_locations
|
47
|
-
catch
|
48
|
-
class
|
49
|
-
clone
|
50
|
-
define_singleton_method
|
51
|
-
display
|
52
|
-
dup
|
26
|
+
!~ format public_method
|
27
|
+
<=> freeze public_methods
|
28
|
+
=== frozen? public_send
|
29
|
+
Array gem putc
|
30
|
+
Complex gem_original_require puts
|
31
|
+
Float gets raise
|
32
|
+
Hash global_variables rand
|
33
|
+
Integer hash readline
|
34
|
+
Pathname initialize_clone readlines
|
35
|
+
Rational initialize_copy remove_instance_variable
|
36
|
+
String initialize_dup require
|
37
|
+
__callee__ inspect require_relative
|
38
|
+
__dir__ instance_of? respond_to?
|
39
|
+
__method__ instance_variable_defined? respond_to_missing?
|
40
|
+
` instance_variable_get select
|
41
|
+
abort instance_variable_set send
|
42
|
+
at_exit instance_variables set_trace_func
|
43
|
+
autoload is_a? singleton_class
|
44
|
+
autoload? iterator? singleton_method
|
45
|
+
binding itself singleton_methods
|
46
|
+
block_given? kind_of? sleep
|
47
|
+
caller lambda spawn
|
48
|
+
caller_locations load sprintf
|
49
|
+
catch local_variables srand
|
50
|
+
class loop syscall
|
51
|
+
clone method system
|
52
|
+
define_singleton_method methods tap
|
53
|
+
display nil? test
|
54
|
+
dup object_id then
|
55
|
+
enum_for open throw
|
56
|
+
eql? p to_enum
|
57
|
+
eval pp to_s
|
58
|
+
exec pretty_inspect trace_var
|
59
|
+
exit print trap
|
60
|
+
exit! printf untrace_var
|
61
|
+
extend private_methods warn
|
62
|
+
fail proc yield_self
|
63
|
+
fork protected_methods
|
53
64
|
Looksee::ObjectMixin
|
54
|
-
|
65
|
+
look
|
66
|
+
PP::ObjectMixin
|
67
|
+
pretty_print pretty_print_inspect
|
68
|
+
pretty_print_cycle pretty_print_instance_variables
|
55
69
|
Object
|
56
|
-
DelegateClass
|
70
|
+
DelegateClass
|
57
71
|
Enumerable
|
58
|
-
all?
|
59
|
-
any?
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
72
|
+
all? drop find_all max reject tally
|
73
|
+
any? drop_while find_index max_by reverse_each to_a
|
74
|
+
chain each_cons first member? select to_h
|
75
|
+
chunk each_entry flat_map min slice_after to_set
|
76
|
+
chunk_while each_slice grep min_by slice_before uniq
|
77
|
+
collect each_with_index grep_v minmax slice_when zip
|
78
|
+
collect_concat each_with_object group_by minmax_by sort
|
79
|
+
compact entries include? none? sort_by
|
80
|
+
count filter inject one? sum
|
81
|
+
cycle filter_map lazy partition take
|
82
|
+
detect find map reduce take_while
|
66
83
|
Array
|
67
|
-
&
|
68
|
-
*
|
69
|
-
+
|
70
|
-
-
|
71
|
-
<<
|
72
|
-
<=>
|
73
|
-
==
|
74
|
-
[]
|
75
|
-
[]=
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
84
|
+
& count include? pretty_print size
|
85
|
+
* cycle index pretty_print_cycle slice
|
86
|
+
+ deconstruct initialize product slice!
|
87
|
+
- delete initialize_copy push sort
|
88
|
+
<< delete_at insert rassoc sort!
|
89
|
+
<=> delete_if inspect reject sort_by!
|
90
|
+
== difference intersect? reject! sum
|
91
|
+
[] dig intersection repeated_combination take
|
92
|
+
[]= drop join repeated_permutation take_while
|
93
|
+
all? drop_while keep_if replace to_a
|
94
|
+
any? each last reverse to_ary
|
95
|
+
append each_index length reverse! to_h
|
96
|
+
assoc empty? map reverse_each to_s
|
97
|
+
at eql? map! rindex transpose
|
98
|
+
bsearch fetch max rotate union
|
99
|
+
bsearch_index fill min rotate! uniq
|
100
|
+
clear filter minmax sample uniq!
|
101
|
+
collect filter! none? select unshift
|
102
|
+
collect! find_index one? select! values_at
|
103
|
+
combination first pack shelljoin zip
|
104
|
+
compact flatten permutation shift |
|
105
|
+
compact! flatten! pop shuffle
|
106
|
+
concat hash prepend shuffle!
|
83
107
|
|
84
108
|
Methods are colored according to whether they're public, protected,
|
85
109
|
private, undefined (using Module#undef_method), or overridden.
|
@@ -88,11 +112,11 @@ private, undefined (using Module#undef_method), or overridden.
|
|
88
112
|
|
89
113
|
You can hide, say, private methods like this:
|
90
114
|
|
91
|
-
irb> [].
|
115
|
+
irb> [].look :noprivate
|
92
116
|
|
93
117
|
Or filter the list by Regexp:
|
94
118
|
|
95
|
-
irb> [].
|
119
|
+
irb> [].look /^to_/
|
96
120
|
=> BasicObject
|
97
121
|
Kernel
|
98
122
|
to_enum to_s
|
@@ -107,32 +131,32 @@ Or filter the list by Regexp:
|
|
107
131
|
## Proxy objects
|
108
132
|
|
109
133
|
Objects that delegate everything via `method_missing` to some other object can
|
110
|
-
be tricky, because they will delegate `
|
111
|
-
always do:
|
134
|
+
be tricky, because they will delegate `look` itself. To view such objects, you
|
135
|
+
can always do:
|
112
136
|
|
113
137
|
Looksee[object]
|
114
138
|
|
115
|
-
This will also work for `BasicObject` instances that don't have an `
|
116
|
-
`Object#
|
139
|
+
This will also work for `BasicObject` instances that don't have an `look`
|
140
|
+
method. `Object#look` is simply a wrapper around `Looksee.[]`.
|
117
141
|
|
118
142
|
## To the source!
|
119
143
|
|
120
144
|
If you want to know more about any of those methods, Looksee can
|
121
145
|
take you straight to the source in your editor:
|
122
146
|
|
123
|
-
[].
|
147
|
+
[].look.edit :to_set
|
124
148
|
|
125
149
|
By default, this uses `vi`; customize it like this:
|
126
150
|
|
127
151
|
# %f = file, %l = line number
|
128
152
|
Looksee.editor = "mate -l%l %f"
|
129
153
|
|
130
|
-
## `
|
154
|
+
## `look` in your way?
|
131
155
|
|
132
|
-
If you have a library that for some reason can't handle an `
|
133
|
-
on `Object`, you may rename it like this:
|
156
|
+
If you have a library that for some reason can't handle an `look` method
|
157
|
+
existing on `Object`, you may rename it like this:
|
134
158
|
|
135
|
-
Looksee.rename :
|
159
|
+
Looksee.rename :_look
|
136
160
|
|
137
161
|
## Quick Reference
|
138
162
|
|
data/ext/mri/mri.c
CHANGED
@@ -17,7 +17,11 @@ VALUE Looksee_internal_undefined_instance_methods(VALUE self, VALUE klass) {
|
|
17
17
|
|
18
18
|
VALUE Looksee_singleton_instance(VALUE self, VALUE klass) {
|
19
19
|
if (!SPECIAL_CONST_P(klass) && BUILTIN_TYPE(klass) == T_CLASS && FL_TEST(klass, FL_SINGLETON)) {
|
20
|
+
#if RUBY_VERSION < 330
|
20
21
|
VALUE object = rb_ivar_get(klass, rb_intern("__attached__"));
|
22
|
+
#else
|
23
|
+
VALUE object = rb_class_attached_object(klass);
|
24
|
+
#endif
|
21
25
|
if (object == Qnil)
|
22
26
|
rb_raise(rb_eRuntimeError, "[looksee bug] can't find singleton object");
|
23
27
|
return object;
|
data/lib/looksee/clean.rb
CHANGED
data/lib/looksee/help.rb
CHANGED
data/lib/looksee/inspector.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Looksee
|
2
2
|
class Inspector
|
3
|
+
include PrettyPrintHack
|
4
|
+
|
3
5
|
def initialize(lookup_path, options={})
|
4
6
|
@lookup_path = lookup_path
|
5
7
|
@visibilities = (vs = options[:visibilities]) ? vs.to_set : Set[]
|
@@ -20,17 +22,6 @@ module Looksee
|
|
20
22
|
end.join("\n")
|
21
23
|
end
|
22
24
|
|
23
|
-
def pretty_print(pp)
|
24
|
-
# In the default IRB inspect mode (pp), IRB assumes that an inspect string
|
25
|
-
# that doesn't look like a bunch of known patterns is a code blob, and
|
26
|
-
# formats accordingly. That messes up our color escapes.
|
27
|
-
if Object.const_defined?(:IRB) && IRB.const_defined?(:ColorPrinter) && pp.is_a?(IRB::ColorPrinter)
|
28
|
-
PP.instance_method(:text).bind(pp).call(inspect)
|
29
|
-
else
|
30
|
-
pp.text(inspect)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
25
|
#
|
35
26
|
# Open an editor at the named method's definition.
|
36
27
|
#
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Looksee
|
2
|
+
module PrettyPrintHack
|
3
|
+
def pretty_print(pp)
|
4
|
+
# In the default IRB inspect mode (pp), IRB assumes that an inspect string
|
5
|
+
# that doesn't look like a bunch of known patterns is a code blob, and
|
6
|
+
# formats accordingly. That messes up our color escapes.
|
7
|
+
if Object.const_defined?(:IRB) && IRB.const_defined?(:ColorPrinter) && pp.is_a?(IRB::ColorPrinter)
|
8
|
+
PP.instance_method(:text).bind(pp).call(inspect)
|
9
|
+
else
|
10
|
+
pp.text(inspect)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/looksee/version.rb
CHANGED
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: 5.
|
4
|
+
version: 5.1.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:
|
11
|
+
date: 2025-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/looksee/help.rb
|
62
62
|
- lib/looksee/inspector.rb
|
63
63
|
- lib/looksee/lookup_path.rb
|
64
|
+
- lib/looksee/pretty_print_hack.rb
|
64
65
|
- lib/looksee/version.rb
|
65
66
|
- spec/looksee/adapter_spec.rb
|
66
67
|
- spec/looksee/clean_spec.rb
|
@@ -92,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
93
|
- !ruby/object:Gem::Version
|
93
94
|
version: '0'
|
94
95
|
requirements: []
|
95
|
-
rubygems_version: 3.
|
96
|
+
rubygems_version: 3.5.9
|
96
97
|
signing_key:
|
97
98
|
specification_version: 3
|
98
99
|
summary: Supercharged method introspection in IRB.
|