oggy-looksee 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/README.rdoc +11 -1
- data/lib/looksee/shortcuts.rb +53 -0
- data/lib/looksee/version.rb +1 -1
- data/lib/looksee/wirble_compatibility.rb +2 -1
- data/lib/looksee.rb +16 -12
- data/looksee.gemspec +3 -3
- data/script/console +4 -7
- metadata +3 -4
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -66,7 +66,13 @@ This defines a method +lp+ ("lookup path") which lets you do:
|
|
66
66
|
|
67
67
|
It'll also color the methods according to whether they're public,
|
68
68
|
protected, private, undefined (using Module#undef_method), or
|
69
|
-
overridden. So pretty.
|
69
|
+
overridden. So pretty. The default colors are:
|
70
|
+
|
71
|
+
public: green
|
72
|
+
protected: yellow
|
73
|
+
private: red
|
74
|
+
undefined: blue
|
75
|
+
overridden: black
|
70
76
|
|
71
77
|
By default, it shows public and protected methods. Add private ones
|
72
78
|
like so:
|
@@ -83,6 +89,10 @@ use it as a library without polluting the built-in classes. See:
|
|
83
89
|
|
84
90
|
$ ri Looksee
|
85
91
|
|
92
|
+
Or do this in IRB for a quick reference:
|
93
|
+
|
94
|
+
Looksee.help
|
95
|
+
|
86
96
|
Enjoy!
|
87
97
|
|
88
98
|
== INSTALL
|
data/lib/looksee/shortcuts.rb
CHANGED
@@ -52,3 +52,56 @@ class Object
|
|
52
52
|
self
|
53
53
|
end
|
54
54
|
end
|
55
|
+
|
56
|
+
module Looksee
|
57
|
+
#
|
58
|
+
# Show a quick reference.
|
59
|
+
#
|
60
|
+
def self.help
|
61
|
+
Help.new
|
62
|
+
end
|
63
|
+
|
64
|
+
class Help
|
65
|
+
def inspect
|
66
|
+
<<-EOS.gsub(/^ *\|/, '')
|
67
|
+
|== Looksee Quick Reference
|
68
|
+
|
|
69
|
+
| lp(object)
|
70
|
+
| object.lookup_path
|
71
|
+
| Print the method lookup path of \`object\'
|
72
|
+
|
|
73
|
+
| lpi(klass)
|
74
|
+
| Print the method lookup path of an instance of \`klass\'.
|
75
|
+
|
|
76
|
+
|Add .grep(/pattern/) to restrict the methods listed:
|
77
|
+
|
|
78
|
+
| lp(object).grep(/foo/)
|
79
|
+
|
|
80
|
+
|== Visibilities
|
81
|
+
|
|
82
|
+
|Methods are printed according to their visibility:
|
83
|
+
|
|
84
|
+
|#{style_info}
|
85
|
+
|
|
86
|
+
|Pass options to specify which visibilities to show:
|
87
|
+
|
|
88
|
+
| lp(object, :private => true, :overridden => false)
|
89
|
+
| lp(object, :private , :overridden => false) # shortcut
|
90
|
+
EOS
|
91
|
+
end
|
92
|
+
|
93
|
+
def style_info
|
94
|
+
max_width = 0
|
95
|
+
styles = [:public, :protected, :private, :undefined, :overridden]
|
96
|
+
data = styles.map do |name|
|
97
|
+
display_style = Looksee.styles[name] % name
|
98
|
+
display_length = display_style.length
|
99
|
+
max_width = display_length if display_length > max_width
|
100
|
+
on = Looksee.default_lookup_path_options[name] ? 'on' : 'off'
|
101
|
+
[display_style, on]
|
102
|
+
end.map do |display_style, on|
|
103
|
+
" * #{display_style.ljust(max_width)} (#{on} by default)"
|
104
|
+
end.join("\n")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/lib/looksee/version.rb
CHANGED
@@ -38,7 +38,8 @@ module Looksee
|
|
38
38
|
def hook_into_irb_output_value
|
39
39
|
IRB::Irb.class_eval do
|
40
40
|
def output_value_with_looksee
|
41
|
-
|
41
|
+
case @context.last_value
|
42
|
+
when Looksee::LookupPath, Looksee::Help
|
42
43
|
non_color_output_value
|
43
44
|
else
|
44
45
|
output_value_without_looksee
|
data/lib/looksee.rb
CHANGED
@@ -46,6 +46,10 @@ require "looksee/version"
|
|
46
46
|
# require 'looksee'
|
47
47
|
# Looksee.lookup_path(thing) # like "lp thing"
|
48
48
|
#
|
49
|
+
# For a quick reference:
|
50
|
+
#
|
51
|
+
# Looksee.help
|
52
|
+
#
|
49
53
|
# == Configuration
|
50
54
|
#
|
51
55
|
# Set these:
|
@@ -116,12 +120,12 @@ module Looksee
|
|
116
120
|
# Default:
|
117
121
|
#
|
118
122
|
# {
|
119
|
-
# :module => "\e[1;37m%s\e[0m",
|
120
|
-
# :public => "\e[1;32m%s\e[0m",
|
121
|
-
# :protected => "\e[1;33m%s\e[0m",
|
122
|
-
# :private => "\e[1;31m%s\e[0m",
|
123
|
-
# :undefined => "\e[1;34m%s\e[0m",
|
124
|
-
# :overridden => "\e[1;30m%s\e[0m",
|
123
|
+
# :module => "\e[1;37m%s\e[0m", # white
|
124
|
+
# :public => "\e[1;32m%s\e[0m", # green
|
125
|
+
# :protected => "\e[1;33m%s\e[0m", # yellow
|
126
|
+
# :private => "\e[1;31m%s\e[0m", # red
|
127
|
+
# :undefined => "\e[1;34m%s\e[0m", # blue
|
128
|
+
# :overridden => "\e[1;30m%s\e[0m", # black
|
125
129
|
# }
|
126
130
|
#
|
127
131
|
attr_accessor :styles
|
@@ -144,12 +148,12 @@ module Looksee
|
|
144
148
|
self.default_lookup_path_options = {:public => true, :protected => true, :undefined => true, :overridden => true}
|
145
149
|
self.default_width = 80
|
146
150
|
self.styles = {
|
147
|
-
:module => "\e[1;37m%s\e[0m",
|
148
|
-
:public => "\e[1;32m%s\e[0m",
|
149
|
-
:protected => "\e[1;33m%s\e[0m",
|
150
|
-
:private => "\e[1;31m%s\e[0m",
|
151
|
-
:undefined => "\e[1;34m%s\e[0m",
|
152
|
-
:overridden => "\e[1;30m%s\e[0m",
|
151
|
+
:module => "\e[1;37m%s\e[0m", # white
|
152
|
+
:public => "\e[1;32m%s\e[0m", # green
|
153
|
+
:protected => "\e[1;33m%s\e[0m", # yellow
|
154
|
+
:private => "\e[1;31m%s\e[0m", # red
|
155
|
+
:undefined => "\e[1;34m%s\e[0m", # blue
|
156
|
+
:overridden => "\e[1;30m%s\e[0m", # black
|
153
157
|
}
|
154
158
|
|
155
159
|
class LookupPath
|
data/looksee.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{looksee}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.2.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["George Ogata"]
|
9
|
-
s.date = %q{2009-08-
|
9
|
+
s.date = %q{2009-08-30}
|
10
10
|
s.description = %q{Looksee lets you examine the method lookup path of objects in ways not
|
11
11
|
possible in plain ruby.}
|
12
12
|
s.email = ["george.ogata@gmail.com"]
|
@@ -17,7 +17,7 @@ possible in plain ruby.}
|
|
17
17
|
s.rdoc_options = ["--main", "README.rdoc"]
|
18
18
|
s.require_paths = ["lib", "ext/looksee"]
|
19
19
|
s.rubyforge_project = %q{looksee}
|
20
|
-
s.rubygems_version = %q{1.3.
|
20
|
+
s.rubygems_version = %q{1.3.5}
|
21
21
|
s.summary = %q{Looksee lets you examine the method lookup path of objects in ways not possible in plain ruby.}
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
data/script/console
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# File: script/console
|
3
|
-
|
4
|
-
|
5
|
-
libs = " -r irb/completion"
|
6
|
-
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
-
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
-
libs << " -r #{File.dirname(__FILE__) + '/../lib/looksee.rb'}"
|
3
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
4
|
+
require 'irb'
|
9
5
|
puts "Loading looksee gem"
|
10
|
-
|
6
|
+
require 'looksee/shortcuts'
|
7
|
+
IRB.start
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oggy-looksee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Ogata
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-30 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -86,7 +86,6 @@ files:
|
|
86
86
|
- tasks/extconf/looksee.rake
|
87
87
|
has_rdoc: false
|
88
88
|
homepage: http://github.com/oggy/looksee
|
89
|
-
licenses:
|
90
89
|
post_install_message:
|
91
90
|
rdoc_options:
|
92
91
|
- --main
|
@@ -109,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
108
|
requirements: []
|
110
109
|
|
111
110
|
rubyforge_project: looksee
|
112
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.2.0
|
113
112
|
signing_key:
|
114
113
|
specification_version: 3
|
115
114
|
summary: Looksee lets you examine the method lookup path of objects in ways not possible in plain ruby.
|