sender 1.5.9 → 1.5.10
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.rdoc +278 -278
- data/ext/sender/RPSender_internal.c +23 -23
- data/ext/sender/RPSender_internal.h +9 -9
- data/ext/sender/RubySourceSupport.c +20 -20
- data/ext/sender/RubySourceSupport.h +65 -65
- data/ext/sender/extconf.rb +4 -4
- data/ext/sender/rb_Global.c +107 -107
- data/ext/sender/rb_Global.h +6 -6
- data/ext/sender/rb_Global_internal.h +4 -4
- data/ext/sender/rb_Kernel.c +556 -556
- data/ext/sender/rb_Kernel.h +24 -24
- data/ext/sender/rb_Kernel_internal.h +5 -5
- data/ext/sender/sender.c +6 -6
- metadata +68 -70
data/README.rdoc
CHANGED
@@ -11,311 +11,311 @@ and :backtrace_includes_one_of? for context inspection, and :backtrace_frame_wit
|
|
11
11
|
matching frame information for the frame(s) matching the given description.
|
12
12
|
|
13
13
|
== SUMMARY:
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
14
|
+
|
15
|
+
Adds object-oriented backtrace, which returns :object, :method, :line, and :file for each stack frame,
|
16
|
+
and which permits queries regarding backtrace contents.
|
17
|
+
|
18
|
+
* __sender__
|
19
|
+
* __caller__
|
20
|
+
* backtrace
|
21
|
+
* backtrace( frames_to_trace_backward )
|
22
|
+
* each_backtrace_frame
|
23
|
+
* each_backtrace_frame( frames_to_trace_backward )
|
24
|
+
* backtrace_includes?( Class, class_instance, :symbol, {frame_hash}, ... )
|
25
|
+
* backtrace_includes?( frames_to_trace_backward, Class, class_instance, :symbol, {frame_hash}, ... )
|
26
|
+
* backtrace_includes_one_of?( Class, class_instance, :symbol, {frame_hash}, ... )
|
27
|
+
* backtrace_includes_one_of?( frames_to_trace_backward, Class, class_instance, :symbol, {frame_hash}, ... )
|
28
|
+
* backtrace_frame_with( Class, class_instance, :symbol, {frame_hash}, ... )
|
29
|
+
* backtrace_frame_with( frames_to_trace_backward, Class, class_instance, :symbol, {frame_hash}, ... )
|
30
|
+
* backtrace_frames_with( Class, class_instance, :symbol, {frame_hash}, ... )
|
31
|
+
* backtrace_frames_with( frames_to_trace_backward, Class, class_instance, :symbol, {frame_hash}, ... )
|
32
32
|
|
33
33
|
== INSTALL:
|
34
34
|
|
35
|
-
|
35
|
+
* sudo gem install sender
|
36
36
|
|
37
37
|
== EXAMPLE:
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
require 'sender'
|
40
|
+
require 'pp'
|
41
41
|
|
42
|
-
|
42
|
+
class Test
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
def initialize
|
45
|
+
puts 'In method <Test>:initialize'
|
46
|
+
puts 'Sender was: ' + __sender__.pretty_inspect.to_s
|
47
|
+
puts 'Caller was: ' + __caller__.to_s
|
48
|
+
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
def test
|
51
|
+
puts 'In <Test>:test'
|
52
|
+
self.another_test
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
def another_test
|
56
|
+
puts 'In method <Test>:another_test'
|
57
|
+
test2 = Test2.new
|
58
|
+
test2.and_another_test_in_another_object
|
59
|
+
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
def and_another_test_in_another_object
|
62
|
+
puts 'In method <Test>:and_another_test_in_another_object'
|
63
|
+
puts 'Sender was: ' + __sender__.pretty_inspect.to_s
|
64
|
+
puts 'Caller was: ' + __caller__.to_s
|
65
|
+
end
|
66
66
|
|
67
|
-
|
67
|
+
end
|
68
68
|
|
69
|
-
|
69
|
+
class Test2 < Test
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
def initialize
|
72
|
+
puts 'In method <Test2>:initialize'
|
73
|
+
super
|
74
|
+
puts 'Sender was: ' + __sender__.pretty_inspect.to_s
|
75
|
+
puts 'Caller was: ' + __caller__.to_s
|
76
|
+
pp Kernel.backtrace
|
77
|
+
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
79
|
+
def and_another_test_in_another_object
|
80
|
+
puts 'In method <Test2>:and_another_test_in_another_object'
|
81
|
+
super
|
82
|
+
pp self
|
83
|
+
puts 'Sender was: ' + __sender__.pretty_inspect.to_s
|
84
|
+
puts 'Caller was: ' + __caller__.to_s
|
85
|
+
pp Kernel.backtrace
|
86
|
+
pp Kernel.backtrace( 2 )
|
87
|
+
puts 'These should be true:'
|
88
|
+
pp Kernel.backtrace_includes?( :another_test )
|
89
|
+
pp Kernel.backtrace_includes?( Test )
|
90
|
+
pp Kernel.backtrace_includes?( $test )
|
91
|
+
pp Kernel.backtrace_includes?( :another_test, Test, $test )
|
92
|
+
pp Kernel.backtrace_includes?( "sender_test.rb" )
|
93
|
+
puts 'These should be false:'
|
94
|
+
pp Kernel.backtrace_includes?( :yet_another_test )
|
95
|
+
pp Kernel.backtrace_includes?( Test2 )
|
96
|
+
pp Kernel.backtrace_includes?( self )
|
97
|
+
pp Kernel.backtrace_includes?( :yet_another_test, Test2, self )
|
98
|
+
pp Kernel.backtrace_includes?( "sender_test.rbi" )
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
100
|
+
puts 'And now we get a step by step backtrace'
|
101
|
+
which_step = 1
|
102
|
+
Kernel.each_backtrace_frame do |this_frame|
|
103
|
+
puts 'Frame number ' + which_step.to_s + ':'
|
104
|
+
pp this_frame
|
105
|
+
which_step += 1
|
106
|
+
end
|
107
|
+
puts 'And now we try a backtrace inside a block.'
|
108
|
+
block_item = [ 'one_item' ]
|
109
|
+
block_item.each do |this_item|
|
110
|
+
pp Kernel.backtrace
|
111
|
+
end
|
112
112
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
113
|
+
puts 'And :backtrace_includes_one_of?; this should be true:'
|
114
|
+
pp Kernel.backtrace_includes_one_of?( :some_method_that_does_not_exit, :another_test, :test, :some_other_test_that_does_not_exist )
|
115
|
+
puts 'as should this:'
|
116
|
+
pp Kernel.backtrace_includes_one_of?( { :method => :another_test, :object => $test }, { :method => :test } )
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
puts 'And :backtrace_frame_with; this should be a Hash:'
|
119
|
+
pp Kernel.backtrace_frame_with( :test )
|
120
|
+
puts 'as should this:'
|
121
|
+
pp Kernel.backtrace_frame_with( "sender_test.rb" )
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
puts 'And :backtrace_frames_with; this should be an Array of Hashes'
|
124
|
+
pp Kernel.backtrace_frames_with( :object => $test )
|
125
|
+
puts 'as should this:'
|
126
|
+
pp Kernel.backtrace_frames_with( :file => "sender_test.rb" )
|
127
127
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
128
|
+
puts 'And try iterating with an Enumerator'
|
129
|
+
enumerator = Kernel.each_backtrace_frame
|
130
|
+
pp enumerator
|
131
|
+
while result = enumerator.next
|
132
|
+
pp result
|
133
|
+
end
|
134
134
|
|
135
|
-
|
136
|
-
|
135
|
+
end
|
136
|
+
end
|
137
137
|
|
138
138
|
== EXAMPLE's OUTPUT:
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
139
|
+
|
140
|
+
In method <Test>:initialize
|
141
|
+
Sender was: main
|
142
|
+
Caller was: <main>
|
143
|
+
In <Test>:test
|
144
|
+
In method <Test>:another_test
|
145
|
+
In method <Test2>:initialize
|
146
|
+
In method <Test>:initialize
|
147
|
+
Sender was: #<Test:0x0000010081ba10>
|
148
|
+
Caller was: another_test
|
149
|
+
Sender was: #<Test:0x0000010081ba10>
|
150
|
+
Caller was: another_test
|
151
|
+
[{:object=>#<Test2:0x0000010081a7e8>,
|
152
|
+
:file=>"sender_test.rb",
|
153
|
+
:line=>39,
|
154
|
+
:method=>:initialize},
|
155
|
+
{:object=>Test2, :file=>nil, :line=>nil, :method=>:new},
|
156
|
+
{:object=>#<Test:0x0000010081ba10>,
|
157
|
+
:file=>"sender_test.rb",
|
158
|
+
:line=>20,
|
159
|
+
:method=>:another_test},
|
160
|
+
{:object=>#<Test:0x0000010081ba10>,
|
161
|
+
:file=>"sender_test.rb",
|
162
|
+
:line=>15,
|
163
|
+
:method=>:test},
|
164
|
+
{:object=>main, :file=>"sender_test.rb", :line=>96, :method=>:"<main>"},
|
165
|
+
{:object=>main, :file=>"<main>", :line=>0, :method=>:"<main>"}]
|
166
|
+
In method <Test2>:and_another_test_in_another_object
|
167
|
+
In method <Test>:and_another_test_in_another_object
|
168
|
+
Sender was: #<Test2:0x0000010081a7e8>
|
169
|
+
Caller was: another_test
|
170
|
+
#<Test2:0x0000010081a7e8>
|
171
|
+
Sender was: #<Test:0x0000010081ba10>
|
172
|
+
Caller was: another_test
|
173
|
+
[{:object=>#<Test2:0x0000010081a7e8>,
|
174
|
+
:file=>"sender_test.rb",
|
175
|
+
:line=>48,
|
176
|
+
:method=>:and_another_test_in_another_object},
|
177
|
+
{:object=>#<Test:0x0000010081ba10>,
|
178
|
+
:file=>"sender_test.rb",
|
179
|
+
:line=>21,
|
180
|
+
:method=>:another_test},
|
181
|
+
{:object=>#<Test:0x0000010081ba10>,
|
182
|
+
:file=>"sender_test.rb",
|
183
|
+
:line=>15,
|
184
|
+
:method=>:test},
|
185
|
+
{:object=>main, :file=>"sender_test.rb", :line=>96, :method=>:"<main>"},
|
186
|
+
{:object=>main, :file=>"<main>", :line=>0, :method=>:"<main>"}]
|
187
|
+
[{:object=>#<Test2:0x0000010081a7e8>,
|
188
|
+
:file=>"sender_test.rb",
|
189
|
+
:line=>49,
|
190
|
+
:method=>:and_another_test_in_another_object},
|
191
|
+
{:object=>#<Test:0x0000010081ba10>,
|
192
|
+
:file=>"sender_test.rb",
|
193
|
+
:line=>21,
|
194
|
+
:method=>:another_test}]
|
195
|
+
These should be true:
|
196
|
+
true
|
197
|
+
true
|
198
|
+
true
|
199
|
+
true
|
200
|
+
true
|
201
|
+
These should be false:
|
202
|
+
false
|
203
|
+
false
|
204
|
+
false
|
205
|
+
false
|
206
|
+
false
|
207
|
+
And now we get a step by step backtrace
|
208
|
+
Frame number 1:
|
209
|
+
{:object=>#<Test:0x0000010081ba10>,
|
210
|
+
:file=>"sender_test.rb",
|
211
|
+
:line=>21,
|
212
|
+
:method=>:another_test}
|
213
|
+
Frame number 2:
|
214
|
+
{:object=>#<Test:0x0000010081ba10>,
|
215
|
+
:file=>"sender_test.rb",
|
216
|
+
:line=>15,
|
217
|
+
:method=>:test}
|
218
|
+
Frame number 3:
|
219
|
+
{:object=>main, :file=>"sender_test.rb", :line=>96, :method=>:"<main>"}
|
220
|
+
Frame number 4:
|
221
|
+
{:object=>main, :file=>"<main>", :line=>0, :method=>:"<main>"}
|
222
|
+
And now we try a backtrace inside a block.
|
223
|
+
[{:object=>#<Test2:0x0000010081a7e8>,
|
224
|
+
:file=>"sender_test.rb",
|
225
|
+
:line=>73,
|
226
|
+
:method=>:"block in and_another_test_in_another_object"},
|
227
|
+
{:object=>["one_item"], :file=>nil, :line=>nil, :method=>:each},
|
228
|
+
{:object=>#<Test2:0x0000010081a7e8>,
|
229
|
+
:file=>"sender_test.rb",
|
230
|
+
:line=>72,
|
231
|
+
:method=>:and_another_test_in_another_object},
|
232
|
+
{:object=>#<Test:0x0000010081ba10>,
|
233
|
+
:file=>"sender_test.rb",
|
234
|
+
:line=>21,
|
235
|
+
:method=>:another_test},
|
236
|
+
{:object=>#<Test:0x0000010081ba10>,
|
237
|
+
:file=>"sender_test.rb",
|
238
|
+
:line=>15,
|
239
|
+
:method=>:test},
|
240
|
+
{:object=>main, :file=>"sender_test.rb", :line=>96, :method=>:"<main>"},
|
241
|
+
{:object=>main, :file=>"<main>", :line=>0, :method=>:"<main>"}]
|
242
|
+
And :backtrace_includes_one_of?; this should be true:
|
243
|
+
true
|
244
|
+
as should this:
|
245
|
+
true
|
246
|
+
And :backtrace_frame_with; this should be a Hash:
|
247
|
+
{:object=>#<Test:0x0000010081ba10>,
|
248
|
+
:file=>"sender_test.rb",
|
249
|
+
:line=>15,
|
250
|
+
:method=>:test}
|
251
|
+
as should this:
|
252
|
+
{:object=>#<Test:0x0000010081ba10>,
|
253
|
+
:file=>"sender_test.rb",
|
254
|
+
:line=>21,
|
255
|
+
:method=>:another_test}
|
256
|
+
And :backtrace_frames_with; this should be an Array of Hashes
|
257
|
+
[{:object=>#<Test:0x0000010081ba10>,
|
258
|
+
:file=>"sender_test.rb",
|
259
|
+
:line=>21,
|
260
|
+
:method=>:another_test},
|
261
|
+
{:object=>#<Test:0x0000010081ba10>,
|
262
|
+
:file=>"sender_test.rb",
|
263
|
+
:line=>15,
|
264
|
+
:method=>:test}]
|
265
|
+
as should this:
|
266
|
+
[{:object=>#<Test:0x0000010081ba10>,
|
267
|
+
:file=>"sender_test.rb",
|
268
|
+
:line=>21,
|
269
|
+
:method=>:another_test},
|
270
|
+
{:object=>#<Test:0x0000010081ba10>,
|
271
|
+
:file=>"sender_test.rb",
|
272
|
+
:line=>15,
|
273
|
+
:method=>:test},
|
274
|
+
{:object=>main, :file=>"sender_test.rb", :line=>96, :method=>:"<main>"}]
|
275
|
+
And try iterating with an Enumerator
|
276
|
+
#<Enumerator:0x000001010480e0>
|
277
|
+
{:object=>#<Test2:0x0000010081a388>,
|
278
|
+
:file=>"sender_test.rb",
|
279
|
+
:line=>92,
|
280
|
+
:method=>:and_another_test_in_another_object}
|
281
|
+
{:object=>#<Test:0x0000010081b770>,
|
282
|
+
:file=>"sender_test.rb",
|
283
|
+
:line=>21,
|
284
|
+
:method=>:another_test}
|
285
|
+
{:object=>#<Test:0x0000010081b770>,
|
286
|
+
:file=>"sender_test.rb",
|
287
|
+
:line=>15,
|
288
|
+
:method=>:test}
|
289
|
+
{:object=>main, :file=>"sender_test.rb", :line=>103, :method=>:"<main>"}
|
290
|
+
{:object=>main, :file=>"<main>", :line=>0, :method=>:"<main>"}
|
291
|
+
sender_test.rb:94:in `next': iteration reached at end (StopIteration)
|
292
|
+
from sender_test.rb:94:in `and_another_test_in_another_object'
|
293
|
+
from sender_test.rb:21:in `another_test'
|
294
|
+
from sender_test.rb:15:in `test'
|
295
|
+
from sender_test.rb:103:in `<main>'
|
296
|
+
Finished Test.
|
297
297
|
|
298
298
|
== LICENSE:
|
299
299
|
|
300
|
-
|
300
|
+
(The MIT License)
|
301
301
|
|
302
|
-
|
302
|
+
Copyright (c) 2010 Asher
|
303
303
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
304
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
305
|
+
a copy of this software and associated documentation files (the
|
306
|
+
'Software'), to deal in the Software without restriction, including
|
307
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
308
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
309
|
+
permit persons to whom the Software is furnished to do so, subject to
|
310
|
+
the following conditions:
|
311
311
|
|
312
|
-
|
313
|
-
|
312
|
+
The above copyright notice and this permission notice shall be
|
313
|
+
included in all copies or substantial portions of the Software.
|
314
314
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
315
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
316
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
317
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
318
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
319
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
320
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
321
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|