== Sender http://rubygems.org/gems/sender == DESCRIPTION: Adds __sender__ and __caller__ to the built-in __callee__ and __method__ functions. == SUMMARY: 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, ... ) == INSTALL: * sudo gem install sender == EXAMPLE: require 'sender' require '../sender/lib/sender/sender' require 'pp' class Test 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: # Caller was: and_another_test_in_another_object [{:object=>#, :method=>:another_test}, {:object=>#, :method=>:test}, {:object=>main}] [{:object=>#, :method=>:another_test}, {:object=>#, :method=>:test}] These should be true: true true true true These should be false: false false false false == LICENSE: (The MIT License) Copyright (c) 2010 Asher Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.