rubybreaker 0.0.6 → 0.0.7
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/NEWS +3 -0
- data/README.md +1 -2
- data/Rakefile +1 -0
- data/TODO +0 -8
- data/TUTORIAL.md +33 -7
- data/VERSION +1 -1
- data/lib/rubybreaker.rb +12 -4
- data/lib/rubybreaker/debug/error.rb +1 -1
- data/lib/rubybreaker/runtime.rb +16 -12
- data/lib/rubybreaker/runtime/monitor.rb +116 -84
- data/lib/rubybreaker/runtime/pluggable.rb +8 -2
- data/lib/rubybreaker/runtime/type_system.rb +77 -10
- data/lib/rubybreaker/task.rb +6 -0
- data/lib/rubybreaker/util.rb +23 -0
- data/test/integrated/tc_checking.rb +71 -0
- data/test/integrated/tc_class_methods.rb +14 -4
- data/test/testtask/sample.rb +1 -0
- data/test/testtask/tc_testtask.rb +14 -2
- data/test/ts_integrated.rb +1 -0
- data/webpage/index.html +1 -2
- data/webpage/rdoc/Object.html +0 -2
- data/webpage/rdoc/Rake.html +0 -2
- data/webpage/rdoc/Rake/RubyBreakerTestTask.html +19 -5
- data/webpage/rdoc/RubyBreaker.html +35 -3
- data/webpage/rdoc/RubyBreaker/Breakable.html +1 -3
- data/webpage/rdoc/RubyBreaker/Broken.html +1 -3
- data/webpage/rdoc/RubyBreaker/Context.html +0 -2
- data/webpage/rdoc/RubyBreaker/Errors.html +0 -2
- data/webpage/rdoc/RubyBreaker/Errors/InternalError.html +0 -2
- data/webpage/rdoc/RubyBreaker/Errors/InvalidSubtypeCheck.html +0 -2
- data/webpage/rdoc/RubyBreaker/Errors/InvalidTypeConstruction.html +0 -2
- data/webpage/rdoc/RubyBreaker/Errors/SubtypeFailure.html +0 -2
- data/webpage/rdoc/RubyBreaker/Errors/TypeError.html +0 -2
- data/webpage/rdoc/RubyBreaker/Errors/UserError.html +2 -4
- data/webpage/rdoc/RubyBreaker/ObjectPosition.html +0 -2
- data/webpage/rdoc/RubyBreaker/Position.html +0 -2
- data/webpage/rdoc/RubyBreaker/RDocSupport.html +0 -2
- data/webpage/rdoc/RubyBreaker/RubyTypeUtils.html +0 -2
- data/webpage/rdoc/RubyBreaker/Runtime.html +39 -6
- data/webpage/rdoc/RubyBreaker/Runtime/Inspector.html +0 -2
- data/webpage/rdoc/RubyBreaker/Runtime/MethodInfo.html +0 -2
- data/webpage/rdoc/RubyBreaker/Runtime/Monitor.html +295 -28
- data/webpage/rdoc/RubyBreaker/Runtime/MonitorInstaller.html +30 -43
- data/webpage/rdoc/RubyBreaker/Runtime/MonitorSwitch.html +4 -6
- data/webpage/rdoc/RubyBreaker/Runtime/ObjectWrapper.html +0 -2
- data/webpage/rdoc/RubyBreaker/Runtime/Pluggable.html +78 -18
- data/webpage/rdoc/RubyBreaker/Runtime/TypeSigParser.html +0 -2
- data/webpage/rdoc/RubyBreaker/Runtime/TypeSigUnparser.html +0 -2
- data/webpage/rdoc/RubyBreaker/Runtime/TypeSystem.html +172 -28
- data/webpage/rdoc/RubyBreaker/TypeComparer.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/AnyType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/BlockType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/DuckType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/FusionType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/MethodListType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/MethodType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/NilType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/NominalType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/OptionalType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/OrType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/SelfType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/Type.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeDefs/VarLengthType.html +0 -2
- data/webpage/rdoc/RubyBreaker/TypeUnparser.html +0 -2
- data/webpage/rdoc/RubyBreaker/Typing.html +0 -2
- data/webpage/rdoc/RubyBreaker/Util.html +80 -4
- data/webpage/rdoc/Test.html +0 -2
- data/webpage/rdoc/Test/Unit.html +0 -2
- data/webpage/rdoc/created.rid +12 -12
- data/webpage/rdoc/index.html +0 -2
- data/webpage/rdoc/js/search_index.js +1 -1
- data/webpage/rdoc/table_of_contents.html +53 -34
- data/webpage/tutorial.html +36 -7
- metadata +8 -11
- data/webpage/rdoc/RubyBreaker/Runtime/MonitorUtils.html +0 -402
data/webpage/tutorial.html
CHANGED
@@ -40,7 +40,7 @@ to use RubyBreaker in a Rakefile later.</p>
|
|
40
40
|
|
41
41
|
<p>The above command runs RubyBreaker in verbose mode (<code>-v</code>) and will display
|
42
42
|
the output on the screen (<code>-s</code>). Before RubyBreaker runs <code>prog.rb</code>, it will
|
43
|
-
import (<code>-l</code>) <code>lib.rb</code> and
|
43
|
+
import (<code>-l</code>) <code>lib.rb</code> and <em>break</em> (<code>-b</code>) classes <code>A</code> and <code>B</code>.
|
44
44
|
Here is <code>lib.rb</code>:</p>
|
45
45
|
|
46
46
|
<pre><code>class A
|
@@ -95,7 +95,7 @@ obtain precise and accurate type information.</p>
|
|
95
95
|
<h3>Using Ruby Unit Testing Framework</h3>
|
96
96
|
|
97
97
|
<p>Instead of manually inserting the entry point indicator in the source
|
98
|
-
program, you can take advantage of Ruby
|
98
|
+
program, you can take advantage of Ruby’s built-in testing framework. This
|
99
99
|
is preferred to modifying the source program directly, especially for the
|
100
100
|
long term program maintainability. But no worries! This method is as simple
|
101
101
|
as the previous one.</p>
|
@@ -111,7 +111,7 @@ class TestClassA < Test::Unit::TestCase
|
|
111
111
|
end
|
112
112
|
</code></pre>
|
113
113
|
|
114
|
-
<p>That
|
114
|
+
<p>That’s it! The only requirements are to indicate to RubyBreaker which modules
|
115
115
|
and classes to "break" and to place <code>require rubybreaker</code> <em>after</em>
|
116
116
|
<code>require test/unit</code>.</p>
|
117
117
|
|
@@ -152,7 +152,7 @@ end
|
|
152
152
|
<p>Note that <code>RubyBrakerTestTask</code> can simply replace your <code>TestTask</code> block in
|
153
153
|
Rakefile. In fact, the former is a subclass of the latter and includes all
|
154
154
|
features supported by the latter. The only additional options are
|
155
|
-
<code>rubybreaker_opts</code> which is RubyBreaker
|
155
|
+
<code>rubybreaker_opts</code> which is RubyBreaker command-line options and
|
156
156
|
<code>break</code> which specifies which modules and classes to monitor. Since
|
157
157
|
<code>Class1</code> and <code>Class2</code> are not <em>recognized</em> by this Rakefile, you must use
|
158
158
|
string literals to specify modules and classes (and with full namespace).</p>
|
@@ -213,7 +213,7 @@ precise return type.</p>
|
|
213
213
|
|
214
214
|
<h3>Duck Type</h3>
|
215
215
|
|
216
|
-
<p>This type is inspired by the Ruby Language
|
216
|
+
<p>This type is inspired by the Ruby Language’s duck typing, <em>"if it
|
217
217
|
walks like a duck and quacks like a duck, it must be a duck."</em> Using this
|
218
218
|
type, an object can be represented simply by a list of method names. For
|
219
219
|
example <code>[walks, quacks]</code> is an object that has <code>walks</code> and <code>quacks</code>
|
@@ -260,7 +260,7 @@ suffices, <code>?</code> and <code>*</code>, respectively.</p>
|
|
260
260
|
|
261
261
|
<h3>Block Type</h3>
|
262
262
|
|
263
|
-
<p>One of the Ruby
|
263
|
+
<p>One of the Ruby’s prominent features is the block argument. It allows
|
264
264
|
the caller to pass in a piece of code to be executed inside the callee. This
|
265
265
|
code block can be executed by the Ruby construct, <code>yield</code>, or by directly
|
266
266
|
calling the <code>call</code> method of the block object. In RubyBreaker, this type can
|
@@ -293,7 +293,7 @@ end
|
|
293
293
|
</code></pre>
|
294
294
|
|
295
295
|
<p>There is no way to document the type of <code>foo</code> without using a method list
|
296
|
-
type. Let
|
296
|
+
type. Let’s try to give a method type to <code>foo</code> without a method list. The
|
297
297
|
closest we can come up with would be <code>foo(fixnum or string) -> fixnum and
|
298
298
|
string</code>. But RubyBreaker does not have the "and" type in the type annotation
|
299
299
|
language because it gives me an headache! (By the way, it needs to be an
|
@@ -319,6 +319,35 @@ automatically documenting such a type, RubyBreaker looks for the (subtyping)
|
|
319
319
|
compatibility between the return types and "promote" the method type to a
|
320
320
|
method list type by spliting the type signature into two (or more in
|
321
321
|
subsequent "promotions").</p>
|
322
|
+
|
323
|
+
<h3>Early Dynamic Type Checking</h3>
|
324
|
+
|
325
|
+
<p>RubyBreaker gives you an option to run the early dynamic type check. If a
|
326
|
+
method is documented and its module is specified to be <em>type checked</em>, then
|
327
|
+
RubyBreaker will verify if the argument types and the return type are
|
328
|
+
appropriate at runtime. To allow this feature in command-line, use <code>-c</code>
|
329
|
+
(checking) option:</p>
|
330
|
+
|
331
|
+
<pre><code>rubybreaker -l lib.rb -c A prog.rb
|
332
|
+
</code></pre>
|
333
|
+
|
334
|
+
<p>Or use it in Rakefile:</p>
|
335
|
+
|
336
|
+
<pre><code>require "rubybreaker/task"
|
337
|
+
...
|
338
|
+
desc "Run RubyBreaker"
|
339
|
+
Rake::RubyBreakerTestTask.new(:"rubybreaker") do |t|
|
340
|
+
t.libs << "lib"
|
341
|
+
t.test_files = ["test/foo/tc_foo1.rb"]
|
342
|
+
# ...Other test task options..
|
343
|
+
t.rubybreaker_opts << "-v" # run in verbose mode
|
344
|
+
t.break = ["Class1", "Class2", ...] # specify classes to monitor
|
345
|
+
t.check = ["Class3", ....] # specify classes to check
|
346
|
+
end
|
347
|
+
</code></pre>
|
348
|
+
|
349
|
+
<p>Alternatively, you can use <code>RubyBreaker.check()</code> to specify classes to type
|
350
|
+
check in the setup code of the test case.</p>
|
322
351
|
<hr />
|
323
352
|
<center style="font-size:smaller; padding:0px;">
|
324
353
|
Copyright (C) 2012 Jong-hoon (David) An. All Rights Reserved.<br />
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubybreaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: treetop
|
@@ -27,11 +27,11 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
-
description: RubyBreaker is a dynamic type documentation tool for Ruby. It
|
31
|
-
instruments code, monitors objects during execution,
|
32
|
-
based on the profiled information.
|
33
|
-
|
34
|
-
auto-documenting type information.
|
30
|
+
description: RubyBreaker is a dynamic type documentation/checking tool for Ruby. It
|
31
|
+
dynamically instruments code, monitors objects during execution, performs dynamic
|
32
|
+
type checking, and generates type documentation based on the profiled information.
|
33
|
+
In other words, RubyBreaker "breaks" Ruby code out of its obscurity and wildness
|
34
|
+
(as in "code breaking" or "horse breaking") by auto-documenting type information.
|
35
35
|
email: rubybreaker@gmail.com
|
36
36
|
executables:
|
37
37
|
- rubybreaker
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- TUTORIAL.md
|
82
82
|
- VERSION
|
83
83
|
- test/integrated/tc_both_documented_and_undocumented.rb
|
84
|
+
- test/integrated/tc_checking.rb
|
84
85
|
- test/integrated/tc_class_methods.rb
|
85
86
|
- test/integrated/tc_inherit_broken.rb
|
86
87
|
- test/integrated/tc_method_missing.rb
|
@@ -164,7 +165,6 @@ files:
|
|
164
165
|
- webpage/rdoc/RubyBreaker/Runtime/Monitor.html
|
165
166
|
- webpage/rdoc/RubyBreaker/Runtime/MonitorInstaller.html
|
166
167
|
- webpage/rdoc/RubyBreaker/Runtime/MonitorSwitch.html
|
167
|
-
- webpage/rdoc/RubyBreaker/Runtime/MonitorUtils.html
|
168
168
|
- webpage/rdoc/RubyBreaker/Runtime/ObjectWrapper.html
|
169
169
|
- webpage/rdoc/RubyBreaker/Runtime/Pluggable.html
|
170
170
|
- webpage/rdoc/RubyBreaker/Runtime/TypeSigParser.html
|
@@ -202,9 +202,6 @@ licenses:
|
|
202
202
|
post_install_message:
|
203
203
|
rdoc_options:
|
204
204
|
- README.md
|
205
|
-
- TUTORIAL.md
|
206
|
-
- TOPICS.md
|
207
|
-
- ABOUT.md
|
208
205
|
require_paths:
|
209
206
|
- lib
|
210
207
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -1,402 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
-
|
7
|
-
<title>module RubyBreaker::Runtime::MonitorUtils - RDoc Documentation</title>
|
8
|
-
|
9
|
-
<link type="text/css" media="screen" href="../../rdoc.css" rel="stylesheet">
|
10
|
-
|
11
|
-
<script type="text/javascript">
|
12
|
-
var rdoc_rel_prefix = "../../";
|
13
|
-
</script>
|
14
|
-
|
15
|
-
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
16
|
-
<script type="text/javascript" charset="utf-8" src="../../js/navigation.js"></script>
|
17
|
-
<script type="text/javascript" charset="utf-8" src="../../js/search_index.js"></script>
|
18
|
-
<script type="text/javascript" charset="utf-8" src="../../js/search.js"></script>
|
19
|
-
<script type="text/javascript" charset="utf-8" src="../../js/searcher.js"></script>
|
20
|
-
<script type="text/javascript" charset="utf-8" src="../../js/darkfish.js"></script>
|
21
|
-
|
22
|
-
|
23
|
-
<body id="top" class="module">
|
24
|
-
<nav id="metadata">
|
25
|
-
<nav id="home-section" class="section">
|
26
|
-
<h3 class="section-header">
|
27
|
-
<a href="../../index.html">Home</a>
|
28
|
-
<a href="../../table_of_contents.html#classes">Classes</a>
|
29
|
-
<a href="../../table_of_contents.html#methods">Methods</a>
|
30
|
-
</h3>
|
31
|
-
</nav>
|
32
|
-
|
33
|
-
|
34
|
-
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
-
<form action="#" method="get" accept-charset="utf-8">
|
36
|
-
<h3 class="section-header">
|
37
|
-
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
-
</h3>
|
40
|
-
</form>
|
41
|
-
|
42
|
-
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
-
</nav>
|
44
|
-
|
45
|
-
|
46
|
-
<div id="file-metadata">
|
47
|
-
<nav id="file-list-section" class="section">
|
48
|
-
<h3 class="section-header">Defined In</h3>
|
49
|
-
<ul>
|
50
|
-
<li>lib/rubybreaker/runtime/monitor.rb
|
51
|
-
</ul>
|
52
|
-
</nav>
|
53
|
-
|
54
|
-
|
55
|
-
</div>
|
56
|
-
|
57
|
-
<div id="class-metadata">
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
<!-- Method Quickref -->
|
62
|
-
<nav id="method-list-section" class="section">
|
63
|
-
<h3 class="section-header">Methods</h3>
|
64
|
-
|
65
|
-
<ul class="link-list">
|
66
|
-
|
67
|
-
<li><a href="#method-c-get_alt_meth_name">::get_alt_meth_name</a>
|
68
|
-
|
69
|
-
<li><a href="#method-c-get_orig_meth_name">::get_orig_meth_name</a>
|
70
|
-
|
71
|
-
<li><a href="#method-c-route">::route</a>
|
72
|
-
|
73
|
-
</ul>
|
74
|
-
</nav>
|
75
|
-
|
76
|
-
</div>
|
77
|
-
|
78
|
-
<div id="project-metadata">
|
79
|
-
|
80
|
-
<nav id="classindex-section" class="section project-section">
|
81
|
-
<h3 class="section-header">Class and Module Index</h3>
|
82
|
-
|
83
|
-
<ul class="link-list">
|
84
|
-
|
85
|
-
<li><a href="../../RubyBreaker.html">RubyBreaker</a>
|
86
|
-
|
87
|
-
<li><a href="../../RubyBreaker/Breakable.html">RubyBreaker::Breakable</a>
|
88
|
-
|
89
|
-
<li><a href="../../RubyBreaker/Broken.html">RubyBreaker::Broken</a>
|
90
|
-
|
91
|
-
<li><a href="../../RubyBreaker/Context.html">RubyBreaker::Context</a>
|
92
|
-
|
93
|
-
<li><a href="../../RubyBreaker/Errors.html">RubyBreaker::Errors</a>
|
94
|
-
|
95
|
-
<li><a href="../../RubyBreaker/Errors/InternalError.html">RubyBreaker::Errors::InternalError</a>
|
96
|
-
|
97
|
-
<li><a href="../../RubyBreaker/Errors/InvalidSubtypeCheck.html">RubyBreaker::Errors::InvalidSubtypeCheck</a>
|
98
|
-
|
99
|
-
<li><a href="../../RubyBreaker/Errors/InvalidTypeConstruction.html">RubyBreaker::Errors::InvalidTypeConstruction</a>
|
100
|
-
|
101
|
-
<li><a href="../../RubyBreaker/Errors/SubtypeFailure.html">RubyBreaker::Errors::SubtypeFailure</a>
|
102
|
-
|
103
|
-
<li><a href="../../RubyBreaker/Errors/TypeError.html">RubyBreaker::Errors::TypeError</a>
|
104
|
-
|
105
|
-
<li><a href="../../RubyBreaker/Errors/UserError.html">RubyBreaker::Errors::UserError</a>
|
106
|
-
|
107
|
-
<li><a href="../../RubyBreaker/ObjectPosition.html">RubyBreaker::ObjectPosition</a>
|
108
|
-
|
109
|
-
<li><a href="../../RubyBreaker/Position.html">RubyBreaker::Position</a>
|
110
|
-
|
111
|
-
<li><a href="../../RubyBreaker/RDocSupport.html">RubyBreaker::RDocSupport</a>
|
112
|
-
|
113
|
-
<li><a href="../../RubyBreaker/RubyTypeUtils.html">RubyBreaker::RubyTypeUtils</a>
|
114
|
-
|
115
|
-
<li><a href="../../RubyBreaker/Runtime.html">RubyBreaker::Runtime</a>
|
116
|
-
|
117
|
-
<li><a href="../../RubyBreaker/Runtime/Inspector.html">RubyBreaker::Runtime::Inspector</a>
|
118
|
-
|
119
|
-
<li><a href="../../RubyBreaker/Runtime/MethodInfo.html">RubyBreaker::Runtime::MethodInfo</a>
|
120
|
-
|
121
|
-
<li><a href="../../RubyBreaker/Runtime/Monitor.html">RubyBreaker::Runtime::Monitor</a>
|
122
|
-
|
123
|
-
<li><a href="../../RubyBreaker/Runtime/MonitorInstaller.html">RubyBreaker::Runtime::MonitorInstaller</a>
|
124
|
-
|
125
|
-
<li><a href="../../RubyBreaker/Runtime/MonitorSwitch.html">RubyBreaker::Runtime::MonitorSwitch</a>
|
126
|
-
|
127
|
-
<li><a href="../../RubyBreaker/Runtime/MonitorUtils.html">RubyBreaker::Runtime::MonitorUtils</a>
|
128
|
-
|
129
|
-
<li><a href="../../RubyBreaker/Runtime/ObjectWrapper.html">RubyBreaker::Runtime::ObjectWrapper</a>
|
130
|
-
|
131
|
-
<li><a href="../../RubyBreaker/Runtime/Pluggable.html">RubyBreaker::Runtime::Pluggable</a>
|
132
|
-
|
133
|
-
<li><a href="../../RubyBreaker/Runtime/TypeSigParser.html">RubyBreaker::Runtime::TypeSigParser</a>
|
134
|
-
|
135
|
-
<li><a href="../../RubyBreaker/Runtime/TypeSigUnparser.html">RubyBreaker::Runtime::TypeSigUnparser</a>
|
136
|
-
|
137
|
-
<li><a href="../../RubyBreaker/Runtime/TypeSystem.html">RubyBreaker::Runtime::TypeSystem</a>
|
138
|
-
|
139
|
-
<li><a href="../../RubyBreaker/TypeComparer.html">RubyBreaker::TypeComparer</a>
|
140
|
-
|
141
|
-
<li><a href="../../RubyBreaker/TypeDefs.html">RubyBreaker::TypeDefs</a>
|
142
|
-
|
143
|
-
<li><a href="../../RubyBreaker/TypeDefs/AnyType.html">RubyBreaker::TypeDefs::AnyType</a>
|
144
|
-
|
145
|
-
<li><a href="../../RubyBreaker/TypeDefs/BlockType.html">RubyBreaker::TypeDefs::BlockType</a>
|
146
|
-
|
147
|
-
<li><a href="../../RubyBreaker/TypeDefs/DuckType.html">RubyBreaker::TypeDefs::DuckType</a>
|
148
|
-
|
149
|
-
<li><a href="../../RubyBreaker/TypeDefs/FusionType.html">RubyBreaker::TypeDefs::FusionType</a>
|
150
|
-
|
151
|
-
<li><a href="../../RubyBreaker/TypeDefs/MethodListType.html">RubyBreaker::TypeDefs::MethodListType</a>
|
152
|
-
|
153
|
-
<li><a href="../../RubyBreaker/TypeDefs/MethodType.html">RubyBreaker::TypeDefs::MethodType</a>
|
154
|
-
|
155
|
-
<li><a href="../../RubyBreaker/TypeDefs/NilType.html">RubyBreaker::TypeDefs::NilType</a>
|
156
|
-
|
157
|
-
<li><a href="../../RubyBreaker/TypeDefs/NominalType.html">RubyBreaker::TypeDefs::NominalType</a>
|
158
|
-
|
159
|
-
<li><a href="../../RubyBreaker/TypeDefs/OptionalType.html">RubyBreaker::TypeDefs::OptionalType</a>
|
160
|
-
|
161
|
-
<li><a href="../../RubyBreaker/TypeDefs/OrType.html">RubyBreaker::TypeDefs::OrType</a>
|
162
|
-
|
163
|
-
<li><a href="../../RubyBreaker/TypeDefs/SelfType.html">RubyBreaker::TypeDefs::SelfType</a>
|
164
|
-
|
165
|
-
<li><a href="../../RubyBreaker/TypeDefs/Type.html">RubyBreaker::TypeDefs::Type</a>
|
166
|
-
|
167
|
-
<li><a href="../../RubyBreaker/TypeDefs/VarLengthType.html">RubyBreaker::TypeDefs::VarLengthType</a>
|
168
|
-
|
169
|
-
<li><a href="../../RubyBreaker/TypeUnparser.html">RubyBreaker::TypeUnparser</a>
|
170
|
-
|
171
|
-
<li><a href="../../RubyBreaker/Typing.html">RubyBreaker::Typing</a>
|
172
|
-
|
173
|
-
<li><a href="../../RubyBreaker/Util.html">RubyBreaker::Util</a>
|
174
|
-
|
175
|
-
<li><a href="../../Rake.html">Rake</a>
|
176
|
-
|
177
|
-
<li><a href="../../Rake/RubyBreakerTestTask.html">Rake::RubyBreakerTestTask</a>
|
178
|
-
|
179
|
-
<li><a href="../../Test.html">Test</a>
|
180
|
-
|
181
|
-
<li><a href="../../Test/Unit.html">Test::Unit</a>
|
182
|
-
|
183
|
-
<li><a href="../../Object.html">Object</a>
|
184
|
-
|
185
|
-
</ul>
|
186
|
-
</nav>
|
187
|
-
|
188
|
-
</div>
|
189
|
-
</nav>
|
190
|
-
|
191
|
-
<div id="documentation">
|
192
|
-
<h1 class="module">module RubyBreaker::Runtime::MonitorUtils</h1>
|
193
|
-
|
194
|
-
<div id="description" class="description">
|
195
|
-
|
196
|
-
<p>This module contains helper methods for monitoring objects and modules.</p>
|
197
|
-
|
198
|
-
</div><!-- description -->
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
<!-- Methods -->
|
213
|
-
|
214
|
-
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
215
|
-
<h3 class="section-header">Public Class Methods</h3>
|
216
|
-
|
217
|
-
|
218
|
-
<div id="method-c-get_alt_meth_name" class="method-detail ">
|
219
|
-
|
220
|
-
<div class="method-heading">
|
221
|
-
<span class="method-name">get_alt_meth_name</span><span
|
222
|
-
class="method-args">(meth_name)</span>
|
223
|
-
<span class="method-click-advice">click to toggle source</span>
|
224
|
-
</div>
|
225
|
-
|
226
|
-
|
227
|
-
<div class="method-description">
|
228
|
-
|
229
|
-
<p>This method returns the alternative (renamed) method name</p>
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
<div class="method-source-code" id="get_alt_meth_name-source">
|
234
|
-
<pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 171</span>
|
235
|
-
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">get_alt_meth_name</span>(<span class="ruby-identifier">meth_name</span>)
|
236
|
-
<span class="ruby-keyword">return</span> <span class="ruby-node">"__#{meth_name}"</span>
|
237
|
-
<span class="ruby-keyword">end</span></pre>
|
238
|
-
</div><!-- get_alt_meth_name-source -->
|
239
|
-
|
240
|
-
</div>
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
</div><!-- get_alt_meth_name-method -->
|
246
|
-
|
247
|
-
|
248
|
-
<div id="method-c-get_orig_meth_name" class="method-detail ">
|
249
|
-
|
250
|
-
<div class="method-heading">
|
251
|
-
<span class="method-name">get_orig_meth_name</span><span
|
252
|
-
class="method-args">(meth_name)</span>
|
253
|
-
<span class="method-click-advice">click to toggle source</span>
|
254
|
-
</div>
|
255
|
-
|
256
|
-
|
257
|
-
<div class="method-description">
|
258
|
-
|
259
|
-
<p>This method returns the original method name</p>
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
<div class="method-source-code" id="get_orig_meth_name-source">
|
264
|
-
<pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 176</span>
|
265
|
-
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">get_orig_meth_name</span>(<span class="ruby-identifier">meth_name</span>)
|
266
|
-
<span class="ruby-keyword">return</span> <span class="ruby-identifier">meth_name</span>[<span class="ruby-value">2</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
|
267
|
-
<span class="ruby-keyword">end</span></pre>
|
268
|
-
</div><!-- get_orig_meth_name-source -->
|
269
|
-
|
270
|
-
</div>
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
</div><!-- get_orig_meth_name-method -->
|
276
|
-
|
277
|
-
|
278
|
-
<div id="method-c-route" class="method-detail ">
|
279
|
-
|
280
|
-
<div class="method-heading">
|
281
|
-
<span class="method-name">route</span><span
|
282
|
-
class="method-args">(obj,meth_name,*args,&blk)</span>
|
283
|
-
<span class="method-click-advice">click to toggle source</span>
|
284
|
-
</div>
|
285
|
-
|
286
|
-
|
287
|
-
<div class="method-description">
|
288
|
-
|
289
|
-
<p>This will do the actual routing work for a particular “monitored” method
|
290
|
-
call.</p>
|
291
|
-
<dl class="rdoc-list note-list"><dt>obj
|
292
|
-
<dd>
|
293
|
-
<p>is the object receiving the message; is never wrapped object</p>
|
294
|
-
</dd><dt>meth_name
|
295
|
-
<dd><dl class="rdoc-list note-list"><dt>is the original method name being called args
|
296
|
-
<dd>
|
297
|
-
<p>is a</p>
|
298
|
-
</dd></dl>
|
299
|
-
</dd><dt>list of arguments for the original method call blk
|
300
|
-
<dd>
|
301
|
-
<p>is the block</p>
|
302
|
-
</dd></dl>
|
303
|
-
|
304
|
-
<p>argument for the original method call</p>
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
<div class="method-source-code" id="route-source">
|
309
|
-
<pre><span class="ruby-comment"># File lib/rubybreaker/runtime/monitor.rb, line 99</span>
|
310
|
-
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">route</span>(<span class="ruby-identifier">obj</span>,<span class="ruby-identifier">meth_name</span>,*<span class="ruby-identifier">args</span>,&<span class="ruby-identifier">blk</span>)
|
311
|
-
|
312
|
-
<span class="ruby-comment"># remember the switch mode before turning it off</span>
|
313
|
-
<span class="ruby-identifier">switch</span> = <span class="ruby-constant">GLOBAL_MONITOR_SWITCH</span>.<span class="ruby-identifier">switch</span>
|
314
|
-
|
315
|
-
<span class="ruby-comment"># turn off the monitor so we do not fall into an infinite loop</span>
|
316
|
-
<span class="ruby-constant">GLOBAL_MONITOR_SWITCH</span>.<span class="ruby-identifier">turn_off</span>()
|
317
|
-
|
318
|
-
<span class="ruby-comment"># use symbol instead of string throughout this code</span>
|
319
|
-
<span class="ruby-identifier">meth_name</span> = <span class="ruby-value">:"#{meth_name}"</span>
|
320
|
-
|
321
|
-
<span class="ruby-comment"># first, get the context right</span>
|
322
|
-
<span class="ruby-comment"># notice the argument 2 to the caller!</span>
|
323
|
-
<span class="ruby-comment">#</span>
|
324
|
-
<span class="ruby-comment"># CONTEXT.push(obj, meth_name, </span>
|
325
|
-
<span class="ruby-comment"># Position.convert_caller_to_pos(caller(2)))</span>
|
326
|
-
<span class="ruby-constant">CONTEXT</span>.<span class="ruby-identifier">push</span>(<span class="ruby-constant">Position</span>.<span class="ruby-identifier">convert_caller_to_pos</span>(<span class="ruby-identifier">caller</span>(<span class="ruby-value">2</span>)))
|
327
|
-
|
328
|
-
<span class="ruby-comment"># this is what the renamed method</span>
|
329
|
-
<span class="ruby-identifier">stub_meth_name</span> = <span class="ruby-identifier">get_alt_meth_name</span>(<span class="ruby-identifier">meth_name</span>)
|
330
|
-
|
331
|
-
<span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-node">"Route to #{stub_meth_name}"</span>, <span class="ruby-value">:debug</span>, <span class="ruby-constant">CONTEXT</span>)
|
332
|
-
|
333
|
-
<span class="ruby-comment"># short-circuit if switch was off--i.e., no monitoring</span>
|
334
|
-
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">switch</span>
|
335
|
-
<span class="ruby-identifier">retval</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">stub_meth_name</span>.<span class="ruby-identifier">to_sym</span>,*<span class="ruby-identifier">args</span>,&<span class="ruby-identifier">blk</span>)
|
336
|
-
<span class="ruby-constant">CONTEXT</span>.<span class="ruby-identifier">pop</span>() <span class="ruby-comment"># do not forget to pop the context before returning</span>
|
337
|
-
<span class="ruby-keyword">return</span> <span class="ruby-identifier">retval</span>
|
338
|
-
<span class="ruby-keyword">end</span>
|
339
|
-
|
340
|
-
<span class="ruby-identifier">is_obj_mod</span> = (<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Module</span>)
|
341
|
-
<span class="ruby-identifier">mod</span> = <span class="ruby-identifier">is_obj_mod</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Runtime</span>.<span class="ruby-identifier">eigen_class</span>(<span class="ruby-identifier">obj</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>
|
342
|
-
|
343
|
-
<span class="ruby-comment"># mm = get_module_monitor(mod) unless is_obj_mod</span>
|
344
|
-
<span class="ruby-identifier">mm</span> = <span class="ruby-constant">MONITOR_MAP</span>[<span class="ruby-identifier">mod</span>]
|
345
|
-
|
346
|
-
<span class="ruby-comment"># There is something wrong if there isn't a module monitor</span>
|
347
|
-
<span class="ruby-comment"># associated with the call.</span>
|
348
|
-
<span class="ruby-comment"># raise Exception if mm == nil || !mm.include?(meth_name)</span>
|
349
|
-
|
350
|
-
<span class="ruby-identifier">meth_info</span> = <span class="ruby-constant">MethodInfo</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">meth_name</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">blk</span>, <span class="ruby-keyword">nil</span>)
|
351
|
-
|
352
|
-
<span class="ruby-identifier">mm</span>.<span class="ruby-identifier">monitor_before_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
|
353
|
-
|
354
|
-
<span class="ruby-constant">RubyBreaker</span>.<span class="ruby-identifier">log</span>(<span class="ruby-string">"monitor_before_method ended"</span>)
|
355
|
-
|
356
|
-
<span class="ruby-comment"># we are going to turn the switch back on</span>
|
357
|
-
<span class="ruby-constant">GLOBAL_MONITOR_SWITCH</span>.<span class="ruby-identifier">turn_on</span>()
|
358
|
-
|
359
|
-
<span class="ruby-comment"># call the original method which was renamed</span>
|
360
|
-
<span class="ruby-identifier">retval</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">stub_meth_name</span>.<span class="ruby-identifier">to_sym</span>, *<span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">args</span>,
|
361
|
-
&<span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">blk</span>)
|
362
|
-
|
363
|
-
<span class="ruby-comment"># turn it off</span>
|
364
|
-
<span class="ruby-constant">GLOBAL_MONITOR_SWITCH</span>.<span class="ruby-identifier">turn_off</span>()
|
365
|
-
|
366
|
-
<span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">ret</span> = <span class="ruby-identifier">retval</span>
|
367
|
-
<span class="ruby-identifier">mm</span>.<span class="ruby-identifier">monitor_after_method</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">meth_info</span>)
|
368
|
-
<span class="ruby-identifier">retval</span> = <span class="ruby-identifier">meth_info</span>.<span class="ruby-identifier">ret</span> <span class="ruby-comment"># Return value may have been altered by the</span>
|
369
|
-
<span class="ruby-comment"># after_method monitoring code</span>
|
370
|
-
|
371
|
-
<span class="ruby-comment"># things are done in this context. pop it off.</span>
|
372
|
-
<span class="ruby-constant">CONTEXT</span>.<span class="ruby-identifier">pop</span>()
|
373
|
-
|
374
|
-
<span class="ruby-comment"># it is always the case that the switch was off when this particular</span>
|
375
|
-
<span class="ruby-comment"># call was made. (Otherwise, it would have quit somewhere above</span>
|
376
|
-
<span class="ruby-constant">GLOBAL_MONITOR_SWITCH</span>.<span class="ruby-identifier">turn_on</span>()
|
377
|
-
|
378
|
-
<span class="ruby-keyword">return</span> <span class="ruby-identifier">retval</span> <span class="ruby-comment"># always return the return value</span>
|
379
|
-
<span class="ruby-keyword">end</span></pre>
|
380
|
-
</div><!-- route-source -->
|
381
|
-
|
382
|
-
</div>
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
</div><!-- route-method -->
|
388
|
-
|
389
|
-
|
390
|
-
</section><!-- public-class-method-details -->
|
391
|
-
|
392
|
-
</section><!-- 5Buntitled-5D -->
|
393
|
-
|
394
|
-
</div><!-- documentation -->
|
395
|
-
|
396
|
-
|
397
|
-
<footer id="validator-badges">
|
398
|
-
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
399
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
400
|
-
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
401
|
-
</footer>
|
402
|
-
|