rogerdpack-desc_method 0.1.2 → 0.1.3

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.
data/README CHANGED
@@ -1,24 +1,21 @@
1
- A "ruby method describer"--this gem allows you to introspect methods while within irb or ruby-debug. It reveals everything conceivably known about that method. This includes source, ri, arity, rdoc comments (on 1.9), etc. etc.
1
+ A "run time RI for ruby methods", this gem allows you to inspect objects' methods while within irb or ruby-debug. It reveals everything known about the method in question. This includes source, ri, arity, rdoc comments (on 1.9), etc. where available
2
2
 
3
- For me it has proved quite useful, and I wouldn't leave home without it [try it--you might really like it].
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
- Examples:
6
- >>
7
- class A;
5
+ irb examples:
6
+ >> class A;
8
7
  def go(a); end;
9
- end
8
+ end
10
9
  >> A.desc_method :go
11
- # it outputs everything it knows about it...arity, source, RI, etc.
10
+ #<UnboundMethod: A#go> arity: 1
12
11
  ri for A#go
13
12
  Nothing known about A
14
13
  (end ri)
15
- #<UnboundMethod: A#go> arity: 1
16
- A#go a
17
- proc { |a|
14
+ def go(a)
18
15
  # do nothing
19
- }
16
+ end
17
+ Parameters: go(a)
20
18
 
21
- an example in 1.9:
22
19
  >> File.desc_method :delete
23
20
  ri for File.delete
24
21
  ----------------------------------------------------------- File::delete
@@ -35,6 +32,37 @@ ri for File.delete
35
32
  appears to be a c method
36
33
  #parameters signature: delete( [[:rest]] )
37
34
 
35
+
36
+ Or my favorite, using it in debug sessions:
37
+ (rdb:1) l=
38
+ ...
39
+ => 74 assert(assigns['order'].order_line_items.map(:unit_price).min >= -5)
40
+ ...
41
+ (rdb:1) desc_method :assert
42
+ #<Method: StoreControllerTest(Test::Unit::Assertions)#assert> arity: -2
43
+ ri for Test::Unit::Assertions#assert
44
+ ------------------------------------------ Test::Unit::Assertions#assert
45
+ assert(boolean, message=nil)
46
+
47
+ From gem test-unit-2.0.1
48
+ ------------------------------------------------------------------------
49
+ Asserts that +boolean+ is not false or nil.
50
+
51
+ Example:
52
+
53
+ assert [1, 2].include?(5)
54
+
55
+ (end ri)
56
+ def assert(boolean, message = nil)
57
+ _wrap_assertion do
58
+ assert_block("assert should not be called with a block.") do
59
+ (not block_given?)
60
+ end
61
+ assert_block(build_message(message, "<?> is not true.", boolean)) { boolean }
62
+ end
63
+ end
64
+ Parameters: assert(boolean, message = nil)
65
+
38
66
  ========= Installation/usage:=====
39
67
  Installation:
40
68
  $ gem install rogerdpack-desc_method
@@ -45,19 +73,18 @@ Usage:
45
73
  >> instance.desc_method :instance_method_name
46
74
  ...
47
75
 
48
- other goodies also included:
49
- Class.desc_class method # outputs descriptive information about that class--ex:
76
+ Other goodies also included:
77
+ Class#desc_class
50
78
  >> Object.desc_class
51
- # outputs RI, methods, etc.
52
- or
79
+ # outputs descriptive info about that class--RI, methods, etc.
53
80
  >> Object.desc_class :verbose => true
54
81
  # outputs RI, method lists including inherited methods, ancestors, constants
55
82
 
56
- Kernel#method is monkey patched to output a "separator" between its inherited and non inherited methods--i.e.
57
- >> method
58
- => [:first, :second, :after_this_are_inherited>>>>>, :some_inherited_method, :another_inherited_method] # adds in the separator
59
-
83
+ Kernel#methods is also monkey patched to output a "separator" between its inherited and non inherited methods--i.e.
84
+ >> instance.methods
85
+ => [:first, :second, :after_this_are_inherited>>>>>, :some_inherited_method, :another_inherited_method] # adds in that separator
60
86
 
61
- This gem wraps (in a very convenient way) functionality provided by Method#source_location, ruby2ruby, etc. Also thanks to manvenu for some original code inspiration, SourceRef (MBARI), and ruby-debug, who made this possible. Thanks guys!
87
+ === Thanks ===
88
+ This gem wraps functionality of Method#source_location, ruby2ruby, et al, and also some from manvenu, SourceRef (MBARI), and also would not be useful without ruby-debug and all the core guys. Thank you.
62
89
 
63
90
  Comments/suggestions welcome rogerdpack on gmail or github
@@ -122,7 +122,11 @@ module SourceLocationDesc
122
122
 
123
123
  puts doc # always output it since RI does currently [todo make optional I suppose, and non out-putty]
124
124
 
125
- doc if want_the_description_returned # give them something they can examine
125
+ if want_the_description_returned # give them something they can examine
126
+ doc
127
+ else
128
+ self
129
+ end
126
130
  end
127
131
 
128
132
  named_args_for :desc # just for fun, tests use it too, plus it should actually wurk without interfering...I think
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rogerdpack-desc_method
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Pack