README.rdoc in sender-1.0.1 vs README.rdoc in sender-1.1.0
- old
+ new
@@ -1,41 +1,91 @@
Sender:
== DESCRIPTION:
+http://rubygems.org/gems/sender
Adds __sender__ and __caller__ to the built-in __callee__ and __method__ functions.
+
+ Adds object-oriented backtrace, which returns :object and :method for each stack frame,
+ and which permits queries regarding backtrace contents.
+
+ * __sender__
+ * __caller__
+ * backtrace
+ * backtrace( frames_to_trace_backward )
+ * backtrace_includes?( Class )
+ * backtrace_includes?( class_instance )
+ * backtrace_includes?( :symbol )
+ * backtrace_includes?( Class, class_instance, :symbol, ... )
-== SYNOPSIS:
+== INSTALL:
- Example:
+ * sudo gem install sender
- require 'sender'
+== EXAMPLE:
- class SenderTest
- def sender_test
- puts( 'Caller was: ' + __caller__.to_s )
- puts( 'Sender was: ' + __sender__.to_s )
- end
- end
+ require 'sender'
- class Test
- def run_tests
- test = SenderTest.new
- test.sender_test
- end
- end
+ require '../sender/lib/sender/sender'
- test = Test.new
- test.run_tests
-
- Outputs:
-
- Caller was: sender_test
- Sender was: #<SenderTest:0x0000010103ee88>
+ require 'pp'
-== INSTALL:
+ class Test
- * sudo gem install sender
+ def test
+ self.another_test
+ end
+
+ def another_test
+ test2 = Test2.new
+ test2.and_another_test_in_another_object
+ end
+
+ end
+
+ class Test2
+
+ def and_another_test_in_another_object
+ puts 'Sender was: ' + __sender__.pretty_inspect.to_s
+ puts 'Caller was: ' + __caller__.to_s
+ pp Kernel.backtrace
+ pp Kernel.backtrace( 2 )
+ puts 'These should be true:'
+ pp Kernel.backtrace_includes?( :another_test )
+ pp Kernel.backtrace_includes?( Test )
+ pp Kernel.backtrace_includes?( $test )
+ pp Kernel.backtrace_includes?( :another_test, Test, $test )
+ puts 'These should be false:'
+ pp Kernel.backtrace_includes?( :non_existing_function )
+ pp Kernel.backtrace_includes?( Test2 )
+ pp Kernel.backtrace_includes?( self )
+ pp Kernel.backtrace_includes?( :non_existing_function, Test2, self )
+ end
+
+ end
+
+ $test = Test.new
+ $test.test
+
+== EXAMPLE's OUTPUT:
+
+ Sender was: #<Test:0x0000010101ef18>
+ Caller was: and_another_test_in_another_object
+ [{:object=>#<Test:0x0000010101ef18>, :method=>:another_test},
+ {:object=>#<Test:0x0000010101ef18>, :method=>:test},
+ {:object=>main}]
+ [{:object=>#<Test:0x0000010101ef18>, :method=>:another_test},
+ {:object=>#<Test:0x0000010101ef18>, :method=>:test}]
+ These should be true:
+ true
+ true
+ true
+ true
+ These should be false:
+ false
+ false
+ false
+ false
== LICENSE:
(The MIT License)
\ No newline at end of file