active-record-binder 1.1.0 → 1.2.0
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.md +217 -0
- data/bin/arb +13 -0
- data/doc/Binder.html +150 -0
- data/doc/Binder/AR.html +1880 -0
- data/doc/Binder/Command.html +252 -0
- data/doc/Binder/Help.html +374 -0
- data/doc/Binder/Migrate.html +682 -0
- data/doc/Binder/Strategy.html +550 -0
- data/doc/Binder/Version.html +285 -0
- data/doc/Class.html +220 -0
- data/doc/CommandParser.html +268 -0
- data/doc/CommandParser/ParseError.html +123 -0
- data/doc/DeferedDelegator.html +414 -0
- data/doc/MigrationProcessError.html +123 -0
- data/doc/MigrationVersionError.html +123 -0
- data/doc/String.html +245 -0
- data/doc/_index.html +256 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +300 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +300 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +348 -0
- data/doc/top-level-namespace.html +114 -0
- data/extras/cli_help.png +0 -0
- data/lib/active_record_binder.rb +21 -37
- data/lib/cli/command.rb +101 -0
- data/lib/cli/command_parser.rb +29 -0
- data/lib/cli/commands/commands.rb +4 -0
- data/lib/cli/commands/help.rb +35 -0
- data/lib/cli/commands/migrate.rb +77 -0
- data/lib/cli/commands/version.rb +16 -0
- data/lib/cli/core_ext.rb +21 -0
- data/lib/defered_delegator.rb +69 -0
- data/lib/version.rb +3 -0
- data/test/active_record_binder_test.rb +262 -0
- data/test/foo.sqlite3 +0 -0
- data/test/migrations.rb +29 -0
- data/test/minitest_helper.rb +15 -0
- data/test/mocks.rb +24 -0
- metadata +62 -5
@@ -0,0 +1,550 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: Binder::Strategy
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.4.1
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../';
|
20
|
+
framesUrl = "../frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../_index.html">Index (S)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../Binder.html" title="Binder (module)">Binder</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Strategy</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Class: Binder::Strategy
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName">Object</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">Binder::Strategy</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
<dt class="r2 last">Defined in:</dt>
|
97
|
+
<dd class="r2 last">lib/cli/command.rb</dd>
|
98
|
+
|
99
|
+
</dl>
|
100
|
+
<div class="clear"></div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>A Strategy is a way to declare a specific command. You need to subclass the
|
106
|
+
Binder::Strategy class and declare an `execute` method and a `description`
|
107
|
+
method.</p>
|
108
|
+
|
109
|
+
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
<div class="tags">
|
113
|
+
|
114
|
+
<div class="examples">
|
115
|
+
<p class="tag_title">Examples:</p>
|
116
|
+
|
117
|
+
|
118
|
+
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>Migrate</span> <span class='op'><</span> <span class='const'>Binder</span><span class='op'>::</span><span class='const'>Strategy</span>
|
119
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span> <span class='id identifier rubyid_args'>args</span>
|
120
|
+
<span class='comment'># Parse args and do migration stuff
|
121
|
+
</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Migration Done.</span><span class='tstring_end'>"</span></span> <span class='comment'># <= Binder::Command.new automaticaly renders the return value of an `execute` call
|
122
|
+
</span> <span class='kw'>end</span>
|
123
|
+
<span class='comment'>#
|
124
|
+
</span> <span class='comment'># The description call is mainly used by the `help` command.
|
125
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_description'>description</span>
|
126
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Easier Migration. Use the </span><span class='tstring_end'>"</span></span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>--directory</span><span class='tstring_end'>"</span></span><span class='period'>.</span><span class='id identifier rubyid_colorize'>colorize</span><span class='lparen'>(</span><span class='symbol'>:orange</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> option to pass in a directory to load.</span><span class='tstring_end'>"</span></span>
|
127
|
+
<span class='comment'># Yeah, notice the "colorize" String method that helps you write a string in a beatiful color.
|
128
|
+
</span> <span class='kw'>end</span>
|
129
|
+
<span class='kw'>end</span></code></pre>
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
|
134
|
+
</div><div id="subclasses">
|
135
|
+
<h2>Direct Known Subclasses</h2>
|
136
|
+
<p class="children"><span class='object_link'><a href="Help.html" title="Binder::Help (class)">Help</a></span>, <span class='object_link'><a href="Migrate.html" title="Binder::Migrate (class)">Migrate</a></span>, <span class='object_link'><a href="Version.html" title="Binder::Version (class)">Version</a></span></p>
|
137
|
+
</div>
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
<h2>
|
147
|
+
Class Method Summary
|
148
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
149
|
+
</h2>
|
150
|
+
|
151
|
+
<ul class="summary">
|
152
|
+
|
153
|
+
<li class="public ">
|
154
|
+
<span class="summary_signature">
|
155
|
+
|
156
|
+
<a href="#alias_class-class_method" title="alias_class (class method)">+ (Object) <strong>alias_class</strong>(_alias) </a>
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
</span>
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
<span class="summary_desc"><div class='inline'>
|
171
|
+
<p>creates an alias for the command.</p>
|
172
|
+
</div></span>
|
173
|
+
|
174
|
+
</li>
|
175
|
+
|
176
|
+
|
177
|
+
</ul>
|
178
|
+
|
179
|
+
<h2>
|
180
|
+
Instance Method Summary
|
181
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
182
|
+
</h2>
|
183
|
+
|
184
|
+
<ul class="summary">
|
185
|
+
|
186
|
+
<li class="public ">
|
187
|
+
<span class="summary_signature">
|
188
|
+
|
189
|
+
<a href="#description-instance_method" title="#description (instance method)">- (Object) <strong>description</strong> </a>
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
</span>
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
<span class="summary_desc"><div class='inline'>
|
204
|
+
<p>provides a default description if not defined.</p>
|
205
|
+
</div></span>
|
206
|
+
|
207
|
+
</li>
|
208
|
+
|
209
|
+
|
210
|
+
<li class="public ">
|
211
|
+
<span class="summary_signature">
|
212
|
+
|
213
|
+
<a href="#justify_size-instance_method" title="#justify_size (instance method)">- (Object) <strong>justify_size</strong> </a>
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
</span>
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
<span class="summary_desc"><div class='inline'>
|
228
|
+
<p>returns the String size of the biggest command or option group.</p>
|
229
|
+
</div></span>
|
230
|
+
|
231
|
+
</li>
|
232
|
+
|
233
|
+
|
234
|
+
<li class="public ">
|
235
|
+
<span class="summary_signature">
|
236
|
+
|
237
|
+
<a href="#merge_options_aliases-instance_method" title="#merge_options_aliases (instance method)">- (Object) <strong>merge_options_aliases</strong> </a>
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
</span>
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
<span class="summary_desc"><div class='inline'>
|
252
|
+
<p>merge options and aliases "-m, --migrate, -h, --help", etc...</p>
|
253
|
+
</div></span>
|
254
|
+
|
255
|
+
</li>
|
256
|
+
|
257
|
+
|
258
|
+
</ul>
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<div id="class_method_details" class="method_details_list">
|
264
|
+
<h2>Class Method Details</h2>
|
265
|
+
|
266
|
+
|
267
|
+
<div class="method_details first">
|
268
|
+
<h3 class="signature first" id="alias_class-class_method">
|
269
|
+
|
270
|
+
+ (<tt>Object</tt>) <strong>alias_class</strong>(_alias)
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
</h3><div class="docstring">
|
277
|
+
<div class="discussion">
|
278
|
+
|
279
|
+
<p>creates an alias for the command.</p>
|
280
|
+
|
281
|
+
|
282
|
+
</div>
|
283
|
+
</div>
|
284
|
+
<div class="tags">
|
285
|
+
|
286
|
+
<div class="examples">
|
287
|
+
<p class="tag_title">Examples:</p>
|
288
|
+
|
289
|
+
|
290
|
+
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>Migrate</span> <span class='op'><</span> <span class='const'>Binder</span><span class='op'>::</span><span class='const'>Strategy</span>
|
291
|
+
<span class='comment'># def execute...
|
292
|
+
</span> <span class='comment'># def description...
|
293
|
+
</span> <span class='comment'>#
|
294
|
+
</span> <span class='id identifier rubyid_alias_class'>alias_class</span> <span class='symbol'>:M</span>
|
295
|
+
<span class='comment'># => This will create an alias :M class and this the existance of the corresponding "-m" command. (`arb --migrate` or `arb -m`, now)
|
296
|
+
</span><span class='kw'>end</span></code></pre>
|
297
|
+
|
298
|
+
</div>
|
299
|
+
|
300
|
+
|
301
|
+
</div><table class="source_code">
|
302
|
+
<tr>
|
303
|
+
<td>
|
304
|
+
<pre class="lines">
|
305
|
+
|
306
|
+
|
307
|
+
57
|
308
|
+
58
|
309
|
+
59</pre>
|
310
|
+
</td>
|
311
|
+
<td>
|
312
|
+
<pre class="code"><span class="info file"># File 'lib/cli/command.rb', line 57</span>
|
313
|
+
|
314
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_alias_class'>alias_class</span> <span class='id identifier rubyid__alias'>_alias</span>
|
315
|
+
<span class='const'>Binder</span><span class='op'>::</span><span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='id identifier rubyid__alias'>_alias</span><span class='comma'>,</span> <span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
316
|
+
<span class='kw'>end</span></pre>
|
317
|
+
</td>
|
318
|
+
</tr>
|
319
|
+
</table>
|
320
|
+
</div>
|
321
|
+
|
322
|
+
</div>
|
323
|
+
|
324
|
+
<div id="instance_method_details" class="method_details_list">
|
325
|
+
<h2>Instance Method Details</h2>
|
326
|
+
|
327
|
+
|
328
|
+
<div class="method_details first">
|
329
|
+
<h3 class="signature first" id="description-instance_method">
|
330
|
+
|
331
|
+
- (<tt>Object</tt>) <strong>description</strong>
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
</h3><div class="docstring">
|
338
|
+
<div class="discussion">
|
339
|
+
|
340
|
+
<p>provides a default description if not defined.</p>
|
341
|
+
|
342
|
+
|
343
|
+
</div>
|
344
|
+
</div>
|
345
|
+
<div class="tags">
|
346
|
+
|
347
|
+
<p class="tag_title">Returns:</p>
|
348
|
+
<ul class="return">
|
349
|
+
|
350
|
+
<li>
|
351
|
+
|
352
|
+
|
353
|
+
<span class='type'></span>
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
<div class='inline'>
|
359
|
+
<p>a "No description found" String.</p>
|
360
|
+
</div>
|
361
|
+
|
362
|
+
</li>
|
363
|
+
|
364
|
+
</ul>
|
365
|
+
|
366
|
+
</div><table class="source_code">
|
367
|
+
<tr>
|
368
|
+
<td>
|
369
|
+
<pre class="lines">
|
370
|
+
|
371
|
+
|
372
|
+
99</pre>
|
373
|
+
</td>
|
374
|
+
<td>
|
375
|
+
<pre class="code"><span class="info file"># File 'lib/cli/command.rb', line 99</span>
|
376
|
+
|
377
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_description'>description</span><span class='semicolon'>;</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>No description found</span><span class='tstring_end'>"</span></span> <span class='kw'>end</span></pre>
|
378
|
+
</td>
|
379
|
+
</tr>
|
380
|
+
</table>
|
381
|
+
</div>
|
382
|
+
|
383
|
+
<div class="method_details ">
|
384
|
+
<h3 class="signature " id="justify_size-instance_method">
|
385
|
+
|
386
|
+
- (<tt>Object</tt>) <strong>justify_size</strong>
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
</h3><div class="docstring">
|
393
|
+
<div class="discussion">
|
394
|
+
|
395
|
+
<p>returns the String size of the biggest command or option group.</p>
|
396
|
+
|
397
|
+
|
398
|
+
</div>
|
399
|
+
</div>
|
400
|
+
<div class="tags">
|
401
|
+
|
402
|
+
<p class="tag_title">Returns:</p>
|
403
|
+
<ul class="return">
|
404
|
+
|
405
|
+
<li>
|
406
|
+
|
407
|
+
|
408
|
+
<span class='type'></span>
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
<div class='inline'>
|
414
|
+
<p>a Numeric.</p>
|
415
|
+
</div>
|
416
|
+
|
417
|
+
</li>
|
418
|
+
|
419
|
+
</ul>
|
420
|
+
|
421
|
+
</div><table class="source_code">
|
422
|
+
<tr>
|
423
|
+
<td>
|
424
|
+
<pre class="lines">
|
425
|
+
|
426
|
+
|
427
|
+
64
|
428
|
+
65
|
429
|
+
66
|
430
|
+
67
|
431
|
+
68
|
432
|
+
69
|
433
|
+
70</pre>
|
434
|
+
</td>
|
435
|
+
<td>
|
436
|
+
<pre class="code"><span class="info file"># File 'lib/cli/command.rb', line 64</span>
|
437
|
+
|
438
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_justify_size'>justify_size</span>
|
439
|
+
<span class='kw'>if</span> <span class='ivar'>@options</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
440
|
+
<span class='const'>Binder</span><span class='op'>::</span><span class='const'>Strategy</span><span class='period'>.</span><span class='id identifier rubyid_subclasses'>subclasses</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:to_s</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_group_by'>group_by</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:size</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='op'>-</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Binder</span><span class='tstring_end'>"</span></span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
|
441
|
+
<span class='kw'>else</span>
|
442
|
+
<span class='ivar'>@options</span><span class='period'>.</span><span class='id identifier rubyid_group_by'>group_by</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:size</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
443
|
+
<span class='kw'>end</span>
|
444
|
+
<span class='kw'>end</span></pre>
|
445
|
+
</td>
|
446
|
+
</tr>
|
447
|
+
</table>
|
448
|
+
</div>
|
449
|
+
|
450
|
+
<div class="method_details ">
|
451
|
+
<h3 class="signature " id="merge_options_aliases-instance_method">
|
452
|
+
|
453
|
+
- (<tt>Object</tt>) <strong>merge_options_aliases</strong>
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
</h3><div class="docstring">
|
460
|
+
<div class="discussion">
|
461
|
+
|
462
|
+
<p>merge options and aliases "-m, --migrate, -h, --help", etc...</p>
|
463
|
+
|
464
|
+
<p>Uses an array of commands : ["-h" "-m", "--help", "--migrate"],</p>
|
465
|
+
|
466
|
+
<p>and concatenate the aliases : ["-m, --migrate", "-h, --help"]</p>
|
467
|
+
|
468
|
+
|
469
|
+
</div>
|
470
|
+
</div>
|
471
|
+
<div class="tags">
|
472
|
+
|
473
|
+
<p class="tag_title">Returns:</p>
|
474
|
+
<ul class="return">
|
475
|
+
|
476
|
+
<li>
|
477
|
+
|
478
|
+
|
479
|
+
<span class='type'></span>
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
<div class='inline'>
|
485
|
+
<p>an Array of merged aliases.</p>
|
486
|
+
</div>
|
487
|
+
|
488
|
+
</li>
|
489
|
+
|
490
|
+
</ul>
|
491
|
+
|
492
|
+
</div><table class="source_code">
|
493
|
+
<tr>
|
494
|
+
<td>
|
495
|
+
<pre class="lines">
|
496
|
+
|
497
|
+
|
498
|
+
79
|
499
|
+
80
|
500
|
+
81
|
501
|
+
82
|
502
|
+
83
|
503
|
+
84
|
504
|
+
85
|
505
|
+
86
|
506
|
+
87
|
507
|
+
88
|
508
|
+
89
|
509
|
+
90
|
510
|
+
91
|
511
|
+
92
|
512
|
+
93
|
513
|
+
94</pre>
|
514
|
+
</td>
|
515
|
+
<td>
|
516
|
+
<pre class="code"><span class="info file"># File 'lib/cli/command.rb', line 79</span>
|
517
|
+
|
518
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_merge_options_aliases'>merge_options_aliases</span>
|
519
|
+
<span class='id identifier rubyid_commands'>commands</span> <span class='op'>=</span> <span class='const'>Binder</span><span class='op'>::</span><span class='const'>Strategy</span><span class='period'>.</span><span class='id identifier rubyid_subclasses'>subclasses</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_command'>command</span><span class='op'>|</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Binder::</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span>
|
520
|
+
<span class='id identifier rubyid_previous_cmd'>previous_cmd</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span>
|
521
|
+
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
522
|
+
|
523
|
+
<span class='id identifier rubyid_commands'>commands</span><span class='period'>.</span><span class='id identifier rubyid_each_with_index'>each_with_index</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_cmd'>cmd</span><span class='comma'>,</span> <span class='id identifier rubyid_i'>i</span><span class='op'>|</span>
|
524
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_cmd'>cmd</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>1</span>
|
525
|
+
<span class='id identifier rubyid_previous_cmd'>previous_cmd</span> <span class='op'>=</span> <span class='id identifier rubyid_cmd'>cmd</span>
|
526
|
+
<span class='kw'>elsif</span> <span class='kw'>not</span> <span class='id identifier rubyid_previous_cmd'>previous_cmd</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
527
|
+
<span class='id identifier rubyid_cmd_prefixes'>cmd_prefixes</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_previous_cmd'>previous_cmd</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>1</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>-</span><span class='tstring_end'>'</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>--</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_cmd'>cmd</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>1</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>-</span><span class='tstring_end'>'</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>--</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
528
|
+
<span class='id identifier rubyid_options'>options</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cmd_prefixes'>cmd_prefixes</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rbrace'>}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_previous_cmd'>previous_cmd</span><span class='rbrace'>}</span><span class='tstring_content'>, </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cmd_prefixes'>cmd_prefixes</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='rbrace'>}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cmd'>cmd</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
529
|
+
<span class='id identifier rubyid_previous_cmd'>previous_cmd</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span>
|
530
|
+
<span class='kw'>end</span>
|
531
|
+
<span class='kw'>end</span>
|
532
|
+
<span class='ivar'>@options</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span>
|
533
|
+
<span class='kw'>end</span></pre>
|
534
|
+
</td>
|
535
|
+
</tr>
|
536
|
+
</table>
|
537
|
+
</div>
|
538
|
+
|
539
|
+
</div>
|
540
|
+
|
541
|
+
</div>
|
542
|
+
|
543
|
+
<div id="footer">
|
544
|
+
Generated on Thu Feb 21 02:06:17 2013 by
|
545
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
546
|
+
0.8.4.1 (ruby-1.9.3).
|
547
|
+
</div>
|
548
|
+
|
549
|
+
</body>
|
550
|
+
</html>
|