rogerdpack-desc_method 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README +21 -13
- data/lib/method_describer/method_desc.rb +3 -2
- metadata +1 -1
data/README
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
A "run time RI for ruby methods", this gem allows you to
|
1
|
+
A "run time RI for ruby methods", this gem allows you to query for information about objects' methods within irb or a ruby-debug prompt. It reveals everything known about the method. This includes source, ri, arity, rdoc comments (on 1.9), etc. where available
|
2
2
|
|
3
3
|
For me it has proved quite useful, and I wouldn't do a ruby-debug session without it--try it--you might really like it.
|
4
4
|
|
5
|
-
|
5
|
+
Examples:
|
6
6
|
>> class A;
|
7
7
|
def go(a); end;
|
8
8
|
end
|
@@ -15,7 +15,6 @@ def go(a)
|
|
15
15
|
# do nothing
|
16
16
|
end
|
17
17
|
Parameters: go(a)
|
18
|
-
|
19
18
|
>> File.desc_method :delete
|
20
19
|
ri for File.delete
|
21
20
|
----------------------------------------------------------- File::delete
|
@@ -33,7 +32,7 @@ appears to be a c method
|
|
33
32
|
#parameters signature: delete( [[:rest]] )
|
34
33
|
|
35
34
|
|
36
|
-
Or my favorite
|
35
|
+
Or (my favorite) using it in a debug session:
|
37
36
|
(rdb:1) l=
|
38
37
|
...
|
39
38
|
=> 74 assert(assigns['order'].order_line_items.map(:unit_price).min >= -5)
|
@@ -62,29 +61,38 @@ def assert(boolean, message = nil)
|
|
62
61
|
end
|
63
62
|
end
|
64
63
|
Parameters: assert(boolean, message = nil)
|
64
|
+
(rdb:1)
|
65
|
+
|
66
|
+
========= How to Install=====
|
67
|
+
$ gem install rogerdpack-desc_method
|
68
|
+
or
|
69
|
+
$ gem install rogerdpack-desc_method --source http://gems.github.com
|
70
|
+
if you don't have gems.github.com as a gem source.
|
65
71
|
|
66
|
-
========= Installation/usage:=====
|
67
|
-
Installation:
|
68
|
-
$ gem install rogerdpack-desc_method
|
69
72
|
Usage:
|
70
73
|
>> require 'desc_method'
|
71
74
|
>> Class.desc_method :method_name # class or instance method name
|
72
75
|
...
|
73
|
-
>>
|
76
|
+
>> some_object.desc_method :method_name
|
74
77
|
...
|
75
78
|
|
76
79
|
Other goodies also included:
|
77
80
|
Class#desc_class
|
81
|
+
|
82
|
+
Examples:
|
78
83
|
>> Object.desc_class
|
79
|
-
# outputs descriptive info about that class--RI,
|
84
|
+
# outputs descriptive info about that class--RI, method list, etc.
|
80
85
|
>> Object.desc_class :verbose => true
|
81
|
-
# outputs RI, method lists including inherited methods, ancestors, constants
|
86
|
+
# outputs RI, method lists including inherited methods, ancestors, all constants etc.
|
82
87
|
|
83
|
-
Kernel#methods
|
88
|
+
Kernel#methods
|
89
|
+
This has been monkey patched to output a "separator" between its inherited and non inherited methods--i.e.
|
84
90
|
>> instance.methods
|
85
91
|
=> [:first, :second, :after_this_are_inherited>>>>>, :some_inherited_method, :another_inherited_method] # adds in that separator
|
86
92
|
|
93
|
+
Though I'll probably remove that in a future release since it turns out you can just run Kernel#methods(false) for about as much usefulness.
|
94
|
+
|
87
95
|
=== Thanks ===
|
88
|
-
This gem wraps functionality of Method#source_location, ruby2ruby, et al, and also some from manvenu, SourceRef (MBARI), and also
|
96
|
+
This gem wraps for convenience the functionality of Method#source_location, ruby2ruby, et al, and also contains some code inspiration from manvenu, SourceRef (MBARI), and Python's Method#desc. It also wouldn't be useful without irb and the ruby-debug folks. Thanks!
|
89
97
|
|
90
|
-
Comments/suggestions welcome rogerdpack on gmail or github
|
98
|
+
Comments/suggestions welcome rogerdpack on gmail or github
|
@@ -48,11 +48,12 @@ module SourceLocationDesc
|
|
48
48
|
joiner = $1
|
49
49
|
method_name = $2
|
50
50
|
full_name = "#{class_name}#{joiner}#{method_name}"
|
51
|
-
puts "#{to_s} arity: #{arity}"
|
51
|
+
puts "#{to_s} arity: #{arity}"
|
52
|
+
# TODO add to doc, I want it before ri for now though, and only once, so not there yet :)
|
52
53
|
|
53
54
|
# now run default RI for it
|
54
55
|
begin
|
55
|
-
puts 'ri for ' + full_name
|
56
|
+
puts 'searching ri for ' + full_name + "..."
|
56
57
|
RDoc::RI::Driver.run [full_name, '--no-pager'] unless want_just_summary
|
57
58
|
rescue *[StandardError, SystemExit]
|
58
59
|
# not found
|