irbtools 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -7
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/doc/classes/IRB.html +111 -0
- data/doc/classes/IRB/CaptureIO.html +189 -0
- data/doc/classes/Irbtools.html +170 -0
- data/doc/classes/Kernel.html +161 -0
- data/doc/created.rid +1 -0
- data/doc/files/README_rdoc.html +225 -0
- data/doc/files/lib/irbtools/configure_rb.html +115 -0
- data/doc/files/lib/irbtools_rb.html +563 -0
- data/doc/fr_class_index.html +30 -0
- data/doc/fr_file_index.html +29 -0
- data/doc/fr_method_index.html +48 -0
- data/doc/index.html +26 -0
- data/doc/rdoc-style.css +208 -0
- data/irbtools.gemspec +87 -0
- data/lib/irbtools.rb +193 -36
- data/lib/irbtools/configure.rb +58 -0
- metadata +20 -5
@@ -0,0 +1,563 @@
|
|
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: irbtools.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>irbtools.rb</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>lib/irbtools.rb
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Wed Oct 06 16:34:13 +0200 2010</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
|
+
encoding: utf-8
|
74
|
+
</p>
|
75
|
+
|
76
|
+
</div>
|
77
|
+
|
78
|
+
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<div id="method-list">
|
82
|
+
<h3 class="section-bar">Methods</h3>
|
83
|
+
|
84
|
+
<div class="name-list">
|
85
|
+
<a href="#M000012">cat</a>
|
86
|
+
<a href="#M000011">cd</a>
|
87
|
+
<a href="#M000007">colorize</a>
|
88
|
+
<a href="#M000001">copy</a>
|
89
|
+
<a href="#M000003">copy_input</a>
|
90
|
+
<a href="#M000005">copy_output</a>
|
91
|
+
<a href="#M000004">copy_session_input</a>
|
92
|
+
<a href="#M000006">copy_session_output</a>
|
93
|
+
<a href="#M000010">dir</a>
|
94
|
+
<a href="#M000009">ls</a>
|
95
|
+
<a href="#M000002">paste</a>
|
96
|
+
<a href="#M000008">ray</a>
|
97
|
+
<a href="#M000015">reset!</a>
|
98
|
+
<a href="#M000013">rq</a>
|
99
|
+
<a href="#M000016">ruby_version</a>
|
100
|
+
<a href="#M000014">session_history</a>
|
101
|
+
<a href="#M000017">use</a>
|
102
|
+
</div>
|
103
|
+
</div>
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
<!-- if includes -->
|
109
|
+
<div id="includes">
|
110
|
+
<h3 class="section-bar">Included Modules</h3>
|
111
|
+
|
112
|
+
<div id="includes-list">
|
113
|
+
<span class="include-name">FileUtils::Verbose</span>
|
114
|
+
</div>
|
115
|
+
</div>
|
116
|
+
|
117
|
+
<div id="section">
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
<!-- if method_list -->
|
127
|
+
<div id="methods">
|
128
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
129
|
+
|
130
|
+
<div id="method-M000012" class="method-detail">
|
131
|
+
<a name="M000012"></a>
|
132
|
+
|
133
|
+
<div class="method-heading">
|
134
|
+
<a href="#M000012" class="method-signature">
|
135
|
+
<span class="method-name">cat</span><span class="method-args">(path)</span>
|
136
|
+
</a>
|
137
|
+
</div>
|
138
|
+
|
139
|
+
<div class="method-description">
|
140
|
+
<p>
|
141
|
+
read file contents (also see <a href="irbtools_rb.html#M000008">ray</a> for
|
142
|
+
ruby source files ;) )
|
143
|
+
</p>
|
144
|
+
<p><a class="source-toggle" href="#"
|
145
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
146
|
+
<div class="method-source-code" id="M000012-source">
|
147
|
+
<pre>
|
148
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 91</span>
|
149
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cat</span>(<span class="ruby-identifier">path</span>)
|
150
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span> <span class="ruby-identifier">path</span>
|
151
|
+
<span class="ruby-keyword kw">end</span>
|
152
|
+
</pre>
|
153
|
+
</div>
|
154
|
+
</div>
|
155
|
+
</div>
|
156
|
+
|
157
|
+
<div id="method-M000011" class="method-detail">
|
158
|
+
<a name="M000011"></a>
|
159
|
+
|
160
|
+
<div class="method-heading">
|
161
|
+
<a href="#M000011" class="method-signature">
|
162
|
+
<span class="method-name">cd</span><span class="method-args">(path = '/', *args)</span>
|
163
|
+
</a>
|
164
|
+
</div>
|
165
|
+
|
166
|
+
<div class="method-description">
|
167
|
+
<p>
|
168
|
+
patch <a href="irbtools_rb.html#M000011">cd</a> so that it also shows the
|
169
|
+
current directory
|
170
|
+
</p>
|
171
|
+
<p><a class="source-toggle" href="#"
|
172
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
173
|
+
<div class="method-source-code" id="M000011-source">
|
174
|
+
<pre>
|
175
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 85</span>
|
176
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cd</span>(<span class="ruby-identifier">path</span> = <span class="ruby-value str">'/'</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
177
|
+
<span class="ruby-constant">FileUtils</span><span class="ruby-operator">::</span><span class="ruby-constant">Verbose</span>.<span class="ruby-identifier">cd</span> <span class="ruby-identifier">path</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>
|
178
|
+
<span class="ruby-identifier">ls</span>
|
179
|
+
<span class="ruby-keyword kw">end</span>
|
180
|
+
</pre>
|
181
|
+
</div>
|
182
|
+
</div>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
<div id="method-M000007" class="method-detail">
|
186
|
+
<a name="M000007"></a>
|
187
|
+
|
188
|
+
<div class="method-heading">
|
189
|
+
<a href="#M000007" class="method-signature">
|
190
|
+
<span class="method-name">colorize</span><span class="method-args">(string)</span>
|
191
|
+
</a>
|
192
|
+
</div>
|
193
|
+
|
194
|
+
<div class="method-description">
|
195
|
+
<p>
|
196
|
+
syntax highlight a string
|
197
|
+
</p>
|
198
|
+
<p><a class="source-toggle" href="#"
|
199
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
200
|
+
<div class="method-source-code" id="M000007-source">
|
201
|
+
<pre>
|
202
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 54</span>
|
203
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">colorize</span>(<span class="ruby-identifier">string</span>)
|
204
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-constant">CodeRay</span>.<span class="ruby-identifier">scan</span>( <span class="ruby-identifier">string</span>, <span class="ruby-identifier">:ruby</span> ).<span class="ruby-identifier">term</span>
|
205
|
+
<span class="ruby-keyword kw">end</span>
|
206
|
+
</pre>
|
207
|
+
</div>
|
208
|
+
</div>
|
209
|
+
</div>
|
210
|
+
|
211
|
+
<div id="method-M000001" class="method-detail">
|
212
|
+
<a name="M000001"></a>
|
213
|
+
|
214
|
+
<div class="method-heading">
|
215
|
+
<a href="#M000001" class="method-signature">
|
216
|
+
<span class="method-name">copy</span><span class="method-args">(str)</span>
|
217
|
+
</a>
|
218
|
+
</div>
|
219
|
+
|
220
|
+
<div class="method-description">
|
221
|
+
<p>
|
222
|
+
copies the clipboard
|
223
|
+
</p>
|
224
|
+
<p><a class="source-toggle" href="#"
|
225
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
226
|
+
<div class="method-source-code" id="M000001-source">
|
227
|
+
<pre>
|
228
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 28</span>
|
229
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">copy</span>(<span class="ruby-identifier">str</span>)
|
230
|
+
<span class="ruby-constant">Clipboard</span>.<span class="ruby-identifier">copy</span>(<span class="ruby-identifier">str</span>)
|
231
|
+
<span class="ruby-keyword kw">end</span>
|
232
|
+
</pre>
|
233
|
+
</div>
|
234
|
+
</div>
|
235
|
+
</div>
|
236
|
+
|
237
|
+
<div id="method-M000003" class="method-detail">
|
238
|
+
<a name="M000003"></a>
|
239
|
+
|
240
|
+
<div class="method-heading">
|
241
|
+
<a href="#M000003" class="method-signature">
|
242
|
+
<span class="method-name">copy_input</span><span class="method-args">()</span>
|
243
|
+
</a>
|
244
|
+
</div>
|
245
|
+
|
246
|
+
<div class="method-description">
|
247
|
+
<p>
|
248
|
+
copies everything you have entered in this irb session
|
249
|
+
</p>
|
250
|
+
<p><a class="source-toggle" href="#"
|
251
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
252
|
+
<div class="method-source-code" id="M000003-source">
|
253
|
+
<pre>
|
254
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 38</span>
|
255
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">copy_input</span>
|
256
|
+
<span class="ruby-identifier">copy</span> <span class="ruby-identifier">session_history</span>
|
257
|
+
<span class="ruby-value str">"The session input history has been copied to the clipboard."</span>
|
258
|
+
<span class="ruby-keyword kw">end</span>
|
259
|
+
</pre>
|
260
|
+
</div>
|
261
|
+
</div>
|
262
|
+
</div>
|
263
|
+
|
264
|
+
<div id="method-M000005" class="method-detail">
|
265
|
+
<a name="M000005"></a>
|
266
|
+
|
267
|
+
<div class="method-heading">
|
268
|
+
<a href="#M000005" class="method-signature">
|
269
|
+
<span class="method-name">copy_output</span><span class="method-args">()</span>
|
270
|
+
</a>
|
271
|
+
</div>
|
272
|
+
|
273
|
+
<div class="method-description">
|
274
|
+
<p>
|
275
|
+
copies the output of all irb commands in this irb session
|
276
|
+
</p>
|
277
|
+
<p><a class="source-toggle" href="#"
|
278
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
279
|
+
<div class="method-source-code" id="M000005-source">
|
280
|
+
<pre>
|
281
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 45</span>
|
282
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">copy_output</span>
|
283
|
+
<span class="ruby-identifier">copy</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-identifier">:@eval_history_values</span>).<span class="ruby-identifier">inspect</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/^\d+ (.*)/</span>, <span class="ruby-value str">'\1'</span>)
|
284
|
+
<span class="ruby-value str">"The session output history has been copied to the clipboard."</span>
|
285
|
+
<span class="ruby-keyword kw">end</span>
|
286
|
+
</pre>
|
287
|
+
</div>
|
288
|
+
</div>
|
289
|
+
</div>
|
290
|
+
|
291
|
+
<div id="method-M000004" class="method-detail">
|
292
|
+
<a name="M000004"></a>
|
293
|
+
|
294
|
+
<div class="method-heading">
|
295
|
+
<span class="method-name">copy_session_input</span><span class="method-args">()</span>
|
296
|
+
</div>
|
297
|
+
|
298
|
+
<div class="method-description">
|
299
|
+
<p>
|
300
|
+
Alias for <a href="irbtools_rb.html#M000003">copy_input</a>
|
301
|
+
</p>
|
302
|
+
</div>
|
303
|
+
</div>
|
304
|
+
|
305
|
+
<div id="method-M000006" class="method-detail">
|
306
|
+
<a name="M000006"></a>
|
307
|
+
|
308
|
+
<div class="method-heading">
|
309
|
+
<span class="method-name">copy_session_output</span><span class="method-args">()</span>
|
310
|
+
</div>
|
311
|
+
|
312
|
+
<div class="method-description">
|
313
|
+
<p>
|
314
|
+
Alias for <a href="irbtools_rb.html#M000005">copy_output</a>
|
315
|
+
</p>
|
316
|
+
</div>
|
317
|
+
</div>
|
318
|
+
|
319
|
+
<div id="method-M000010" class="method-detail">
|
320
|
+
<a name="M000010"></a>
|
321
|
+
|
322
|
+
<div class="method-heading">
|
323
|
+
<span class="method-name">dir</span><span class="method-args">(path='.')</span>
|
324
|
+
</div>
|
325
|
+
|
326
|
+
<div class="method-description">
|
327
|
+
<p>
|
328
|
+
Alias for <a href="irbtools_rb.html#M000009">ls</a>
|
329
|
+
</p>
|
330
|
+
</div>
|
331
|
+
</div>
|
332
|
+
|
333
|
+
<div id="method-M000009" class="method-detail">
|
334
|
+
<a name="M000009"></a>
|
335
|
+
|
336
|
+
<div class="method-heading">
|
337
|
+
<a href="#M000009" class="method-signature">
|
338
|
+
<span class="method-name">ls</span><span class="method-args">(path='.')</span>
|
339
|
+
</a>
|
340
|
+
</div>
|
341
|
+
|
342
|
+
<div class="method-description">
|
343
|
+
<p>
|
344
|
+
shows the contents of your current directory (more such commands available
|
345
|
+
by FileUtils)
|
346
|
+
</p>
|
347
|
+
<p><a class="source-toggle" href="#"
|
348
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
349
|
+
<div class="method-source-code" id="M000009-source">
|
350
|
+
<pre>
|
351
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 79</span>
|
352
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ls</span>(<span class="ruby-identifier">path</span>=<span class="ruby-value str">'.'</span>)
|
353
|
+
<span class="ruby-constant">Dir</span>[ <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">path</span>, <span class="ruby-value str">'*'</span> ].<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">res</span><span class="ruby-operator">|</span> <span class="ruby-identifier">res</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/^#{path}\/?/</span>; <span class="ruby-identifier">$'</span> }
|
354
|
+
<span class="ruby-keyword kw">end</span>
|
355
|
+
</pre>
|
356
|
+
</div>
|
357
|
+
</div>
|
358
|
+
</div>
|
359
|
+
|
360
|
+
<div id="method-M000002" class="method-detail">
|
361
|
+
<a name="M000002"></a>
|
362
|
+
|
363
|
+
<div class="method-heading">
|
364
|
+
<a href="#M000002" class="method-signature">
|
365
|
+
<span class="method-name">paste</span><span class="method-args">()</span>
|
366
|
+
</a>
|
367
|
+
</div>
|
368
|
+
|
369
|
+
<div class="method-description">
|
370
|
+
<p>
|
371
|
+
pastes the clipboard
|
372
|
+
</p>
|
373
|
+
<p><a class="source-toggle" href="#"
|
374
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
375
|
+
<div class="method-source-code" id="M000002-source">
|
376
|
+
<pre>
|
377
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 33</span>
|
378
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">paste</span>
|
379
|
+
<span class="ruby-constant">Clipboard</span>.<span class="ruby-identifier">paste</span>
|
380
|
+
<span class="ruby-keyword kw">end</span>
|
381
|
+
</pre>
|
382
|
+
</div>
|
383
|
+
</div>
|
384
|
+
</div>
|
385
|
+
|
386
|
+
<div id="method-M000008" class="method-detail">
|
387
|
+
<a name="M000008"></a>
|
388
|
+
|
389
|
+
<div class="method-heading">
|
390
|
+
<a href="#M000008" class="method-signature">
|
391
|
+
<span class="method-name">ray</span><span class="method-args">(path)</span>
|
392
|
+
</a>
|
393
|
+
</div>
|
394
|
+
|
395
|
+
<div class="method-description">
|
396
|
+
<p>
|
397
|
+
syntax highlight a file
|
398
|
+
</p>
|
399
|
+
<p><a class="source-toggle" href="#"
|
400
|
+
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
401
|
+
<div class="method-source-code" id="M000008-source">
|
402
|
+
<pre>
|
403
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 59</span>
|
404
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ray</span>(<span class="ruby-identifier">path</span>)
|
405
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-constant">CodeRay</span>.<span class="ruby-identifier">scan</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">path</span>), <span class="ruby-identifier">:ruby</span> ).<span class="ruby-identifier">term</span>
|
406
|
+
<span class="ruby-keyword kw">end</span>
|
407
|
+
</pre>
|
408
|
+
</div>
|
409
|
+
</div>
|
410
|
+
</div>
|
411
|
+
|
412
|
+
<div id="method-M000015" class="method-detail">
|
413
|
+
<a name="M000015"></a>
|
414
|
+
|
415
|
+
<div class="method-heading">
|
416
|
+
<a href="#M000015" class="method-signature">
|
417
|
+
<span class="method-name">reset!</span><span class="method-args">(</span>
|
418
|
+
</a>
|
419
|
+
</div>
|
420
|
+
|
421
|
+
<div class="method-description">
|
422
|
+
<p>
|
423
|
+
restart irb
|
424
|
+
</p>
|
425
|
+
<p><a class="source-toggle" href="#"
|
426
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
427
|
+
<div class="method-source-code" id="M000015-source">
|
428
|
+
<pre>
|
429
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 106</span>
|
430
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset!</span> <span class="ruby-comment cmt"># restart irb</span>
|
431
|
+
<span class="ruby-identifier">exec</span><span class="ruby-identifier">$0</span>
|
432
|
+
<span class="ruby-keyword kw">end</span>
|
433
|
+
</pre>
|
434
|
+
</div>
|
435
|
+
</div>
|
436
|
+
</div>
|
437
|
+
|
438
|
+
<div id="method-M000013" class="method-detail">
|
439
|
+
<a name="M000013"></a>
|
440
|
+
|
441
|
+
<div class="method-heading">
|
442
|
+
<a href="#M000013" class="method-signature">
|
443
|
+
<span class="method-name">rq</span><span class="method-args">(lib)</span>
|
444
|
+
</a>
|
445
|
+
</div>
|
446
|
+
|
447
|
+
<div class="method-description">
|
448
|
+
<p>
|
449
|
+
allows concise syntax like <a href="irbtools_rb.html#M000013">rq</a>:mathn
|
450
|
+
</p>
|
451
|
+
<p><a class="source-toggle" href="#"
|
452
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
453
|
+
<div class="method-source-code" id="M000013-source">
|
454
|
+
<pre>
|
455
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 96</span>
|
456
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rq</span>(<span class="ruby-identifier">lib</span>)
|
457
|
+
<span class="ruby-identifier">require</span> <span class="ruby-identifier">lib</span>.<span class="ruby-identifier">to_s</span>
|
458
|
+
<span class="ruby-keyword kw">end</span>
|
459
|
+
</pre>
|
460
|
+
</div>
|
461
|
+
</div>
|
462
|
+
</div>
|
463
|
+
|
464
|
+
<div id="method-M000016" class="method-detail">
|
465
|
+
<a name="M000016"></a>
|
466
|
+
|
467
|
+
<div class="method-heading">
|
468
|
+
<a href="#M000016" class="method-signature">
|
469
|
+
<span class="method-name">ruby_version</span><span class="method-args">(which = nil)</span>
|
470
|
+
</a>
|
471
|
+
</div>
|
472
|
+
|
473
|
+
<div class="method-description">
|
474
|
+
<p><a class="source-toggle" href="#"
|
475
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
476
|
+
<div class="method-source-code" id="M000016-source">
|
477
|
+
<pre>
|
478
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 110</span>
|
479
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ruby_version</span>(<span class="ruby-identifier">which</span> = <span class="ruby-keyword kw">nil</span>)
|
480
|
+
<span class="ruby-comment cmt"># test if installed</span>
|
481
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-value">`rvm -v`</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/Seguin/</span>
|
482
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">'Ruby Version Manager must be installed to use this command'</span>
|
483
|
+
<span class="ruby-keyword kw">end</span>
|
484
|
+
|
485
|
+
<span class="ruby-comment cmt"># show rubies if called without options</span>
|
486
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">which</span>
|
487
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">'Availabe Rubies: '</span> <span class="ruby-operator">+</span>
|
488
|
+
<span class="ruby-value">`rvm list`</span>.<span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/^(?: |=>) (.*) \[/</span> )<span class="ruby-operator">*</span><span class="ruby-value str">", "</span>
|
489
|
+
<span class="ruby-keyword kw">return</span>
|
490
|
+
<span class="ruby-keyword kw">end</span>
|
491
|
+
|
492
|
+
<span class="ruby-comment cmt"># get irb suffix</span>
|
493
|
+
<span class="ruby-identifier">rv</span> = <span class="ruby-node">`rvm use #{which}`</span> <span class="ruby-comment cmt"># e.g. => "\ninfo: Using ruby 1.9.2 p0\n"</span>
|
494
|
+
<span class="ruby-comment cmt"># it does not change the ruby for the current user</span>
|
495
|
+
<span class="ruby-identifier">rv</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^.*Using(.*)\n/</span>
|
496
|
+
|
497
|
+
<span class="ruby-comment cmt"># if ruby is found, start it</span>
|
498
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$1</span>
|
499
|
+
<span class="ruby-identifier">ruby_name</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">split</span>( <span class="ruby-identifier">$1</span> )[<span class="ruby-value">-1</span>].<span class="ruby-identifier">tr</span>(<span class="ruby-value str">' '</span>, <span class="ruby-value str">'-'</span>)
|
500
|
+
<span class="ruby-identifier">irbname</span> = <span class="ruby-identifier">$0</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'-'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">ruby_name</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'@global'</span>
|
501
|
+
<span class="ruby-identifier">exec</span> <span class="ruby-identifier">irbname</span>
|
502
|
+
<span class="ruby-keyword kw">else</span>
|
503
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Sorry, that Ruby version could not be found."</span>
|
504
|
+
<span class="ruby-keyword kw">end</span>
|
505
|
+
<span class="ruby-keyword kw">end</span>
|
506
|
+
</pre>
|
507
|
+
</div>
|
508
|
+
</div>
|
509
|
+
</div>
|
510
|
+
|
511
|
+
<div id="method-M000014" class="method-detail">
|
512
|
+
<a name="M000014"></a>
|
513
|
+
|
514
|
+
<div class="method-heading">
|
515
|
+
<a href="#M000014" class="method-signature">
|
516
|
+
<span class="method-name">session_history</span><span class="method-args">(number_of_lines = context.instance_variable_get(:@line_no) )</span>
|
517
|
+
</a>
|
518
|
+
</div>
|
519
|
+
|
520
|
+
<div class="method-description">
|
521
|
+
<p>
|
522
|
+
returns the last lines, needed for some copy_ methods
|
523
|
+
</p>
|
524
|
+
<p><a class="source-toggle" href="#"
|
525
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
526
|
+
<div class="method-source-code" id="M000014-source">
|
527
|
+
<pre>
|
528
|
+
<span class="ruby-comment cmt"># File lib/irbtools.rb, line 101</span>
|
529
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session_history</span>(<span class="ruby-identifier">number_of_lines</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-identifier">:@line_no</span>) )
|
530
|
+
<span class="ruby-constant">Readline</span><span class="ruby-operator">::</span><span class="ruby-constant">HISTORY</span>.<span class="ruby-identifier">entries</span>[<span class="ruby-operator">-</span><span class="ruby-identifier">number_of_lines</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>]<span class="ruby-operator">*</span><span class="ruby-value str">"\n"</span>
|
531
|
+
<span class="ruby-keyword kw">end</span>
|
532
|
+
</pre>
|
533
|
+
</div>
|
534
|
+
</div>
|
535
|
+
</div>
|
536
|
+
|
537
|
+
<div id="method-M000017" class="method-detail">
|
538
|
+
<a name="M000017"></a>
|
539
|
+
|
540
|
+
<div class="method-heading">
|
541
|
+
<span class="method-name">use</span><span class="method-args">(which = nil)</span>
|
542
|
+
</div>
|
543
|
+
|
544
|
+
<div class="method-description">
|
545
|
+
<p>
|
546
|
+
Alias for <a href="irbtools_rb.html#M000016">ruby_version</a>
|
547
|
+
</p>
|
548
|
+
</div>
|
549
|
+
</div>
|
550
|
+
|
551
|
+
|
552
|
+
</div>
|
553
|
+
|
554
|
+
|
555
|
+
</div>
|
556
|
+
|
557
|
+
|
558
|
+
<div id="validator-badges">
|
559
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
560
|
+
</div>
|
561
|
+
|
562
|
+
</body>
|
563
|
+
</html>
|