method_extensions 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ module MethodExtensions
|
|
10
10
|
# Returns method source by parsing the file returned by `Method#source_location`.
|
11
11
|
#
|
12
12
|
# If method definition cannot be found `ArgumentError` exception is raised
|
13
|
-
# (this includes methods defined `attr_accessor`, `module_eval` etc.).
|
13
|
+
# (this includes methods defined by `attr_accessor`, `module_eval` etc.).
|
14
14
|
#
|
15
15
|
# Sample IRB session:
|
16
16
|
#
|
@@ -119,9 +119,53 @@ module MethodExtensions
|
|
119
119
|
# alias_method :inspect, :irb_inspect if method_defined?(:irb_inspect)
|
120
120
|
# end
|
121
121
|
def irb_inspect
|
122
|
+
return to_s if caller.grep(/pp\.rb/) # pretty_print has some logic
|
123
|
+
# based on output of Method#inspect, nasty, huh?
|
124
|
+
|
122
125
|
require "coderay"
|
123
|
-
|
124
|
-
|
126
|
+
require "rdoc/ri/driver"
|
127
|
+
|
128
|
+
puts to_s
|
129
|
+
|
130
|
+
if source_location
|
131
|
+
puts "#{ source_location[0] }:#{ source_location[1] }"
|
132
|
+
end
|
133
|
+
|
134
|
+
d = doc
|
135
|
+
|
136
|
+
if d && !(d = d.chomp).empty?
|
137
|
+
# puts
|
138
|
+
# TODO
|
139
|
+
# 1. is there better way to drive RDoc?
|
140
|
+
# 2. probably need to detect other doc types?
|
141
|
+
# 3. RDoc::Markup::ToAnsi formatter reflows to the 78 chars width which
|
142
|
+
# looks ugly
|
143
|
+
#
|
144
|
+
# begin
|
145
|
+
# formatter = Class.new(RDoc::Markup::ToAnsi) do
|
146
|
+
# def wrap(text)
|
147
|
+
# @res << text
|
148
|
+
# end
|
149
|
+
# end.new
|
150
|
+
# parser = Class.new.extend(RDoc::Text)
|
151
|
+
# d = d.split("\n").map { |l| parser.parse(l).accept(formatter) }.join("\n")
|
152
|
+
## rescue Exception => e
|
153
|
+
# puts e.inspect
|
154
|
+
# # anything goes wrong - just display comment verbatim
|
155
|
+
# end
|
156
|
+
print d
|
157
|
+
# puts
|
158
|
+
end
|
159
|
+
|
160
|
+
begin
|
161
|
+
src = source
|
162
|
+
if src && !src.empty?
|
163
|
+
puts CodeRay.scan(source_unindent(src), :ruby).term
|
164
|
+
end
|
165
|
+
rescue ArgumentError => e
|
166
|
+
puts e.message
|
167
|
+
end
|
168
|
+
|
125
169
|
nil
|
126
170
|
end
|
127
171
|
|
data/method_extensions.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.unshift lib unless $:.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "method_extensions"
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.6"
|
7
7
|
s.authors = ["Evgeniy Dolzhenko"]
|
8
8
|
s.email = ["dolzenko@gmail.com"]
|
9
9
|
s.homepage = "http://github.com/dolzenko/method_extensions"
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Evgeniy Dolzhenko
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-02 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|