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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48ef0a2047045795c76025fd0544aaa9c2c2545903cad6c944fffcfcb2ee75d0
4
- data.tar.gz: 23493fa986e3b3eb584db4d50d921aa036ee260dc69a6a87f03fe194aed4c26a
3
+ metadata.gz: e79d312ff99899463a1ae1c3ef7c223bd2761cd51d03fdb4349cb3620c06f624
4
+ data.tar.gz: 2c5e23a018a88ef8c7bed8c3e9ea230ed81fb58dcd6f2479b3752cbe5e44cac3
5
5
  SHA512:
6
- metadata.gz: 3e286370942fed7ed9b420e5448639a1a7a3903afcb092d6777f974632ba78c347fc146f95b0dd0b9bb215743d94a498a7402ee17a84d95bcfb4638da14efb6f
7
- data.tar.gz: e96734ae3281967a23a13c287c39e1ea2469782348886936ba63827de8cdbeb2e0fa0a0698658351078f31accb6efeabcc3152eab71917b5412602056c9f0055
6
+ metadata.gz: ef17ec0b836a791aac8b814b9f825aceff66ea346f1ba3f2a6e9504e686d439013583b2c362b2e2c5626d32ca9ec58fd2f1dfecf95f9b503ccb2fd2ee08ceca5
7
+ data.tar.gz: 5e0d129f6977c2b32b8671168b9fd1ab5e5bc26a1efc0e07e88176ac80c8675d459210c639ef54ad51b088971acb75964886571a8aac81e04a7cc241ac736d51
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == 5.1.0 2025-03-28
2
+
3
+ * Support for MRI 3.3.
4
+ * Fix color escaping in Looksee.help.
5
+
1
6
  == 5.0.0 2022-11-08
2
7
 
3
8
  * Rename #ls to #look. Sorry! irb now defines an ls built-in, though, and the
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 `ls`, which shows you all its methods.
17
-
18
- irb> [].ls
19
- => BasicObject
20
- ! __id__ initialize method_missing singleton_method_undefined
21
- != __send__ instance_eval singleton_method_added
22
- == equal? instance_exec singleton_method_removed
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
- !~ enum_for kind_of? respond_to_missing?
25
- <=> eql? lambda select
26
- === eval load send
27
- =~ exec local_variables set_trace_func
28
- Array exit loop singleton_class
29
- Complex exit! method singleton_method
30
- Float extend methods singleton_methods
31
- Hash fail nil? sleep
32
- Integer fork object_id spawn
33
- Rational format open sprintf
34
- String freeze p srand
35
- __callee__ frozen? print syscall
36
- __dir__ gem printf system
37
- __method__ gem_original_require private_methods taint
38
- ` gets proc tainted?
39
- abort global_variables protected_methods tap
40
- at_exit hash public_method test
41
- autoload initialize_clone public_methods throw
42
- autoload? initialize_copy public_send to_enum
43
- binding initialize_dup putc to_s
44
- block_given? inspect puts trace_var
45
- caller instance_of? raise trap
46
- caller_locations instance_variable_defined? rand trust
47
- catch instance_variable_get readline untaint
48
- class instance_variable_set readlines untrace_var
49
- clone instance_variables remove_instance_variable untrust
50
- define_singleton_method is_a? require untrusted?
51
- display iterator? require_relative warn
52
- dup itself respond_to?
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
- ls
65
+ look
66
+ PP::ObjectMixin
67
+ pretty_print pretty_print_inspect
68
+ pretty_print_cycle pretty_print_instance_variables
55
69
  Object
56
- DelegateClass default_src_encoding irb_binding
70
+ DelegateClass
57
71
  Enumerable
58
- all? detect entries group_by min reject take
59
- any? drop find include? min_by reverse_each take_while
60
- chunk drop_while find_all inject minmax select to_a
61
- chunk_while each_cons find_index lazy minmax_by slice_after to_h
62
- collect each_entry first map none? slice_before to_set
63
- collect_concat each_slice flat_map max one? slice_when zip
64
- count each_with_index grep max_by partition sort
65
- cycle each_with_object grep_v member? reduce sort_by
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
- & collect! eql? keep_if reverse sort!
68
- * combination fetch last reverse! sort_by!
69
- + compact fill length reverse_each take
70
- - compact! find_index map rindex take_while
71
- << concat first map! rotate to_a
72
- <=> count flatten pack rotate! to_ary
73
- == cycle flatten! permutation sample to_h
74
- [] delete frozen? pop select to_s
75
- []= delete_at hash product select! transpose
76
- any? delete_if include? push shift uniq
77
- assoc dig index rassoc shuffle uniq!
78
- at drop initialize reject shuffle! unshift
79
- bsearch drop_while initialize_copy reject! size values_at
80
- bsearch_index each insert repeated_combination slice zip
81
- clear each_index inspect repeated_permutation slice! |
82
- collect empty? join replace sort
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> [].ls :noprivate
115
+ irb> [].look :noprivate
92
116
 
93
117
  Or filter the list by Regexp:
94
118
 
95
- irb> [].ls /^to_/
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 `ls` itself. To view such objects, you can
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 `ls` method.
116
- `Object#ls` is simply a wrapper around `Looksee.[]`.
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
- [].ls.edit :to_set
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
- ## `ls` in your way?
154
+ ## `look` in your way?
131
155
 
132
- If you have a library that for some reason can't handle an `ls` method existing
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 :_ls
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
@@ -15,6 +15,7 @@ module Looksee
15
15
  autoload :Help, 'looksee/help'
16
16
  autoload :Inspector, 'looksee/inspector'
17
17
  autoload :LookupPath, 'looksee/lookup_path'
18
+ autoload :PrettyPrintHack, 'looksee/pretty_print_hack'
18
19
 
19
20
  class << self
20
21
  #
data/lib/looksee/help.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Looksee
2
2
  class Help
3
+ include PrettyPrintHack
4
+
3
5
  def inspect
4
6
  <<-EOS.gsub(/^ *\|/, '')
5
7
  |== Looksee Quick Reference
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Looksee
2
- VERSION = [5, 0, 0]
2
+ VERSION = [5, 1, 0]
3
3
 
4
4
  class << VERSION
5
5
  include Comparable
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.0.0
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: 2022-11-08 00:00:00.000000000 Z
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.3.6
96
+ rubygems_version: 3.5.9
96
97
  signing_key:
97
98
  specification_version: 3
98
99
  summary: Supercharged method introspection in IRB.