autocode 0.9.3 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/autocode.rb +92 -3
- data/test/auto_create.rb +28 -0
- data/test/auto_eval.rb +31 -0
- data/test/auto_load.rb +51 -0
- data/test/helpers.rb +15 -0
- metadata +51 -71
- data/doc/rdoc/classes/Autocreate.html +0 -158
- data/doc/rdoc/classes/Autocreate.src/M000004.html +0 -19
- data/doc/rdoc/classes/Autoload.html +0 -206
- data/doc/rdoc/classes/Autoload.src/M000001.html +0 -19
- data/doc/rdoc/classes/Autoload.src/M000002.html +0 -19
- data/doc/rdoc/classes/Autoload.src/M000003.html +0 -25
- data/doc/rdoc/classes/Reloadable.html +0 -173
- data/doc/rdoc/classes/Reloadable.src/M000005.html +0 -19
- data/doc/rdoc/classes/Reloadable.src/M000006.html +0 -19
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/HISTORY.html +0 -130
- data/doc/rdoc/files/README.html +0 -200
- data/doc/rdoc/files/lib/autocode_rb.html +0 -110
- data/doc/rdoc/files/lib/autocreate_rb.html +0 -109
- data/doc/rdoc/files/lib/autoload_rb.html +0 -109
- data/doc/rdoc/files/lib/reloadable_rb.html +0 -109
- data/doc/rdoc/fr_class_index.html +0 -29
- data/doc/rdoc/fr_file_index.html +0 -32
- data/doc/rdoc/fr_method_index.html +0 -32
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/lib/autocreate.rb +0 -54
- data/lib/autoload.rb +0 -69
- data/lib/reloadable.rb +0 -30
@@ -1,19 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>reloadable (Reloadable)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/reloadable.rb, line 15</span>
|
14
|
-
15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reloadable</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">names</span> )
|
15
|
-
16: ( <span class="ruby-ivar">@reloadable</span> <span class="ruby-operator">||=</span> [] ).<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">names</span>)
|
16
|
-
17: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>
|
17
|
-
18: <span class="ruby-keyword kw">end</span></pre>
|
18
|
-
</body>
|
19
|
-
</html>
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>reload (Reloadable)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/reloadable.rb, line 21</span>
|
14
|
-
21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload</span>
|
15
|
-
22: ( <span class="ruby-ivar">@reloadable</span> <span class="ruby-operator">||=</span>[] ).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">remove_const</span>( <span class="ruby-identifier">name</span> ) }
|
16
|
-
23: <span class="ruby-ivar">@reloadable</span> = []; <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>
|
17
|
-
24: <span class="ruby-keyword kw">end</span></pre>
|
18
|
-
</body>
|
19
|
-
</html>
|
data/doc/rdoc/created.rid
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Sat, 26 Jan 2008 15:52:15 -0800
|
data/doc/rdoc/files/HISTORY.html
DELETED
@@ -1,130 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: HISTORY</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>HISTORY</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>HISTORY
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Sat Jan 26 14:50:31 -0800 2008</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
<div id="description">
|
72
|
-
<p>
|
73
|
-
0.9.2:
|
74
|
-
</p>
|
75
|
-
<ul>
|
76
|
-
<li>Fixed autoload to look for a file in all lowercase (foobar.rb instead of
|
77
|
-
Foobar.rb).
|
78
|
-
|
79
|
-
</li>
|
80
|
-
</ul>
|
81
|
-
<p>
|
82
|
-
0.9.1:
|
83
|
-
</p>
|
84
|
-
<ul>
|
85
|
-
<li>Moved initialization of object after calling const_set so that self.name
|
86
|
-
has a value.
|
87
|
-
|
88
|
-
</li>
|
89
|
-
</ul>
|
90
|
-
<p>
|
91
|
-
0.9.0:
|
92
|
-
</p>
|
93
|
-
<ul>
|
94
|
-
<li>Initial release as gem.
|
95
|
-
|
96
|
-
</li>
|
97
|
-
</ul>
|
98
|
-
|
99
|
-
</div>
|
100
|
-
|
101
|
-
|
102
|
-
</div>
|
103
|
-
|
104
|
-
|
105
|
-
</div>
|
106
|
-
|
107
|
-
|
108
|
-
<!-- if includes -->
|
109
|
-
|
110
|
-
<div id="section">
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
<!-- if method_list -->
|
120
|
-
|
121
|
-
|
122
|
-
</div>
|
123
|
-
|
124
|
-
|
125
|
-
<div id="validator-badges">
|
126
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
127
|
-
</div>
|
128
|
-
|
129
|
-
</body>
|
130
|
-
</html>
|
data/doc/rdoc/files/README.html
DELETED
@@ -1,200 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: README</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>README</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>README
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Sat Jan 05 21:04:30 -0800 2008</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
<div id="description">
|
72
|
-
<h1>Introducing Autocode</h1>
|
73
|
-
<p>
|
74
|
-
Autocode makes it relatively easy to automatically (re)load or even
|
75
|
-
generate classes and modules on the fly. You can use it like this:
|
76
|
-
</p>
|
77
|
-
<pre>
|
78
|
-
require 'autocode'
|
79
|
-
|
80
|
-
module Application
|
81
|
-
extend Autoload
|
82
|
-
autoload true
|
83
|
-
directories :configurations, :models, :views, :controllers
|
84
|
-
end
|
85
|
-
</pre>
|
86
|
-
<p>
|
87
|
-
This will attempt to load code dynamically from the given directories,
|
88
|
-
using the module name to determine which directory to look in. Thus,
|
89
|
-
<tt>Application::CustomerModel</tt> could load the file
|
90
|
-
<tt>models/customer_model.rb</tt>.
|
91
|
-
</p>
|
92
|
-
<h2>Reloading Code</h2>
|
93
|
-
<p>
|
94
|
-
To make code reloadable (very useful when debugging running processes),
|
95
|
-
simply extend <a href="../classes/Reloadable.html">Reloadable</a>. Thus,
|
96
|
-
our above example would become:
|
97
|
-
</p>
|
98
|
-
<pre>
|
99
|
-
require 'autocode'
|
100
|
-
|
101
|
-
module Application
|
102
|
-
extend Autoload; extend Reloadable
|
103
|
-
autoload true
|
104
|
-
directories :configurations, :models, :views, :controllers
|
105
|
-
end
|
106
|
-
</pre>
|
107
|
-
<p>
|
108
|
-
Then, later on, we can simply call <tt>Application.reload</tt> to reload
|
109
|
-
all the code that was loaded via <b>Autocode</b>. <b>Important</b>: Only
|
110
|
-
code loaded via <b>Autocode</b> (<a
|
111
|
-
href="../classes/Autoload.html">Autoload</a> or <a
|
112
|
-
href="../classes/Autocreate.html">Autocreate</a>) will be reloaded.
|
113
|
-
</p>
|
114
|
-
<h2>Autocreation</h2>
|
115
|
-
<p>
|
116
|
-
Sometimes it‘s useful to generate defaults for classes or modules
|
117
|
-
that don‘t exist. This can be particularly powerful when used in
|
118
|
-
combination with autoloading.
|
119
|
-
</p>
|
120
|
-
<pre>
|
121
|
-
require 'autocode'
|
122
|
-
|
123
|
-
module Application
|
124
|
-
extend Autocreate; extend Reloadable
|
125
|
-
[ [ :Configurations, :configurations ],
|
126
|
-
[ :Models, :models ],
|
127
|
-
[ :Views, :views ],
|
128
|
-
[ :Controllers, :controllers ] ].each |mod_name, dir_name| do
|
129
|
-
autocreate mod_name, Module.new do
|
130
|
-
extend Autoload
|
131
|
-
autoload true
|
132
|
-
directories dir_name
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
</pre>
|
137
|
-
<p>
|
138
|
-
This will autocreate the modules Configurations, Models, Views, and
|
139
|
-
Controllers within the Application module, as they are referenced, based on
|
140
|
-
the exemplar Module configured to autoload code from the configurations,
|
141
|
-
models, views, and controllers directories.
|
142
|
-
</p>
|
143
|
-
<p>
|
144
|
-
For example, referencing <tt>Application::Models::Customer</tt> will cause
|
145
|
-
the file <tt>models/customer.rb</tt> to be loaded.
|
146
|
-
</p>
|
147
|
-
<h2>Other Uses</h2>
|
148
|
-
<p>
|
149
|
-
Autoloading and autocreation, along with reloading, can be used to provide
|
150
|
-
sophisticated rules for loading and even generating modules and classes
|
151
|
-
within a given module. These capabilities are increasingly found within
|
152
|
-
frameworks like Rails and Camping, but <b>Autocode</b> makes it possible to
|
153
|
-
mixin these capabilities into any situation and precisely control how they
|
154
|
-
are applied.
|
155
|
-
</p>
|
156
|
-
<h2>Support</h2>
|
157
|
-
<p>
|
158
|
-
If you have questions or comments, please go to the <b>Autocode</b> Web
|
159
|
-
site first at <a
|
160
|
-
href="http://code.google.com/p/ruby-autocode">code.google.com/p/ruby-autocode</a>/.
|
161
|
-
</p>
|
162
|
-
<p>
|
163
|
-
(c) 2007 Dan Yoder
|
164
|
-
</p>
|
165
|
-
<p>
|
166
|
-
Licensed under the MIT License.
|
167
|
-
</p>
|
168
|
-
|
169
|
-
</div>
|
170
|
-
|
171
|
-
|
172
|
-
</div>
|
173
|
-
|
174
|
-
|
175
|
-
</div>
|
176
|
-
|
177
|
-
|
178
|
-
<!-- if includes -->
|
179
|
-
|
180
|
-
<div id="section">
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
<!-- if method_list -->
|
190
|
-
|
191
|
-
|
192
|
-
</div>
|
193
|
-
|
194
|
-
|
195
|
-
<div id="validator-badges">
|
196
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
197
|
-
</div>
|
198
|
-
|
199
|
-
</body>
|
200
|
-
</html>
|
@@ -1,110 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: autocode.rb</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>autocode.rb</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>lib/autocode.rb
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Fri Jan 04 20:11:26 -0800 2008</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
|
72
|
-
<div id="requires-list">
|
73
|
-
<h3 class="section-bar">Required files</h3>
|
74
|
-
|
75
|
-
<div class="name-list">
|
76
|
-
autocreate
|
77
|
-
autoload
|
78
|
-
reloadable
|
79
|
-
</div>
|
80
|
-
</div>
|
81
|
-
|
82
|
-
</div>
|
83
|
-
|
84
|
-
|
85
|
-
</div>
|
86
|
-
|
87
|
-
|
88
|
-
<!-- if includes -->
|
89
|
-
|
90
|
-
<div id="section">
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
<!-- if method_list -->
|
100
|
-
|
101
|
-
|
102
|
-
</div>
|
103
|
-
|
104
|
-
|
105
|
-
<div id="validator-badges">
|
106
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
107
|
-
</div>
|
108
|
-
|
109
|
-
</body>
|
110
|
-
</html>
|