stella 0.3.2 → 0.5.1
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.txt +24 -84
- data/Rakefile +1 -6
- data/doc/classes/Crypto.html +248 -0
- data/doc/classes/Crypto/Key.html +308 -0
- data/doc/classes/Enumerable.html +309 -0
- data/doc/classes/FileUtil.html +310 -0
- data/doc/classes/HTTPUtil.html +530 -0
- data/doc/classes/MathUtil.html +210 -0
- data/doc/classes/Stella.html +238 -0
- data/doc/classes/Stella/Adapter.html +127 -0
- data/doc/classes/Stella/Adapter/ApacheBench.html +1076 -0
- data/doc/classes/Stella/Adapter/Base.html +432 -0
- data/doc/classes/Stella/Adapter/CommandNotReady.html +146 -0
- data/doc/classes/Stella/Adapter/Httperf.html +949 -0
- data/doc/classes/Stella/Adapter/Siege.html +1011 -0
- data/doc/classes/Stella/CLI.html +914 -0
- data/doc/classes/Stella/CLI/Base.html +186 -0
- data/doc/classes/Stella/CLI/Language.html +149 -0
- data/doc/classes/Stella/CLI/LocalTest.html +268 -0
- data/doc/classes/Stella/Command.html +111 -0
- data/doc/classes/Stella/Command/Base.html +335 -0
- data/doc/classes/Stella/Config.html +292 -0
- data/doc/classes/Stella/InvalidArgument.html +242 -0
- data/doc/classes/Stella/LocalTest.html +450 -0
- data/doc/classes/Stella/Logger.html +548 -0
- data/doc/classes/Stella/Response.html +846 -0
- data/doc/classes/Stella/Storable.html +928 -0
- data/doc/classes/Stella/Test.html +142 -0
- data/doc/classes/Stella/Test/DaySummary.html +249 -0
- data/doc/classes/Stella/Test/Definition.html +294 -0
- data/doc/classes/Stella/Test/Definition/Rampup.html +215 -0
- data/doc/classes/Stella/Test/RunSummary.html +315 -0
- data/doc/classes/Stella/Test/SummaryBase.html +286 -0
- data/doc/classes/Stella/Test/TestSummary.html +200 -0
- data/doc/classes/Stella/Text.html +581 -0
- data/doc/classes/Stella/Text/Resource.html +289 -0
- data/doc/classes/Stella/UnavailableAdapter.html +242 -0
- data/doc/classes/Stella/UnknownValue.html +242 -0
- data/doc/classes/Stella/UnsupportedLanguage.html +115 -0
- data/doc/classes/Stella/Util.html +348 -0
- data/doc/classes/TextGraph.html +460 -0
- data/doc/classes/TimerUtil.html +431 -0
- data/doc/created.rid +1 -0
- data/doc/files/LICENSE_txt.html +129 -0
- data/doc/files/README_txt.html +209 -0
- data/doc/files/lib/stella/adapter/ab_rb.html +101 -0
- data/doc/files/lib/stella/adapter/base_rb.html +101 -0
- data/doc/files/lib/stella/adapter/httperf_rb.html +101 -0
- data/doc/files/lib/stella/adapter/siege_rb.html +101 -0
- data/doc/files/lib/stella/cli/base_rb.html +101 -0
- data/doc/files/lib/stella/cli/language_rb.html +101 -0
- data/doc/files/lib/stella/cli/localtest_rb.html +101 -0
- data/doc/files/lib/stella/cli_rb.html +112 -0
- data/doc/files/lib/stella/command/base_rb.html +101 -0
- data/doc/files/lib/stella/command/localtest_rb.html +101 -0
- data/doc/files/lib/stella/logger_rb.html +101 -0
- data/doc/files/lib/stella/response_rb.html +101 -0
- data/doc/files/lib/stella/storable_rb.html +109 -0
- data/doc/files/lib/stella/support_rb.html +101 -0
- data/doc/files/lib/stella/test/daysummary_rb.html +101 -0
- data/doc/files/lib/stella/test/definition_rb.html +101 -0
- data/doc/files/lib/stella/test/runsummary_rb.html +101 -0
- data/doc/files/lib/stella/test/summarybase_rb.html +101 -0
- data/doc/files/lib/stella/test/testsummary_rb.html +108 -0
- data/doc/files/lib/stella/text/resource_rb.html +108 -0
- data/doc/files/lib/stella/text_rb.html +108 -0
- data/doc/files/lib/stella_rb.html +128 -0
- data/doc/files/lib/utils/crypto-key_rb.html +116 -0
- data/doc/files/lib/utils/fileutil_rb.html +108 -0
- data/doc/files/lib/utils/httputil_rb.html +110 -0
- data/doc/files/lib/utils/mathutil_rb.html +101 -0
- data/doc/files/lib/utils/textgraph_rb.html +138 -0
- data/doc/files/lib/utils/timerutil_rb.html +108 -0
- data/doc/fr_class_index.html +66 -0
- data/doc/fr_file_index.html +62 -0
- data/doc/fr_method_index.html +309 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/stella.rb +5 -6
- data/lib/stella/adapter/ab.rb +4 -31
- data/lib/stella/adapter/base.rb +1 -15
- data/lib/stella/adapter/httperf.rb +4 -35
- data/lib/stella/adapter/siege.rb +29 -51
- data/lib/stella/cli.rb +22 -45
- data/lib/stella/cli/language.rb +0 -2
- data/lib/stella/cli/localtest.rb +0 -5
- data/lib/stella/command/base.rb +1 -1
- data/lib/stella/command/localtest.rb +68 -84
- data/lib/stella/test/daysummary.rb +93 -0
- data/lib/stella/test/definition.rb +5 -10
- data/lib/stella/test/{run/summary.rb → runsummary.rb} +6 -4
- data/lib/stella/test/{base.rb → summarybase.rb} +7 -3
- data/lib/stella/test/{summary.rb → testsummary.rb} +29 -27
- data/lib/utils/mathutil.rb +34 -36
- data/spec/base.rb +26 -0
- data/spec/shell_spec.rb +12 -0
- data/support/text/en.yaml +1 -7
- metadata +102 -8
- data/lib/stella/cli/agents.rb +0 -73
- data/lib/utils/escape.rb +0 -302
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
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>Module: Enumerable</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
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="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Module</strong></td>
|
|
53
|
+
<td class="class-name-in-header">Enumerable</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../files/lib/utils/mathutil_rb.html">
|
|
59
|
+
lib/utils/mathutil.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
<a href="../files/lib/utils/textgraph_rb.html">
|
|
63
|
+
lib/utils/textgraph.rb
|
|
64
|
+
</a>
|
|
65
|
+
<br />
|
|
66
|
+
</td>
|
|
67
|
+
</tr>
|
|
68
|
+
|
|
69
|
+
</table>
|
|
70
|
+
</div>
|
|
71
|
+
<!-- banner header -->
|
|
72
|
+
|
|
73
|
+
<div id="bodyContent">
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
<div id="contextContent">
|
|
78
|
+
|
|
79
|
+
<div id="description">
|
|
80
|
+
<p>
|
|
81
|
+
Text::Graph Port of Wade Johnson‘s Text::Graph for perl
|
|
82
|
+
</p>
|
|
83
|
+
<pre>
|
|
84
|
+
http://search.cpan.org/src/GWADEJ/Text-Graph-0.23/Graph.pm
|
|
85
|
+
</pre>
|
|
86
|
+
<p>
|
|
87
|
+
Author: Martin DeMello <martindeme…@gmail.com>
|
|
88
|
+
</p>
|
|
89
|
+
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<div id="method-list">
|
|
96
|
+
<h3 class="section-bar">Methods</h3>
|
|
97
|
+
|
|
98
|
+
<div class="name-list">
|
|
99
|
+
<a href="#M000262">average</a>
|
|
100
|
+
<a href="#M000266">map_with_index</a>
|
|
101
|
+
<a href="#M000265">minmax</a>
|
|
102
|
+
<a href="#M000263">sample_variance</a>
|
|
103
|
+
<a href="#M000264">standard_deviation</a>
|
|
104
|
+
<a href="#M000261">sum</a>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
<!-- if includes -->
|
|
112
|
+
|
|
113
|
+
<div id="section">
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
<!-- if method_list -->
|
|
123
|
+
<div id="methods">
|
|
124
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
125
|
+
|
|
126
|
+
<div id="method-M000262" class="method-detail">
|
|
127
|
+
<a name="M000262"></a>
|
|
128
|
+
|
|
129
|
+
<div class="method-heading">
|
|
130
|
+
<a href="#M000262" class="method-signature">
|
|
131
|
+
<span class="method-name">average</span><span class="method-args">()</span>
|
|
132
|
+
</a>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
<div class="method-description">
|
|
136
|
+
<p>
|
|
137
|
+
Average of all the elements of the <a href="Enumerable.html">Enumerable</a>
|
|
138
|
+
</p>
|
|
139
|
+
<p>
|
|
140
|
+
The <a href="Enumerable.html">Enumerable</a> must respond to length
|
|
141
|
+
</p>
|
|
142
|
+
<p><a class="source-toggle" href="#"
|
|
143
|
+
onclick="toggleCode('M000262-source');return false;">[Source]</a></p>
|
|
144
|
+
<div class="method-source-code" id="M000262-source">
|
|
145
|
+
<pre>
|
|
146
|
+
<span class="ruby-comment cmt"># File lib/utils/mathutil.rb, line 18</span>
|
|
147
|
+
18: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">average</span>
|
|
148
|
+
19: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">sum</span> <span class="ruby-operator">/</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_f</span>
|
|
149
|
+
20: <span class="ruby-keyword kw">end</span>
|
|
150
|
+
</pre>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<div id="method-M000266" class="method-detail">
|
|
156
|
+
<a name="M000266"></a>
|
|
157
|
+
|
|
158
|
+
<div class="method-heading">
|
|
159
|
+
<a href="#M000266" class="method-signature">
|
|
160
|
+
<span class="method-name">map_with_index</span><span class="method-args">() {|e,i| ...}</span>
|
|
161
|
+
</a>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<div class="method-description">
|
|
165
|
+
<p><a class="source-toggle" href="#"
|
|
166
|
+
onclick="toggleCode('M000266-source');return false;">[Source]</a></p>
|
|
167
|
+
<div class="method-source-code" id="M000266-source">
|
|
168
|
+
<pre>
|
|
169
|
+
<span class="ruby-comment cmt"># File lib/utils/textgraph.rb, line 55</span>
|
|
170
|
+
55: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map_with_index</span>
|
|
171
|
+
56: <span class="ruby-identifier">a</span> = []
|
|
172
|
+
57: <span class="ruby-identifier">each_with_index</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span> <span class="ruby-operator"><<</span> <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">e</span>,<span class="ruby-identifier">i</span>)}
|
|
173
|
+
58: <span class="ruby-identifier">a</span>
|
|
174
|
+
59: <span class="ruby-keyword kw">end</span>
|
|
175
|
+
</pre>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
<div id="method-M000265" class="method-detail">
|
|
181
|
+
<a name="M000265"></a>
|
|
182
|
+
|
|
183
|
+
<div class="method-heading">
|
|
184
|
+
<a href="#M000265" class="method-signature">
|
|
185
|
+
<span class="method-name">minmax</span><span class="method-args">()</span>
|
|
186
|
+
</a>
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<div class="method-description">
|
|
190
|
+
<p><a class="source-toggle" href="#"
|
|
191
|
+
onclick="toggleCode('M000265-source');return false;">[Source]</a></p>
|
|
192
|
+
<div class="method-source-code" id="M000265-source">
|
|
193
|
+
<pre>
|
|
194
|
+
<span class="ruby-comment cmt"># File lib/utils/textgraph.rb, line 45</span>
|
|
195
|
+
45: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">minmax</span>
|
|
196
|
+
46: <span class="ruby-identifier">min</span> = <span class="ruby-value">1.0</span><span class="ruby-operator">/</span><span class="ruby-value">0</span>
|
|
197
|
+
47: <span class="ruby-identifier">max</span> = <span class="ruby-value">-1.0</span><span class="ruby-operator">/</span><span class="ruby-value">0</span>
|
|
198
|
+
48: <span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
|
199
|
+
49: <span class="ruby-identifier">min</span> = <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">i</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">min</span>
|
|
200
|
+
50: <span class="ruby-identifier">max</span> = <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">></span> <span class="ruby-identifier">max</span>
|
|
201
|
+
51: }
|
|
202
|
+
52: [<span class="ruby-identifier">min</span>, <span class="ruby-identifier">max</span>]
|
|
203
|
+
53: <span class="ruby-keyword kw">end</span>
|
|
204
|
+
</pre>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
<div id="method-M000263" class="method-detail">
|
|
210
|
+
<a name="M000263"></a>
|
|
211
|
+
|
|
212
|
+
<div class="method-heading">
|
|
213
|
+
<a href="#M000263" class="method-signature">
|
|
214
|
+
<span class="method-name">sample_variance</span><span class="method-args">()</span>
|
|
215
|
+
</a>
|
|
216
|
+
</div>
|
|
217
|
+
|
|
218
|
+
<div class="method-description">
|
|
219
|
+
<p>
|
|
220
|
+
Sample variance of all the elements of the <a
|
|
221
|
+
href="Enumerable.html">Enumerable</a>
|
|
222
|
+
</p>
|
|
223
|
+
<p>
|
|
224
|
+
The <a href="Enumerable.html">Enumerable</a> must respond to length
|
|
225
|
+
</p>
|
|
226
|
+
<p><a class="source-toggle" href="#"
|
|
227
|
+
onclick="toggleCode('M000263-source');return false;">[Source]</a></p>
|
|
228
|
+
<div class="method-source-code" id="M000263-source">
|
|
229
|
+
<pre>
|
|
230
|
+
<span class="ruby-comment cmt"># File lib/utils/mathutil.rb, line 27</span>
|
|
231
|
+
27: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sample_variance</span>
|
|
232
|
+
28: <span class="ruby-identifier">avg</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">average</span>
|
|
233
|
+
29: <span class="ruby-identifier">sum</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">acc</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">acc</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">i</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">avg</span>) <span class="ruby-operator">**</span> <span class="ruby-value">2</span> }
|
|
234
|
+
30: <span class="ruby-keyword kw">return</span> (<span class="ruby-value">1</span> <span class="ruby-operator">/</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">sum</span>)
|
|
235
|
+
31: <span class="ruby-keyword kw">end</span>
|
|
236
|
+
</pre>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<div id="method-M000264" class="method-detail">
|
|
242
|
+
<a name="M000264"></a>
|
|
243
|
+
|
|
244
|
+
<div class="method-heading">
|
|
245
|
+
<a href="#M000264" class="method-signature">
|
|
246
|
+
<span class="method-name">standard_deviation</span><span class="method-args">()</span>
|
|
247
|
+
</a>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
<div class="method-description">
|
|
251
|
+
<p>
|
|
252
|
+
Standard deviation of all the elements of the <a
|
|
253
|
+
href="Enumerable.html">Enumerable</a>
|
|
254
|
+
</p>
|
|
255
|
+
<p>
|
|
256
|
+
The <a href="Enumerable.html">Enumerable</a> must respond to length
|
|
257
|
+
</p>
|
|
258
|
+
<p><a class="source-toggle" href="#"
|
|
259
|
+
onclick="toggleCode('M000264-source');return false;">[Source]</a></p>
|
|
260
|
+
<div class="method-source-code" id="M000264-source">
|
|
261
|
+
<pre>
|
|
262
|
+
<span class="ruby-comment cmt"># File lib/utils/mathutil.rb, line 38</span>
|
|
263
|
+
38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">standard_deviation</span>
|
|
264
|
+
39: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Math</span>.<span class="ruby-identifier">sqrt</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">sample_variance</span>)
|
|
265
|
+
40: <span class="ruby-keyword kw">end</span>
|
|
266
|
+
</pre>
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
</div>
|
|
270
|
+
|
|
271
|
+
<div id="method-M000261" class="method-detail">
|
|
272
|
+
<a name="M000261"></a>
|
|
273
|
+
|
|
274
|
+
<div class="method-heading">
|
|
275
|
+
<a href="#M000261" class="method-signature">
|
|
276
|
+
<span class="method-name">sum</span><span class="method-args">()</span>
|
|
277
|
+
</a>
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
<div class="method-description">
|
|
281
|
+
<p>
|
|
282
|
+
Sum of all the elements of the <a href="Enumerable.html">Enumerable</a>
|
|
283
|
+
</p>
|
|
284
|
+
<p><a class="source-toggle" href="#"
|
|
285
|
+
onclick="toggleCode('M000261-source');return false;">[Source]</a></p>
|
|
286
|
+
<div class="method-source-code" id="M000261-source">
|
|
287
|
+
<pre>
|
|
288
|
+
<span class="ruby-comment cmt"># File lib/utils/mathutil.rb, line 9</span>
|
|
289
|
+
9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sum</span>
|
|
290
|
+
10: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">acc</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">acc</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">i</span> }
|
|
291
|
+
11: <span class="ruby-keyword kw">end</span>
|
|
292
|
+
</pre>
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
</div>
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
</div>
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
<div id="validator-badges">
|
|
305
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
306
|
+
</div>
|
|
307
|
+
|
|
308
|
+
</body>
|
|
309
|
+
</html>
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
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>Module: FileUtil</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
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="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Module</strong></td>
|
|
53
|
+
<td class="class-name-in-header">FileUtil</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../files/lib/utils/fileutil_rb.html">
|
|
59
|
+
lib/utils/fileutil.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
</table>
|
|
66
|
+
</div>
|
|
67
|
+
<!-- banner header -->
|
|
68
|
+
|
|
69
|
+
<div id="bodyContent">
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
<div id="contextContent">
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div id="method-list">
|
|
80
|
+
<h3 class="section-bar">Methods</h3>
|
|
81
|
+
|
|
82
|
+
<div class="name-list">
|
|
83
|
+
<a href="#M000271">append_file</a>
|
|
84
|
+
<a href="#M000273">create_dir</a>
|
|
85
|
+
<a href="#M000269">read_binary_file</a>
|
|
86
|
+
<a href="#M000267">read_file</a>
|
|
87
|
+
<a href="#M000268">read_file_to_array</a>
|
|
88
|
+
<a href="#M000270">write_file</a>
|
|
89
|
+
<a href="#M000272">write_or_append_file</a>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
<!-- if includes -->
|
|
97
|
+
|
|
98
|
+
<div id="section">
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
<!-- if method_list -->
|
|
108
|
+
<div id="methods">
|
|
109
|
+
<h3 class="section-bar">Public Class methods</h3>
|
|
110
|
+
|
|
111
|
+
<div id="method-M000271" class="method-detail">
|
|
112
|
+
<a name="M000271"></a>
|
|
113
|
+
|
|
114
|
+
<div class="method-heading">
|
|
115
|
+
<a href="#M000271" class="method-signature">
|
|
116
|
+
<span class="method-name">append_file</span><span class="method-args">(path, content, flush=true)</span>
|
|
117
|
+
</a>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<div class="method-description">
|
|
121
|
+
<p><a class="source-toggle" href="#"
|
|
122
|
+
onclick="toggleCode('M000271-source');return false;">[Source]</a></p>
|
|
123
|
+
<div class="method-source-code" id="M000271-source">
|
|
124
|
+
<pre>
|
|
125
|
+
<span class="ruby-comment cmt"># File lib/utils/fileutil.rb, line 38</span>
|
|
126
|
+
38: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">FileUtil</span>.<span class="ruby-identifier">append_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">content</span>, <span class="ruby-identifier">flush</span>=<span class="ruby-keyword kw">true</span>)
|
|
127
|
+
39: <span class="ruby-constant">FileUtil</span>.<span class="ruby-identifier">write_or_append_file</span>(<span class="ruby-value str">'a'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">content</span>, <span class="ruby-identifier">flush</span>)
|
|
128
|
+
40: <span class="ruby-keyword kw">end</span>
|
|
129
|
+
</pre>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<div id="method-M000273" class="method-detail">
|
|
135
|
+
<a name="M000273"></a>
|
|
136
|
+
|
|
137
|
+
<div class="method-heading">
|
|
138
|
+
<a href="#M000273" class="method-signature">
|
|
139
|
+
<span class="method-name">create_dir</span><span class="method-args">(dirpath)</span>
|
|
140
|
+
</a>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<div class="method-description">
|
|
144
|
+
<p><a class="source-toggle" href="#"
|
|
145
|
+
onclick="toggleCode('M000273-source');return false;">[Source]</a></p>
|
|
146
|
+
<div class="method-source-code" id="M000273-source">
|
|
147
|
+
<pre>
|
|
148
|
+
<span class="ruby-comment cmt"># File lib/utils/fileutil.rb, line 53</span>
|
|
149
|
+
53: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">FileUtil</span>.<span class="ruby-identifier">create_dir</span>(<span class="ruby-identifier">dirpath</span>)
|
|
150
|
+
54: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">dirpath</span>)
|
|
151
|
+
55:
|
|
152
|
+
56: <span class="ruby-comment cmt">#STDERR.puts "Creating #{ dirpath }"</span>
|
|
153
|
+
57: <span class="ruby-constant">File</span>.<span class="ruby-identifier">makedirs</span>(<span class="ruby-identifier">dirpath</span>)
|
|
154
|
+
58: <span class="ruby-keyword kw">end</span>
|
|
155
|
+
</pre>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<div id="method-M000269" class="method-detail">
|
|
161
|
+
<a name="M000269"></a>
|
|
162
|
+
|
|
163
|
+
<div class="method-heading">
|
|
164
|
+
<a href="#M000269" class="method-signature">
|
|
165
|
+
<span class="method-name">read_binary_file</span><span class="method-args">(path)</span>
|
|
166
|
+
</a>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<div class="method-description">
|
|
170
|
+
<p><a class="source-toggle" href="#"
|
|
171
|
+
onclick="toggleCode('M000269-source');return false;">[Source]</a></p>
|
|
172
|
+
<div class="method-source-code" id="M000269-source">
|
|
173
|
+
<pre>
|
|
174
|
+
<span class="ruby-comment cmt"># File lib/utils/fileutil.rb, line 19</span>
|
|
175
|
+
19: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">FileUtil</span>.<span class="ruby-identifier">read_binary_file</span>(<span class="ruby-identifier">path</span>)
|
|
176
|
+
20: <span class="ruby-identifier">contents</span> = <span class="ruby-value str">''</span>
|
|
177
|
+
21: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">contents</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">path</span>)
|
|
178
|
+
22:
|
|
179
|
+
23: <span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value str">'rb'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span>
|
|
180
|
+
24: <span class="ruby-keyword kw">while</span> (<span class="ruby-operator">!</span><span class="ruby-identifier">l</span>.<span class="ruby-identifier">eof?</span>)
|
|
181
|
+
25: <span class="ruby-identifier">contents</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">4096</span>)
|
|
182
|
+
26: <span class="ruby-keyword kw">end</span>
|
|
183
|
+
27: <span class="ruby-keyword kw">end</span>
|
|
184
|
+
28:
|
|
185
|
+
29: <span class="ruby-identifier">contents</span>
|
|
186
|
+
30: <span class="ruby-keyword kw">end</span>
|
|
187
|
+
</pre>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<div id="method-M000267" class="method-detail">
|
|
193
|
+
<a name="M000267"></a>
|
|
194
|
+
|
|
195
|
+
<div class="method-heading">
|
|
196
|
+
<a href="#M000267" class="method-signature">
|
|
197
|
+
<span class="method-name">read_file</span><span class="method-args">(path)</span>
|
|
198
|
+
</a>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<div class="method-description">
|
|
202
|
+
<p><a class="source-toggle" href="#"
|
|
203
|
+
onclick="toggleCode('M000267-source');return false;">[Source]</a></p>
|
|
204
|
+
<div class="method-source-code" id="M000267-source">
|
|
205
|
+
<pre>
|
|
206
|
+
<span class="ruby-comment cmt"># File lib/utils/fileutil.rb, line 5</span>
|
|
207
|
+
5: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">FileUtil</span>.<span class="ruby-identifier">read_file</span>(<span class="ruby-identifier">path</span>)
|
|
208
|
+
6: <span class="ruby-constant">FileUtil</span>.<span class="ruby-identifier">read_file_to_array</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">''</span>)
|
|
209
|
+
7: <span class="ruby-keyword kw">end</span>
|
|
210
|
+
</pre>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
<div id="method-M000268" class="method-detail">
|
|
216
|
+
<a name="M000268"></a>
|
|
217
|
+
|
|
218
|
+
<div class="method-heading">
|
|
219
|
+
<a href="#M000268" class="method-signature">
|
|
220
|
+
<span class="method-name">read_file_to_array</span><span class="method-args">(path)</span>
|
|
221
|
+
</a>
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<div class="method-description">
|
|
225
|
+
<p><a class="source-toggle" href="#"
|
|
226
|
+
onclick="toggleCode('M000268-source');return false;">[Source]</a></p>
|
|
227
|
+
<div class="method-source-code" id="M000268-source">
|
|
228
|
+
<pre>
|
|
229
|
+
<span class="ruby-comment cmt"># File lib/utils/fileutil.rb, line 9</span>
|
|
230
|
+
9: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">FileUtil</span>.<span class="ruby-identifier">read_file_to_array</span>(<span class="ruby-identifier">path</span>)
|
|
231
|
+
10: <span class="ruby-identifier">contents</span> = []
|
|
232
|
+
11: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">contents</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">path</span>)
|
|
233
|
+
12:
|
|
234
|
+
13: <span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value str">'r'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span>
|
|
235
|
+
14: <span class="ruby-identifier">contents</span> = <span class="ruby-identifier">l</span>.<span class="ruby-identifier">readlines</span>
|
|
236
|
+
15: <span class="ruby-keyword kw">end</span>
|
|
237
|
+
16:
|
|
238
|
+
17: <span class="ruby-identifier">contents</span>
|
|
239
|
+
18: <span class="ruby-keyword kw">end</span>
|
|
240
|
+
</pre>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
|
|
245
|
+
<div id="method-M000270" class="method-detail">
|
|
246
|
+
<a name="M000270"></a>
|
|
247
|
+
|
|
248
|
+
<div class="method-heading">
|
|
249
|
+
<a href="#M000270" class="method-signature">
|
|
250
|
+
<span class="method-name">write_file</span><span class="method-args">(path, content, flush=true)</span>
|
|
251
|
+
</a>
|
|
252
|
+
</div>
|
|
253
|
+
|
|
254
|
+
<div class="method-description">
|
|
255
|
+
<p><a class="source-toggle" href="#"
|
|
256
|
+
onclick="toggleCode('M000270-source');return false;">[Source]</a></p>
|
|
257
|
+
<div class="method-source-code" id="M000270-source">
|
|
258
|
+
<pre>
|
|
259
|
+
<span class="ruby-comment cmt"># File lib/utils/fileutil.rb, line 34</span>
|
|
260
|
+
34: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">FileUtil</span>.<span class="ruby-identifier">write_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">content</span>, <span class="ruby-identifier">flush</span>=<span class="ruby-keyword kw">true</span>)
|
|
261
|
+
35: <span class="ruby-constant">FileUtil</span>.<span class="ruby-identifier">write_or_append_file</span>(<span class="ruby-value str">'w'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">content</span>, <span class="ruby-identifier">flush</span>)
|
|
262
|
+
36: <span class="ruby-keyword kw">end</span>
|
|
263
|
+
</pre>
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
<div id="method-M000272" class="method-detail">
|
|
269
|
+
<a name="M000272"></a>
|
|
270
|
+
|
|
271
|
+
<div class="method-heading">
|
|
272
|
+
<a href="#M000272" class="method-signature">
|
|
273
|
+
<span class="method-name">write_or_append_file</span><span class="method-args">(write_or_append, path, content = '', flush = true)</span>
|
|
274
|
+
</a>
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
<div class="method-description">
|
|
278
|
+
<p><a class="source-toggle" href="#"
|
|
279
|
+
onclick="toggleCode('M000272-source');return false;">[Source]</a></p>
|
|
280
|
+
<div class="method-source-code" id="M000272-source">
|
|
281
|
+
<pre>
|
|
282
|
+
<span class="ruby-comment cmt"># File lib/utils/fileutil.rb, line 42</span>
|
|
283
|
+
42: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">FileUtil</span>.<span class="ruby-identifier">write_or_append_file</span>(<span class="ruby-identifier">write_or_append</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">content</span> = <span class="ruby-value str">''</span>, <span class="ruby-identifier">flush</span> = <span class="ruby-keyword kw">true</span>)
|
|
284
|
+
43: <span class="ruby-comment cmt">#STDERR.puts "Writing to #{ path }..." </span>
|
|
285
|
+
44: <span class="ruby-constant">FileUtil</span>.<span class="ruby-identifier">create_dir</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">path</span>))
|
|
286
|
+
45:
|
|
287
|
+
46: <span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">write_or_append</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
|
288
|
+
47: <span class="ruby-identifier">f</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">content</span>
|
|
289
|
+
48: <span class="ruby-identifier">f</span>.<span class="ruby-identifier">flush</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">flush</span>;
|
|
290
|
+
49: <span class="ruby-keyword kw">end</span>
|
|
291
|
+
50: <span class="ruby-constant">File</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-value">0600</span>, <span class="ruby-identifier">path</span>)
|
|
292
|
+
51: <span class="ruby-keyword kw">end</span>
|
|
293
|
+
</pre>
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
</div>
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
</div>
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
<div id="validator-badges">
|
|
306
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
307
|
+
</div>
|
|
308
|
+
|
|
309
|
+
</body>
|
|
310
|
+
</html>
|