akaer 1.0.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2134 @@
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: Akaer::Application
8
+
9
+ &mdash; Documentation by YARD 0.8.2.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 (A)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../Akaer.html" title="Akaer (module)">Akaer</a></span></span>
36
+ &raquo;
37
+ <span class="title">Application</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: Akaer::Application
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">Akaer::Application</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/akaer/application.rb</dd>
98
+
99
+ </dl>
100
+ <div class="clear"></div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+ <p>The main Akaer application.</p>
105
+
106
+
107
+ </div>
108
+ </div>
109
+ <div class="tags">
110
+
111
+
112
+ </div>
113
+
114
+
115
+
116
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
117
+ <ul class="summary">
118
+
119
+ <li class="public ">
120
+ <span class="summary_signature">
121
+
122
+ <a href="#command-instance_method" title="#command (instance method)">- (Object) <strong>command</strong> </a>
123
+
124
+
125
+
126
+ </span>
127
+
128
+
129
+
130
+
131
+ <span class="note title readonly">readonly</span>
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+ <span class="summary_desc"><div class='inline'><p>The Mamertes command.</p>
142
+ </div></span>
143
+
144
+ </li>
145
+
146
+
147
+ <li class="public ">
148
+ <span class="summary_signature">
149
+
150
+ <a href="#config-instance_method" title="#config (instance method)">- (Object) <strong>config</strong> </a>
151
+
152
+
153
+
154
+ </span>
155
+
156
+
157
+
158
+
159
+ <span class="note title readonly">readonly</span>
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <span class="summary_desc"><div class='inline'><p>The <span class='object_link'><a href="Configuration.html" title="Akaer::Configuration (class)">Configuration</a></span> of this application.</p>
170
+ </div></span>
171
+
172
+ </li>
173
+
174
+
175
+ <li class="public ">
176
+ <span class="summary_signature">
177
+
178
+ <a href="#logger-instance_method" title="#logger (instance method)">- (Object) <strong>logger</strong> </a>
179
+
180
+
181
+
182
+ </span>
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+ <span class="summary_desc"><div class='inline'><p>The logger for this application.</p>
196
+ </div></span>
197
+
198
+ </li>
199
+
200
+
201
+ </ul>
202
+
203
+
204
+
205
+
206
+
207
+ <h2>
208
+ Class Method Summary
209
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
210
+ </h2>
211
+
212
+ <ul class="summary">
213
+
214
+ <li class="public ">
215
+ <span class="summary_signature">
216
+
217
+ <a href="#instance-class_method" title="instance (class method)">+ (Application) <strong>instance</strong>(command, force = false) </a>
218
+
219
+
220
+
221
+ </span>
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+ <span class="summary_desc"><div class='inline'><p>Returns a unique (singleton) instance of the application.</p>
232
+ </div></span>
233
+
234
+ </li>
235
+
236
+
237
+ </ul>
238
+
239
+ <h2>
240
+ Instance Method Summary
241
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
242
+ </h2>
243
+
244
+ <ul class="summary">
245
+
246
+ <li class="public ">
247
+ <span class="summary_signature">
248
+
249
+ <a href="#action_add-instance_method" title="#action_add (instance method)">- (Boolean) <strong>action_add</strong> </a>
250
+
251
+
252
+
253
+ </span>
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+ <span class="summary_desc"><div class='inline'><p>Adds aliases to the interface.</p>
264
+ </div></span>
265
+
266
+ </li>
267
+
268
+
269
+ <li class="public ">
270
+ <span class="summary_signature">
271
+
272
+ <a href="#action_install-instance_method" title="#action_install (instance method)">- (Boolean) <strong>action_install</strong> </a>
273
+
274
+
275
+
276
+ </span>
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+ <span class="summary_desc"><div class='inline'><p>Installs the application into the autolaunch.</p>
287
+ </div></span>
288
+
289
+ </li>
290
+
291
+
292
+ <li class="public ">
293
+ <span class="summary_signature">
294
+
295
+ <a href="#action_remove-instance_method" title="#action_remove (instance method)">- (Boolean) <strong>action_remove</strong> </a>
296
+
297
+
298
+
299
+ </span>
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+ <span class="summary_desc"><div class='inline'><p>Removes aliases from the interface.</p>
310
+ </div></span>
311
+
312
+ </li>
313
+
314
+
315
+ <li class="public ">
316
+ <span class="summary_signature">
317
+
318
+ <a href="#action_uninstall-instance_method" title="#action_uninstall (instance method)">- (Boolean) <strong>action_uninstall</strong> </a>
319
+
320
+
321
+
322
+ </span>
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+ <span class="summary_desc"><div class='inline'><p>Uninstalls the application from the autolaunch.</p>
333
+ </div></span>
334
+
335
+ </li>
336
+
337
+
338
+ <li class="public ">
339
+ <span class="summary_signature">
340
+
341
+ <a href="#compute_addresses-instance_method" title="#compute_addresses (instance method)">- (Array) <strong>compute_addresses</strong>(type = :all) </a>
342
+
343
+
344
+
345
+ </span>
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+ <span class="summary_desc"><div class='inline'><p>Computes the list of address to manage.</p>
356
+ </div></span>
357
+
358
+ </li>
359
+
360
+
361
+ <li class="public ">
362
+ <span class="summary_signature">
363
+
364
+ <a href="#execute_command-instance_method" title="#execute_command (instance method)">- (Boolean) <strong>execute_command</strong>(command) </a>
365
+
366
+
367
+
368
+ </span>
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+ <span class="summary_desc"><div class='inline'><p>Executes a shell command.</p>
379
+ </div></span>
380
+
381
+ </li>
382
+
383
+
384
+ <li class="public ">
385
+ <span class="summary_signature">
386
+
387
+ <a href="#get_logger-instance_method" title="#get_logger (instance method)">- (Logger) <strong>get_logger</strong> </a>
388
+
389
+
390
+
391
+ </span>
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+ <span class="summary_desc"><div class='inline'><p>Gets the current logger of the application.</p>
402
+ </div></span>
403
+
404
+ </li>
405
+
406
+
407
+ <li class="public ">
408
+ <span class="summary_signature">
409
+
410
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Application) <strong>initialize</strong>(command) </a>
411
+
412
+
413
+
414
+ </span>
415
+
416
+
417
+ <span class="note title constructor">constructor</span>
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+ <span class="summary_desc"><div class='inline'><p>Creates a new application.</p>
427
+ </div></span>
428
+
429
+ </li>
430
+
431
+
432
+ <li class="public ">
433
+ <span class="summary_signature">
434
+
435
+ <a href="#is_ipv4%3F-instance_method" title="#is_ipv4? (instance method)">- (Boolean) <strong>is_ipv4?</strong>(address) </a>
436
+
437
+
438
+
439
+ </span>
440
+
441
+
442
+
443
+
444
+
445
+
446
+
447
+
448
+
449
+ <span class="summary_desc"><div class='inline'><p>Checks if and address is a valid IPv4 address.</p>
450
+ </div></span>
451
+
452
+ </li>
453
+
454
+
455
+ <li class="public ">
456
+ <span class="summary_signature">
457
+
458
+ <a href="#is_ipv6%3F-instance_method" title="#is_ipv6? (instance method)">- (Boolean) <strong>is_ipv6?</strong>(address) </a>
459
+
460
+
461
+
462
+ </span>
463
+
464
+
465
+
466
+
467
+
468
+
469
+
470
+
471
+
472
+ <span class="summary_desc"><div class='inline'><p>Checks if and address is a valid IPv4 address.</p>
473
+ </div></span>
474
+
475
+ </li>
476
+
477
+
478
+ <li class="public ">
479
+ <span class="summary_signature">
480
+
481
+ <a href="#is_osx%3F-instance_method" title="#is_osx? (instance method)">- (Boolean) <strong>is_osx?</strong> </a>
482
+
483
+
484
+
485
+ </span>
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+ <span class="summary_desc"><div class='inline'><p>Checks if we are running on MacOS X.</p>
496
+ </div></span>
497
+
498
+ </li>
499
+
500
+
501
+ <li class="public ">
502
+ <span class="summary_signature">
503
+
504
+ <a href="#launch_agent_path-instance_method" title="#launch_agent_path (instance method)">- (String) <strong>launch_agent_path</strong>(name = &quot;it.cowtech.akaer&quot;) </a>
505
+
506
+
507
+
508
+ </span>
509
+
510
+
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+ <span class="summary_desc"><div class='inline'><p>Gets the path for the launch agent file.</p>
519
+ </div></span>
520
+
521
+ </li>
522
+
523
+
524
+ <li class="public ">
525
+ <span class="summary_signature">
526
+
527
+ <a href="#manage-instance_method" title="#manage (instance method)">- (Boolean) <strong>manage</strong>(type, address) </a>
528
+
529
+
530
+
531
+ </span>
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+ <span class="summary_desc"><div class='inline'><p>Adds or removes an alias from the interface.</p>
542
+ </div></span>
543
+
544
+ </li>
545
+
546
+
547
+ <li class="public ">
548
+ <span class="summary_signature">
549
+
550
+ <a href="#pad_number-instance_method" title="#pad_number (instance method)">- (String) <strong>pad_number</strong>(num, len = nil) </a>
551
+
552
+
553
+
554
+ </span>
555
+
556
+
557
+
558
+
559
+
560
+
561
+
562
+
563
+
564
+ <span class="summary_desc"><div class='inline'><p>Pads a number to make it print friendly.</p>
565
+ </div></span>
566
+
567
+ </li>
568
+
569
+
570
+ </ul>
571
+
572
+
573
+ <div id="constructor_details" class="method_details_list">
574
+ <h2>Constructor Details</h2>
575
+
576
+ <div class="method_details first">
577
+ <h3 class="signature first" id="initialize-instance_method">
578
+
579
+ - (<tt><span class='object_link'><a href="" title="Akaer::Application (class)">Application</a></span></tt>) <strong>initialize</strong>(command)
580
+
581
+
582
+
583
+
584
+
585
+ </h3><div class="docstring">
586
+ <div class="discussion">
587
+ <p>Creates a new application.</p>
588
+
589
+
590
+ </div>
591
+ </div>
592
+ <div class="tags">
593
+ <p class="tag_title">Parameters:</p>
594
+ <ul class="param">
595
+
596
+ <li>
597
+
598
+ <span class='name'>command</span>
599
+
600
+
601
+ <span class='type'>(<tt>Mamertes::Command</tt>)</span>
602
+
603
+
604
+
605
+ &mdash;
606
+ <div class='inline'><p>The current Mamertes command.</p>
607
+ </div>
608
+
609
+ </li>
610
+
611
+ </ul>
612
+
613
+
614
+ </div><table class="source_code">
615
+ <tr>
616
+ <td>
617
+ <pre class="lines">
618
+
619
+
620
+ 23
621
+ 24
622
+ 25
623
+ 26
624
+ 27
625
+ 28
626
+ 29
627
+ 30
628
+ 31
629
+ 32
630
+ 33
631
+ 34
632
+ 35
633
+ 36
634
+ 37
635
+ 38
636
+ 39
637
+ 40
638
+ 41
639
+ 42
640
+ 43
641
+ 44
642
+ 45
643
+ 46
644
+ 47
645
+ 48
646
+ 49
647
+ 50
648
+ 51
649
+ 52
650
+ 53
651
+ 54
652
+ 55
653
+ 56</pre>
654
+ </td>
655
+ <td>
656
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 23</span>
657
+
658
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
659
+ <span class='ivar'>@command</span> <span class='op'>=</span> <span class='id identifier rubyid_command'>command</span>
660
+ <span class='id identifier rubyid_application'>application</span> <span class='op'>=</span> <span class='ivar'>@command</span><span class='period'>.</span><span class='id identifier rubyid_application'>application</span>
661
+
662
+ <span class='comment'># Setup logger
663
+ </span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_start_time'>start_time</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span>
664
+ <span class='ivar'>@logger</span> <span class='op'>=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_get_real_file'>get_real_file</span><span class='lparen'>(</span><span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>log-file</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_default_file'>default_file</span><span class='comma'>,</span> <span class='const'>Logger</span><span class='op'>::</span><span class='const'>INFO</span><span class='rparen'>)</span>
665
+
666
+ <span class='comment'># Open configuration
667
+ </span> <span class='kw'>begin</span>
668
+ <span class='id identifier rubyid_overrides'>overrides</span> <span class='op'>=</span> <span class='lbrace'>{</span>
669
+ <span class='symbol'>:interface</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>interface</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span>
670
+ <span class='symbol'>:addresses</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>addresses</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span>
671
+ <span class='symbol'>:start_address</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>start-address</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span>
672
+ <span class='symbol'>:aliases</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>aliases</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span>
673
+ <span class='symbol'>:add_command</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>add-command</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span>
674
+ <span class='symbol'>:remove_command</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>remove-command</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span>
675
+ <span class='symbol'>:log_file</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>log-file</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span>
676
+ <span class='symbol'>:log_level</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>log-level</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span>
677
+ <span class='symbol'>:dry_run</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>dry-run</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span>
678
+ <span class='symbol'>:quiet</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>quiet</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
679
+ <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='rbrace'>}</span>
680
+
681
+ <span class='ivar'>@config</span> <span class='op'>=</span> <span class='const'>Akaer</span><span class='op'>::</span><span class='const'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>configuration</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_overrides'>overrides</span><span class='comma'>,</span> <span class='ivar'>@logger</span><span class='rparen'>)</span>
682
+
683
+ <span class='ivar'>@logger</span> <span class='op'>=</span> <span class='kw'>nil</span>
684
+ <span class='ivar'>@logger</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_get_logger'>get_logger</span>
685
+ <span class='kw'>rescue</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>InvalidConfiguration</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
686
+ <span class='ivar'>@logger</span> <span class='op'>?</span> <span class='ivar'>@logger</span><span class='period'>.</span><span class='id identifier rubyid_fatal'>fatal</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>STDERR</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_fatal'>fatal</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cannot log to {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_log_file'>log_file</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}. Exiting...</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
687
+ <span class='id identifier rubyid_raise'>raise</span> <span class='op'>::</span><span class='const'>SystemExit</span>
688
+ <span class='kw'>end</span>
689
+
690
+ <span class='kw'>self</span>
691
+ <span class='kw'>end</span></pre>
692
+ </td>
693
+ </tr>
694
+ </table>
695
+ </div>
696
+
697
+ </div>
698
+
699
+ <div id="instance_attr_details" class="attr_details">
700
+ <h2>Instance Attribute Details</h2>
701
+
702
+
703
+ <span id=""></span>
704
+ <div class="method_details first">
705
+ <h3 class="signature first" id="command-instance_method">
706
+
707
+ - (<tt>Object</tt>) <strong>command</strong> <span class="extras">(readonly)</span>
708
+
709
+
710
+
711
+
712
+
713
+ </h3><div class="docstring">
714
+ <div class="discussion">
715
+ <p>The Mamertes command.</p>
716
+
717
+
718
+ </div>
719
+ </div>
720
+ <div class="tags">
721
+
722
+
723
+ </div><table class="source_code">
724
+ <tr>
725
+ <td>
726
+ <pre class="lines">
727
+
728
+
729
+ 15
730
+ 16
731
+ 17</pre>
732
+ </td>
733
+ <td>
734
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 15</span>
735
+
736
+ <span class='kw'>def</span> <span class='id identifier rubyid_command'>command</span>
737
+ <span class='ivar'>@command</span>
738
+ <span class='kw'>end</span></pre>
739
+ </td>
740
+ </tr>
741
+ </table>
742
+ </div>
743
+
744
+
745
+ <span id=""></span>
746
+ <div class="method_details ">
747
+ <h3 class="signature " id="config-instance_method">
748
+
749
+ - (<tt>Object</tt>) <strong>config</strong> <span class="extras">(readonly)</span>
750
+
751
+
752
+
753
+
754
+
755
+ </h3><div class="docstring">
756
+ <div class="discussion">
757
+ <p>The <span class='object_link'><a href="Configuration.html" title="Akaer::Configuration (class)">Configuration</a></span> of this application.</p>
758
+
759
+
760
+ </div>
761
+ </div>
762
+ <div class="tags">
763
+
764
+
765
+ </div><table class="source_code">
766
+ <tr>
767
+ <td>
768
+ <pre class="lines">
769
+
770
+
771
+ 12
772
+ 13
773
+ 14</pre>
774
+ </td>
775
+ <td>
776
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 12</span>
777
+
778
+ <span class='kw'>def</span> <span class='id identifier rubyid_config'>config</span>
779
+ <span class='ivar'>@config</span>
780
+ <span class='kw'>end</span></pre>
781
+ </td>
782
+ </tr>
783
+ </table>
784
+ </div>
785
+
786
+
787
+ <span id="logger=-instance_method"></span>
788
+ <div class="method_details ">
789
+ <h3 class="signature " id="logger-instance_method">
790
+
791
+ - (<tt>Object</tt>) <strong>logger</strong>
792
+
793
+
794
+
795
+
796
+
797
+ </h3><div class="docstring">
798
+ <div class="discussion">
799
+ <p>The logger for this application.</p>
800
+
801
+
802
+ </div>
803
+ </div>
804
+ <div class="tags">
805
+
806
+
807
+ </div><table class="source_code">
808
+ <tr>
809
+ <td>
810
+ <pre class="lines">
811
+
812
+
813
+ 18
814
+ 19
815
+ 20</pre>
816
+ </td>
817
+ <td>
818
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 18</span>
819
+
820
+ <span class='kw'>def</span> <span class='id identifier rubyid_logger'>logger</span>
821
+ <span class='ivar'>@logger</span>
822
+ <span class='kw'>end</span></pre>
823
+ </td>
824
+ </tr>
825
+ </table>
826
+ </div>
827
+
828
+ </div>
829
+
830
+
831
+ <div id="class_method_details" class="method_details_list">
832
+ <h2>Class Method Details</h2>
833
+
834
+
835
+ <div class="method_details first">
836
+ <h3 class="signature first" id="instance-class_method">
837
+
838
+ + (<tt><span class='object_link'><a href="" title="Akaer::Application (class)">Application</a></span></tt>) <strong>instance</strong>(command, force = false)
839
+
840
+
841
+
842
+
843
+
844
+ </h3><div class="docstring">
845
+ <div class="discussion">
846
+ <p>Returns a unique (singleton) instance of the application.</p>
847
+
848
+
849
+ </div>
850
+ </div>
851
+ <div class="tags">
852
+ <p class="tag_title">Parameters:</p>
853
+ <ul class="param">
854
+
855
+ <li>
856
+
857
+ <span class='name'>command</span>
858
+
859
+
860
+ <span class='type'>(<tt>Mamertes::Command</tt>)</span>
861
+
862
+
863
+
864
+ &mdash;
865
+ <div class='inline'><p>The current Mamertes command.</p>
866
+ </div>
867
+
868
+ </li>
869
+
870
+ <li>
871
+
872
+ <span class='name'>force</span>
873
+
874
+
875
+ <span class='type'>(<tt>Boolean</tt>)</span>
876
+
877
+
878
+ <em class="default">(defaults to: <tt>false</tt>)</em>
879
+
880
+
881
+ &mdash;
882
+ <div class='inline'><p>If to force recreation of the instance.</p>
883
+ </div>
884
+
885
+ </li>
886
+
887
+ </ul>
888
+
889
+ <p class="tag_title">Returns:</p>
890
+ <ul class="return">
891
+
892
+ <li>
893
+
894
+
895
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Akaer::Application (class)">Application</a></span></tt>)</span>
896
+
897
+
898
+
899
+ &mdash;
900
+ <div class='inline'><p>The unique (singleton) instance of the application.</p>
901
+ </div>
902
+
903
+ </li>
904
+
905
+ </ul>
906
+
907
+ </div><table class="source_code">
908
+ <tr>
909
+ <td>
910
+ <pre class="lines">
911
+
912
+
913
+ 303
914
+ 304
915
+ 305
916
+ 306</pre>
917
+ </td>
918
+ <td>
919
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 303</span>
920
+
921
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_force'>force</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
922
+ <span class='ivar'>@instance</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_force'>force</span>
923
+ <span class='ivar'>@instance</span> <span class='op'>||=</span> <span class='const'>Akaer</span><span class='op'>::</span><span class='const'>Application</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
924
+ <span class='kw'>end</span></pre>
925
+ </td>
926
+ </tr>
927
+ </table>
928
+ </div>
929
+
930
+ </div>
931
+
932
+ <div id="instance_method_details" class="method_details_list">
933
+ <h2>Instance Method Details</h2>
934
+
935
+
936
+ <div class="method_details first">
937
+ <h3 class="signature first" id="action_add-instance_method">
938
+
939
+ - (<tt>Boolean</tt>) <strong>action_add</strong>
940
+
941
+
942
+
943
+
944
+
945
+ </h3><div class="docstring">
946
+ <div class="discussion">
947
+ <p>Adds aliases to the interface.</p>
948
+
949
+
950
+ </div>
951
+ </div>
952
+ <div class="tags">
953
+
954
+ <p class="tag_title">Returns:</p>
955
+ <ul class="return">
956
+
957
+ <li>
958
+
959
+
960
+ <span class='type'>(<tt>Boolean</tt>)</span>
961
+
962
+
963
+
964
+ &mdash;
965
+ <div class='inline'><p><code>true</code> if action succedeed, <code>false</code> otherwise.</p>
966
+ </div>
967
+
968
+ </li>
969
+
970
+ </ul>
971
+
972
+ </div><table class="source_code">
973
+ <tr>
974
+ <td>
975
+ <pre class="lines">
976
+
977
+
978
+ 197
979
+ 198
980
+ 199
981
+ 200
982
+ 201
983
+ 202
984
+ 203
985
+ 204
986
+ 205
987
+ 206
988
+ 207
989
+ 208</pre>
990
+ </td>
991
+ <td>
992
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 197</span>
993
+
994
+ <span class='kw'>def</span> <span class='id identifier rubyid_action_add'>action_add</span>
995
+ <span class='id identifier rubyid_addresses'>addresses</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_compute_addresses'>compute_addresses</span>
996
+
997
+ <span class='kw'>if</span> <span class='id identifier rubyid_addresses'>addresses</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='kw'>then</span>
998
+ <span class='comment'># Now, for every address, call the command
999
+ </span> <span class='id identifier rubyid_addresses'>addresses</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_address'>address</span><span class='op'>|</span>
1000
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_manage'>manage</span><span class='lparen'>(</span><span class='symbol'>:add</span><span class='comma'>,</span> <span class='id identifier rubyid_address'>address</span><span class='rparen'>)</span>
1001
+ <span class='rbrace'>}</span>
1002
+ <span class='kw'>else</span>
1003
+ <span class='ivar'>@logger</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>No valid addresses to add to the interface found.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
1004
+ <span class='kw'>end</span>
1005
+ <span class='kw'>end</span></pre>
1006
+ </td>
1007
+ </tr>
1008
+ </table>
1009
+ </div>
1010
+
1011
+ <div class="method_details ">
1012
+ <h3 class="signature " id="action_install-instance_method">
1013
+
1014
+ - (<tt>Boolean</tt>) <strong>action_install</strong>
1015
+
1016
+
1017
+
1018
+
1019
+
1020
+ </h3><div class="docstring">
1021
+ <div class="discussion">
1022
+ <p>Installs the application into the autolaunch.</p>
1023
+
1024
+
1025
+ </div>
1026
+ </div>
1027
+ <div class="tags">
1028
+
1029
+ <p class="tag_title">Returns:</p>
1030
+ <ul class="return">
1031
+
1032
+ <li>
1033
+
1034
+
1035
+ <span class='type'>(<tt>Boolean</tt>)</span>
1036
+
1037
+
1038
+
1039
+ &mdash;
1040
+ <div class='inline'><p><code>true</code> if action succedeed, <code>false</code> otherwise.</p>
1041
+ </div>
1042
+
1043
+ </li>
1044
+
1045
+ </ul>
1046
+
1047
+ </div><table class="source_code">
1048
+ <tr>
1049
+ <td>
1050
+ <pre class="lines">
1051
+
1052
+
1053
+ 229
1054
+ 230
1055
+ 231
1056
+ 232
1057
+ 233
1058
+ 234
1059
+ 235
1060
+ 236
1061
+ 237
1062
+ 238
1063
+ 239
1064
+ 240
1065
+ 241
1066
+ 242
1067
+ 243
1068
+ 244
1069
+ 245
1070
+ 246
1071
+ 247
1072
+ 248
1073
+ 249
1074
+ 250
1075
+ 251
1076
+ 252
1077
+ 253
1078
+ 254
1079
+ 255
1080
+ 256
1081
+ 257
1082
+ 258
1083
+ 259
1084
+ 260
1085
+ 261
1086
+ 262
1087
+ 263
1088
+ 264</pre>
1089
+ </td>
1090
+ <td>
1091
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 229</span>
1092
+
1093
+ <span class='kw'>def</span> <span class='id identifier rubyid_action_install'>action_install</span>
1094
+ <span class='id identifier rubyid_logger'>logger</span> <span class='op'>=</span> <span class='id identifier rubyid_get_logger'>get_logger</span>
1095
+
1096
+ <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_is_osx?'>is_osx?</span> <span class='kw'>then</span>
1097
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_fatal'>fatal</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Install akaer on autolaunch is only available on MacOSX.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
1098
+ <span class='kw'>return</span> <span class='kw'>false</span>
1099
+ <span class='kw'>end</span>
1100
+
1101
+ <span class='id identifier rubyid_launch_agent'>launch_agent</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_launch_agent_path'>launch_agent_path</span>
1102
+
1103
+ <span class='kw'>begin</span>
1104
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Creating the launch agent in {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_launch_agent'>launch_agent</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} ...</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
1105
+
1106
+ <span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='gvar'>$ARGV</span> <span class='op'>?</span> <span class='gvar'>$ARGV</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='gvar'>$ARGV</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>-</span> <span class='int'>1</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
1107
+
1108
+ <span class='id identifier rubyid_plist'>plist</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>KeepAlive</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Label</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>it.cowtech.akaer</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Program</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='lparen'>(</span><span class='op'>::</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_pwd'>pwd</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='gvar'>$0</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>ProgramArguments</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>RunAtLoad</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='rbrace'>}</span>
1109
+ <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_launch_agent'>launch_agent</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>w</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span>
1110
+ <span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_plist'>plist</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span><span class='rparen'>)</span>
1111
+ <span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_flush'>flush</span>
1112
+ <span class='rbrace'>}</span>
1113
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_execute_command'>execute_command</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>plutil -convert binary1 \&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_launch_agent'>launch_agent</span><span class='rbrace'>}</span><span class='tstring_content'>\&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1114
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1115
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cannot create the launch agent.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
1116
+ <span class='kw'>return</span> <span class='kw'>false</span>
1117
+ <span class='kw'>end</span>
1118
+
1119
+ <span class='kw'>begin</span>
1120
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Loading the launch agent ...</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
1121
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_execute_command'>execute_command</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>launchctl load -w \&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_launch_agent'>launch_agent</span><span class='rbrace'>}</span><span class='tstring_content'>\&quot; &gt; /dev/null 2&gt;&amp;1</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1122
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1123
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cannot load the launch agent.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
1124
+ <span class='kw'>return</span> <span class='kw'>false</span>
1125
+ <span class='kw'>end</span>
1126
+
1127
+ <span class='kw'>true</span>
1128
+ <span class='kw'>end</span></pre>
1129
+ </td>
1130
+ </tr>
1131
+ </table>
1132
+ </div>
1133
+
1134
+ <div class="method_details ">
1135
+ <h3 class="signature " id="action_remove-instance_method">
1136
+
1137
+ - (<tt>Boolean</tt>) <strong>action_remove</strong>
1138
+
1139
+
1140
+
1141
+
1142
+
1143
+ </h3><div class="docstring">
1144
+ <div class="discussion">
1145
+ <p>Removes aliases from the interface.</p>
1146
+
1147
+
1148
+ </div>
1149
+ </div>
1150
+ <div class="tags">
1151
+
1152
+ <p class="tag_title">Returns:</p>
1153
+ <ul class="return">
1154
+
1155
+ <li>
1156
+
1157
+
1158
+ <span class='type'>(<tt>Boolean</tt>)</span>
1159
+
1160
+
1161
+
1162
+ &mdash;
1163
+ <div class='inline'><p><code>true</code> if action succedeed, <code>false</code> otherwise.</p>
1164
+ </div>
1165
+
1166
+ </li>
1167
+
1168
+ </ul>
1169
+
1170
+ </div><table class="source_code">
1171
+ <tr>
1172
+ <td>
1173
+ <pre class="lines">
1174
+
1175
+
1176
+ 213
1177
+ 214
1178
+ 215
1179
+ 216
1180
+ 217
1181
+ 218
1182
+ 219
1183
+ 220
1184
+ 221
1185
+ 222
1186
+ 223
1187
+ 224</pre>
1188
+ </td>
1189
+ <td>
1190
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 213</span>
1191
+
1192
+ <span class='kw'>def</span> <span class='id identifier rubyid_action_remove'>action_remove</span>
1193
+ <span class='id identifier rubyid_addresses'>addresses</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_compute_addresses'>compute_addresses</span>
1194
+
1195
+ <span class='kw'>if</span> <span class='id identifier rubyid_addresses'>addresses</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='kw'>then</span>
1196
+ <span class='comment'># Now, for every address, call the command
1197
+ </span> <span class='id identifier rubyid_addresses'>addresses</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_address'>address</span><span class='op'>|</span>
1198
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_manage'>manage</span><span class='lparen'>(</span><span class='symbol'>:remove</span><span class='comma'>,</span> <span class='id identifier rubyid_address'>address</span><span class='rparen'>)</span>
1199
+ <span class='rbrace'>}</span>
1200
+ <span class='kw'>else</span>
1201
+ <span class='ivar'>@logger</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>No valid addresses to remove from the interface found.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
1202
+ <span class='kw'>end</span>
1203
+ <span class='kw'>end</span></pre>
1204
+ </td>
1205
+ </tr>
1206
+ </table>
1207
+ </div>
1208
+
1209
+ <div class="method_details ">
1210
+ <h3 class="signature " id="action_uninstall-instance_method">
1211
+
1212
+ - (<tt>Boolean</tt>) <strong>action_uninstall</strong>
1213
+
1214
+
1215
+
1216
+
1217
+
1218
+ </h3><div class="docstring">
1219
+ <div class="discussion">
1220
+ <p>Uninstalls the application from the autolaunch.</p>
1221
+
1222
+
1223
+ </div>
1224
+ </div>
1225
+ <div class="tags">
1226
+
1227
+ <p class="tag_title">Returns:</p>
1228
+ <ul class="return">
1229
+
1230
+ <li>
1231
+
1232
+
1233
+ <span class='type'>(<tt>Boolean</tt>)</span>
1234
+
1235
+
1236
+
1237
+ &mdash;
1238
+ <div class='inline'><p><code>true</code> if action succedeed, <code>false</code> otherwise.</p>
1239
+ </div>
1240
+
1241
+ </li>
1242
+
1243
+ </ul>
1244
+
1245
+ </div><table class="source_code">
1246
+ <tr>
1247
+ <td>
1248
+ <pre class="lines">
1249
+
1250
+
1251
+ 269
1252
+ 270
1253
+ 271
1254
+ 272
1255
+ 273
1256
+ 274
1257
+ 275
1258
+ 276
1259
+ 277
1260
+ 278
1261
+ 279
1262
+ 280
1263
+ 281
1264
+ 282
1265
+ 283
1266
+ 284
1267
+ 285
1268
+ 286
1269
+ 287
1270
+ 288
1271
+ 289
1272
+ 290
1273
+ 291
1274
+ 292
1275
+ 293
1276
+ 294
1277
+ 295
1278
+ 296</pre>
1279
+ </td>
1280
+ <td>
1281
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 269</span>
1282
+
1283
+ <span class='kw'>def</span> <span class='id identifier rubyid_action_uninstall'>action_uninstall</span>
1284
+ <span class='id identifier rubyid_logger'>logger</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_get_logger'>get_logger</span>
1285
+
1286
+ <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_is_osx?'>is_osx?</span> <span class='kw'>then</span>
1287
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_fatal'>fatal</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Install akaer on autolaunch is only available on MacOSX.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
1288
+ <span class='kw'>return</span> <span class='kw'>false</span>
1289
+ <span class='kw'>end</span>
1290
+
1291
+ <span class='id identifier rubyid_launch_agent'>launch_agent</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_launch_agent_path'>launch_agent_path</span>
1292
+
1293
+ <span class='comment'># Unload the launch agent.
1294
+ </span> <span class='kw'>begin</span>
1295
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_execute_command'>execute_command</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>launchctl unload -w \&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_launch_agent'>launch_agent</span><span class='rbrace'>}</span><span class='tstring_content'>\&quot; &gt; /dev/null 2&gt;&amp;1</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1296
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1297
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cannot unload the launch agent.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
1298
+ <span class='kw'>end</span>
1299
+
1300
+ <span class='comment'># Delete the launch agent.
1301
+ </span> <span class='kw'>begin</span>
1302
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Deleting the launch agent </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_launch_agent'>launch_agent</span><span class='rbrace'>}</span><span class='tstring_content'> ...</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1303
+ <span class='op'>::</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_launch_agent'>launch_agent</span><span class='rparen'>)</span>
1304
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1305
+ <span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cannot delete the launch agent.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
1306
+ <span class='kw'>return</span> <span class='kw'>false</span>
1307
+ <span class='kw'>end</span>
1308
+
1309
+ <span class='kw'>true</span>
1310
+ <span class='kw'>end</span></pre>
1311
+ </td>
1312
+ </tr>
1313
+ </table>
1314
+ </div>
1315
+
1316
+ <div class="method_details ">
1317
+ <h3 class="signature " id="compute_addresses-instance_method">
1318
+
1319
+ - (<tt>Array</tt>) <strong>compute_addresses</strong>(type = :all)
1320
+
1321
+
1322
+
1323
+
1324
+
1325
+ </h3><div class="docstring">
1326
+ <div class="discussion">
1327
+ <p>Computes the list of address to manage.</p>
1328
+
1329
+
1330
+ </div>
1331
+ </div>
1332
+ <div class="tags">
1333
+ <p class="tag_title">Parameters:</p>
1334
+ <ul class="param">
1335
+
1336
+ <li>
1337
+
1338
+ <span class='name'>type</span>
1339
+
1340
+
1341
+ <span class='type'>(<tt>Symbol</tt>)</span>
1342
+
1343
+
1344
+ <em class="default">(defaults to: <tt>:all</tt>)</em>
1345
+
1346
+
1347
+ &mdash;
1348
+ <div class='inline'><p>The type of addresses to consider. Valid values are <code>:ipv4</code>, <code>:ipv6</code>, otherwise all addresses are considered.</p>
1349
+ </div>
1350
+
1351
+ </li>
1352
+
1353
+ </ul>
1354
+
1355
+ <p class="tag_title">Returns:</p>
1356
+ <ul class="return">
1357
+
1358
+ <li>
1359
+
1360
+
1361
+ <span class='type'>(<tt>Array</tt>)</span>
1362
+
1363
+
1364
+
1365
+ &mdash;
1366
+ <div class='inline'><p>The list of addresses to add or remove from the interface.</p>
1367
+ </div>
1368
+
1369
+ </li>
1370
+
1371
+ </ul>
1372
+
1373
+ </div><table class="source_code">
1374
+ <tr>
1375
+ <td>
1376
+ <pre class="lines">
1377
+
1378
+
1379
+ 135
1380
+ 136
1381
+ 137
1382
+ 138
1383
+ 139
1384
+ 140
1385
+ 141
1386
+ 142
1387
+ 143
1388
+ 144
1389
+ 145
1390
+ 146
1391
+ 147
1392
+ 148
1393
+ 149
1394
+ 150
1395
+ 151
1396
+ 152
1397
+ 153
1398
+ 154
1399
+ 155
1400
+ 156
1401
+ 157
1402
+ 158
1403
+ 159
1404
+ 160</pre>
1405
+ </td>
1406
+ <td>
1407
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 135</span>
1408
+
1409
+ <span class='kw'>def</span> <span class='id identifier rubyid_compute_addresses'>compute_addresses</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:all</span><span class='rparen'>)</span>
1410
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
1411
+
1412
+ <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_addresses'>addresses</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='comment'># We have an explicit list
1413
+ </span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_addresses'>addresses</span>
1414
+
1415
+ <span class='comment'># Now filter the addresses
1416
+ </span> <span class='id identifier rubyid_filters'>filters</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span> <span class='op'>!=</span> <span class='symbol'>:ipv6</span> <span class='op'>?</span> <span class='symbol'>:ipv4</span> <span class='op'>:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>!=</span> <span class='symbol'>:ipv4</span> <span class='op'>?</span> <span class='symbol'>:ipv6</span> <span class='op'>:</span> <span class='kw'>nil</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
1417
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_address'>address</span><span class='op'>|</span>
1418
+ <span class='id identifier rubyid_filters'>filters</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_filter'>filter</span><span class='op'>|</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>is_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_filter'>filter</span><span class='rbrace'>}</span><span class='tstring_content'>?</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_address'>address</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
1419
+ <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
1420
+ <span class='kw'>else</span>
1421
+ <span class='kw'>begin</span>
1422
+ <span class='id identifier rubyid_ip'>ip</span> <span class='op'>=</span> <span class='const'>IPAddr</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_start_address'>start_address</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
1423
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='symbol'>:ipv4</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_ip'>ip</span><span class='period'>.</span><span class='id identifier rubyid_ipv4?'>ipv4?</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='symbol'>:ipv6</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_ip'>ip</span><span class='period'>.</span><span class='id identifier rubyid_ipv6?'>ipv6?</span><span class='rparen'>)</span>
1424
+
1425
+ <span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_aliases'>aliases</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>?</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_aliases'>aliases</span> <span class='op'>:</span> <span class='int'>5</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span> <span class='kw'>do</span>
1426
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_ip'>ip</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
1427
+ <span class='id identifier rubyid_ip'>ip</span> <span class='op'>=</span> <span class='id identifier rubyid_ip'>ip</span><span class='period'>.</span><span class='id identifier rubyid_succ'>succ</span>
1428
+ <span class='kw'>end</span>
1429
+ <span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
1430
+ <span class='kw'>end</span>
1431
+ <span class='kw'>end</span>
1432
+
1433
+ <span class='id identifier rubyid_rv'>rv</span>
1434
+ <span class='kw'>end</span></pre>
1435
+ </td>
1436
+ </tr>
1437
+ </table>
1438
+ </div>
1439
+
1440
+ <div class="method_details ">
1441
+ <h3 class="signature " id="execute_command-instance_method">
1442
+
1443
+ - (<tt>Boolean</tt>) <strong>execute_command</strong>(command)
1444
+
1445
+
1446
+
1447
+
1448
+
1449
+ </h3><div class="docstring">
1450
+ <div class="discussion">
1451
+ <p>Executes a shell command.</p>
1452
+
1453
+
1454
+ </div>
1455
+ </div>
1456
+ <div class="tags">
1457
+ <p class="tag_title">Parameters:</p>
1458
+ <ul class="param">
1459
+
1460
+ <li>
1461
+
1462
+ <span class='name'>command</span>
1463
+
1464
+
1465
+ <span class='type'>(<tt>String</tt>)</span>
1466
+
1467
+
1468
+
1469
+ &mdash;
1470
+ <div class='inline'><p>The command to execute.</p>
1471
+ </div>
1472
+
1473
+ </li>
1474
+
1475
+ </ul>
1476
+
1477
+ <p class="tag_title">Returns:</p>
1478
+ <ul class="return">
1479
+
1480
+ <li>
1481
+
1482
+
1483
+ <span class='type'>(<tt>Boolean</tt>)</span>
1484
+
1485
+
1486
+
1487
+ &mdash;
1488
+ <div class='inline'><p><code>true</code> if command succeeded, <code>false</code> otherwise.</p>
1489
+ </div>
1490
+
1491
+ </li>
1492
+
1493
+ </ul>
1494
+
1495
+ </div><table class="source_code">
1496
+ <tr>
1497
+ <td>
1498
+ <pre class="lines">
1499
+
1500
+
1501
+ 127
1502
+ 128
1503
+ 129</pre>
1504
+ </td>
1505
+ <td>
1506
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 127</span>
1507
+
1508
+ <span class='kw'>def</span> <span class='id identifier rubyid_execute_command'>execute_command</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
1509
+ <span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_system'>system</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
1510
+ <span class='kw'>end</span></pre>
1511
+ </td>
1512
+ </tr>
1513
+ </table>
1514
+ </div>
1515
+
1516
+ <div class="method_details ">
1517
+ <h3 class="signature " id="get_logger-instance_method">
1518
+
1519
+ - (<tt>Logger</tt>) <strong>get_logger</strong>
1520
+
1521
+
1522
+
1523
+
1524
+
1525
+ </h3><div class="docstring">
1526
+ <div class="discussion">
1527
+ <p>Gets the current logger of the application.</p>
1528
+
1529
+
1530
+ </div>
1531
+ </div>
1532
+ <div class="tags">
1533
+
1534
+ <p class="tag_title">Returns:</p>
1535
+ <ul class="return">
1536
+
1537
+ <li>
1538
+
1539
+
1540
+ <span class='type'>(<tt>Logger</tt>)</span>
1541
+
1542
+
1543
+
1544
+ &mdash;
1545
+ <div class='inline'><p>The current logger of the application.</p>
1546
+ </div>
1547
+
1548
+ </li>
1549
+
1550
+ </ul>
1551
+
1552
+ </div><table class="source_code">
1553
+ <tr>
1554
+ <td>
1555
+ <pre class="lines">
1556
+
1557
+
1558
+ 111
1559
+ 112
1560
+ 113</pre>
1561
+ </td>
1562
+ <td>
1563
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 111</span>
1564
+
1565
+ <span class='kw'>def</span> <span class='id identifier rubyid_get_logger'>get_logger</span>
1566
+ <span class='ivar'>@logger</span> <span class='op'>||=</span> <span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='const'>Bovem</span><span class='op'>::</span><span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_default_file'>default_file</span><span class='comma'>,</span> <span class='ivar'>@config</span><span class='period'>.</span><span class='id identifier rubyid_log_level'>log_level</span><span class='comma'>,</span> <span class='ivar'>@log_formatter</span><span class='rparen'>)</span>
1567
+ <span class='kw'>end</span></pre>
1568
+ </td>
1569
+ </tr>
1570
+ </table>
1571
+ </div>
1572
+
1573
+ <div class="method_details ">
1574
+ <h3 class="signature " id="is_ipv4?-instance_method">
1575
+
1576
+ - (<tt>Boolean</tt>) <strong>is_ipv4?</strong>(address)
1577
+
1578
+
1579
+
1580
+
1581
+
1582
+ </h3><div class="docstring">
1583
+ <div class="discussion">
1584
+ <p>Checks if and address is a valid IPv4 address.</p>
1585
+
1586
+
1587
+ </div>
1588
+ </div>
1589
+ <div class="tags">
1590
+ <p class="tag_title">Parameters:</p>
1591
+ <ul class="param">
1592
+
1593
+ <li>
1594
+
1595
+ <span class='name'>address</span>
1596
+
1597
+
1598
+ <span class='type'>(<tt>String</tt>)</span>
1599
+
1600
+
1601
+
1602
+ &mdash;
1603
+ <div class='inline'><p>The address to check.</p>
1604
+ </div>
1605
+
1606
+ </li>
1607
+
1608
+ </ul>
1609
+
1610
+ <p class="tag_title">Returns:</p>
1611
+ <ul class="return">
1612
+
1613
+ <li>
1614
+
1615
+
1616
+ <span class='type'>(<tt>Boolean</tt>)</span>
1617
+
1618
+
1619
+
1620
+ &mdash;
1621
+ <div class='inline'><p><code>true</code> if the address is a valid IPv4 address, <code>false</code> otherwise.</p>
1622
+ </div>
1623
+
1624
+ </li>
1625
+
1626
+ </ul>
1627
+
1628
+ </div><table class="source_code">
1629
+ <tr>
1630
+ <td>
1631
+ <pre class="lines">
1632
+
1633
+
1634
+ 70
1635
+ 71
1636
+ 72
1637
+ 73
1638
+ 74
1639
+ 75</pre>
1640
+ </td>
1641
+ <td>
1642
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 70</span>
1643
+
1644
+ <span class='kw'>def</span> <span class='id identifier rubyid_is_ipv4?'>is_ipv4?</span><span class='lparen'>(</span><span class='id identifier rubyid_address'>address</span><span class='rparen'>)</span>
1645
+ <span class='id identifier rubyid_address'>address</span> <span class='op'>=</span> <span class='id identifier rubyid_address'>address</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1646
+
1647
+ <span class='id identifier rubyid_mo'>mo</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\Z</span><span class='regexp_end'>/</span></span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_address'>address</span><span class='rparen'>)</span>
1648
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_mo'>mo</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_mo'>mo</span><span class='period'>.</span><span class='id identifier rubyid_captures'>captures</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>&lt;</span> <span class='int'>256</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>true</span> <span class='op'>:</span> <span class='kw'>false</span>
1649
+ <span class='kw'>end</span></pre>
1650
+ </td>
1651
+ </tr>
1652
+ </table>
1653
+ </div>
1654
+
1655
+ <div class="method_details ">
1656
+ <h3 class="signature " id="is_ipv6?-instance_method">
1657
+
1658
+ - (<tt>Boolean</tt>) <strong>is_ipv6?</strong>(address)
1659
+
1660
+
1661
+
1662
+
1663
+
1664
+ </h3><div class="docstring">
1665
+ <div class="discussion">
1666
+ <p>Checks if and address is a valid IPv4 address.</p>
1667
+
1668
+
1669
+ </div>
1670
+ </div>
1671
+ <div class="tags">
1672
+ <p class="tag_title">Parameters:</p>
1673
+ <ul class="param">
1674
+
1675
+ <li>
1676
+
1677
+ <span class='name'>address</span>
1678
+
1679
+
1680
+ <span class='type'>(<tt>String</tt>)</span>
1681
+
1682
+
1683
+
1684
+ &mdash;
1685
+ <div class='inline'><p>The address to check.</p>
1686
+ </div>
1687
+
1688
+ </li>
1689
+
1690
+ </ul>
1691
+
1692
+ <p class="tag_title">Returns:</p>
1693
+ <ul class="return">
1694
+
1695
+ <li>
1696
+
1697
+
1698
+ <span class='type'>(<tt>Boolean</tt>)</span>
1699
+
1700
+
1701
+
1702
+ &mdash;
1703
+ <div class='inline'><p><code>true</code> if the address is a valid IPv4 address, <code>false</code> otherwise.</p>
1704
+ </div>
1705
+
1706
+ </li>
1707
+
1708
+ </ul>
1709
+
1710
+ </div><table class="source_code">
1711
+ <tr>
1712
+ <td>
1713
+ <pre class="lines">
1714
+
1715
+
1716
+ 81
1717
+ 82
1718
+ 83
1719
+ 84
1720
+ 85
1721
+ 86
1722
+ 87
1723
+ 88
1724
+ 89
1725
+ 90
1726
+ 91
1727
+ 92
1728
+ 93
1729
+ 94
1730
+ 95
1731
+ 96</pre>
1732
+ </td>
1733
+ <td>
1734
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 81</span>
1735
+
1736
+ <span class='kw'>def</span> <span class='id identifier rubyid_is_ipv6?'>is_ipv6?</span><span class='lparen'>(</span><span class='id identifier rubyid_address'>address</span><span class='rparen'>)</span>
1737
+ <span class='id identifier rubyid_address'>address</span> <span class='op'>=</span> <span class='id identifier rubyid_address'>address</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1738
+
1739
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:valid</span><span class='rparen'>)</span> <span class='kw'>do</span>
1740
+ <span class='comment'># IPv6 (normal)
1741
+ </span> <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:valid</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*\Z</span><span class='regexp_end'>/</span></span> <span class='op'>=~</span> <span class='id identifier rubyid_address'>address</span>
1742
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:valid</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*)?\Z</span><span class='regexp_end'>/</span></span> <span class='op'>=~</span> <span class='id identifier rubyid_address'>address</span>
1743
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:valid</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\A::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*)?\Z</span><span class='regexp_end'>/</span></span> <span class='op'>=~</span> <span class='id identifier rubyid_address'>address</span>
1744
+ <span class='comment'># IPv6 (IPv4 compat)
1745
+ </span> <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:valid</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:</span><span class='regexp_end'>/</span></span> <span class='op'>=~</span> <span class='id identifier rubyid_address'>address</span> <span class='op'>&amp;&amp;</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_is_ipv4?'>is_ipv4?</span><span class='lparen'>(</span><span class='backref'>$'</span><span class='rparen'>)</span>
1746
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:valid</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?</span><span class='regexp_end'>/</span></span> <span class='op'>=~</span> <span class='id identifier rubyid_address'>address</span> <span class='op'>&amp;&amp;</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_is_ipv4?'>is_ipv4?</span><span class='lparen'>(</span><span class='backref'>$'</span><span class='rparen'>)</span>
1747
+ <span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:valid</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\A::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?</span><span class='regexp_end'>/</span></span> <span class='op'>=~</span> <span class='id identifier rubyid_address'>address</span> <span class='op'>&amp;&amp;</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_is_ipv4?'>is_ipv4?</span><span class='lparen'>(</span><span class='backref'>$'</span><span class='rparen'>)</span>
1748
+
1749
+ <span class='kw'>false</span>
1750
+ <span class='kw'>end</span>
1751
+ <span class='kw'>end</span></pre>
1752
+ </td>
1753
+ </tr>
1754
+ </table>
1755
+ </div>
1756
+
1757
+ <div class="method_details ">
1758
+ <h3 class="signature " id="is_osx?-instance_method">
1759
+
1760
+ - (<tt>Boolean</tt>) <strong>is_osx?</strong>
1761
+
1762
+
1763
+
1764
+
1765
+
1766
+ </h3><div class="docstring">
1767
+ <div class="discussion">
1768
+ <p>Checks if we are running on MacOS X.
1769
+ System services are only available on that platform.</p>
1770
+
1771
+
1772
+ </div>
1773
+ </div>
1774
+ <div class="tags">
1775
+
1776
+ <p class="tag_title">Returns:</p>
1777
+ <ul class="return">
1778
+
1779
+ <li>
1780
+
1781
+
1782
+ <span class='type'>(<tt>Boolean</tt>)</span>
1783
+
1784
+
1785
+
1786
+ &mdash;
1787
+ <div class='inline'><p><code>true</code> if the current platform is MacOS X, <code>false</code> otherwise.</p>
1788
+ </div>
1789
+
1790
+ </li>
1791
+
1792
+ </ul>
1793
+
1794
+ </div><table class="source_code">
1795
+ <tr>
1796
+ <td>
1797
+ <pre class="lines">
1798
+
1799
+
1800
+ 62
1801
+ 63
1802
+ 64</pre>
1803
+ </td>
1804
+ <td>
1805
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 62</span>
1806
+
1807
+ <span class='kw'>def</span> <span class='id identifier rubyid_is_osx?'>is_osx?</span>
1808
+ <span class='op'>::</span><span class='const'>Config</span><span class='op'>::</span><span class='const'>CONFIG</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>host_os</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^darwin</span><span class='regexp_end'>/</span></span>
1809
+ <span class='kw'>end</span></pre>
1810
+ </td>
1811
+ </tr>
1812
+ </table>
1813
+ </div>
1814
+
1815
+ <div class="method_details ">
1816
+ <h3 class="signature " id="launch_agent_path-instance_method">
1817
+
1818
+ - (<tt>String</tt>) <strong>launch_agent_path</strong>(name = &quot;it.cowtech.akaer&quot;)
1819
+
1820
+
1821
+
1822
+
1823
+
1824
+ </h3><div class="docstring">
1825
+ <div class="discussion">
1826
+ <p>Gets the path for the launch agent file.</p>
1827
+
1828
+
1829
+ </div>
1830
+ </div>
1831
+ <div class="tags">
1832
+ <p class="tag_title">Parameters:</p>
1833
+ <ul class="param">
1834
+
1835
+ <li>
1836
+
1837
+ <span class='name'>name</span>
1838
+
1839
+
1840
+ <span class='type'>(<tt>String</tt>)</span>
1841
+
1842
+
1843
+ <em class="default">(defaults to: <tt>&quot;it.cowtech.akaer&quot;</tt>)</em>
1844
+
1845
+
1846
+ &mdash;
1847
+ <div class='inline'><p>The base name for the agent.</p>
1848
+ </div>
1849
+
1850
+ </li>
1851
+
1852
+ </ul>
1853
+
1854
+ <p class="tag_title">Returns:</p>
1855
+ <ul class="return">
1856
+
1857
+ <li>
1858
+
1859
+
1860
+ <span class='type'>(<tt>String</tt>)</span>
1861
+
1862
+
1863
+
1864
+ &mdash;
1865
+ <div class='inline'><p>The path for the launch agent file.</p>
1866
+ </div>
1867
+
1868
+ </li>
1869
+
1870
+ </ul>
1871
+
1872
+ </div><table class="source_code">
1873
+ <tr>
1874
+ <td>
1875
+ <pre class="lines">
1876
+
1877
+
1878
+ 119
1879
+ 120
1880
+ 121</pre>
1881
+ </td>
1882
+ <td>
1883
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 119</span>
1884
+
1885
+ <span class='kw'>def</span> <span class='id identifier rubyid_launch_agent_path'>launch_agent_path</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>it.cowtech.akaer</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1886
+ <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>HOME</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/Library/LaunchAgents/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='rbrace'>}</span><span class='tstring_content'>.plist</span><span class='tstring_end'>&quot;</span></span>
1887
+ <span class='kw'>end</span></pre>
1888
+ </td>
1889
+ </tr>
1890
+ </table>
1891
+ </div>
1892
+
1893
+ <div class="method_details ">
1894
+ <h3 class="signature " id="manage-instance_method">
1895
+
1896
+ - (<tt>Boolean</tt>) <strong>manage</strong>(type, address)
1897
+
1898
+
1899
+
1900
+
1901
+
1902
+ </h3><div class="docstring">
1903
+ <div class="discussion">
1904
+ <p>Adds or removes an alias from the interface</p>
1905
+
1906
+
1907
+ </div>
1908
+ </div>
1909
+ <div class="tags">
1910
+ <p class="tag_title">Parameters:</p>
1911
+ <ul class="param">
1912
+
1913
+ <li>
1914
+
1915
+ <span class='name'>type</span>
1916
+
1917
+
1918
+ <span class='type'>(<tt>Symbol</tt>)</span>
1919
+
1920
+
1921
+
1922
+ &mdash;
1923
+ <div class='inline'><p>The operation to execute. Can be <code>:add</code> or <code>:remove</code>.</p>
1924
+ </div>
1925
+
1926
+ </li>
1927
+
1928
+ <li>
1929
+
1930
+ <span class='name'>address</span>
1931
+
1932
+
1933
+ <span class='type'>(<tt>String</tt>)</span>
1934
+
1935
+
1936
+
1937
+ &mdash;
1938
+ <div class='inline'><p>The address to manage.</p>
1939
+ </div>
1940
+
1941
+ </li>
1942
+
1943
+ </ul>
1944
+
1945
+ <p class="tag_title">Returns:</p>
1946
+ <ul class="return">
1947
+
1948
+ <li>
1949
+
1950
+
1951
+ <span class='type'>(<tt>Boolean</tt>)</span>
1952
+
1953
+
1954
+
1955
+ &mdash;
1956
+ <div class='inline'><p><code>true</code> if operation succedeed, <code>false</code> otherwise.</p>
1957
+ </div>
1958
+
1959
+ </li>
1960
+
1961
+ </ul>
1962
+
1963
+ </div><table class="source_code">
1964
+ <tr>
1965
+ <td>
1966
+ <pre class="lines">
1967
+
1968
+
1969
+ 167
1970
+ 168
1971
+ 169
1972
+ 170
1973
+ 171
1974
+ 172
1975
+ 173
1976
+ 174
1977
+ 175
1978
+ 176
1979
+ 177
1980
+ 178
1981
+ 179
1982
+ 180
1983
+ 181
1984
+ 182
1985
+ 183
1986
+ 184
1987
+ 185
1988
+ 186
1989
+ 187
1990
+ 188
1991
+ 189
1992
+ 190
1993
+ 191
1994
+ 192</pre>
1995
+ </td>
1996
+ <td>
1997
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 167</span>
1998
+
1999
+ <span class='kw'>def</span> <span class='id identifier rubyid_manage'>manage</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_address'>address</span><span class='rparen'>)</span>
2000
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>true</span>
2001
+
2002
+ <span class='comment'># Compute the command
2003
+ </span> <span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='symbol'>:remove</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_remove_command'>remove_command</span> <span class='op'>:</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_add_command'>add_command</span>
2004
+
2005
+ <span class='comment'># Interpolate
2006
+ </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_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>@INTERFACE@</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_interface'>interface</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>@ALIAS@</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_address'>address</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> &gt; /dev/null 2&gt;&amp;1</span><span class='tstring_end'>&quot;</span></span>
2007
+
2008
+ <span class='comment'># Compute the prefix
2009
+ </span> <span class='ivar'>@addresses</span> <span class='op'>||=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_compute_addresses'>compute_addresses</span>
2010
+ <span class='id identifier rubyid_length'>length</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_pad_number'>pad_number</span><span class='lparen'>(</span><span class='ivar'>@addresses</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='rparen'>)</span>
2011
+ <span class='id identifier rubyid_index'>index</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='ivar'>@addresses</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span><span class='lparen'>(</span><span class='id identifier rubyid_address'>address</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='int'>0</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='int'>1</span>
2012
+ <span class='id identifier rubyid_prefix'>prefix</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>{mark=blue}[{mark=bright white}</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_pad_number'>pad_number</span><span class='lparen'>(</span><span class='id identifier rubyid_index'>index</span><span class='comma'>,</span> <span class='id identifier rubyid_length'>length</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>{mark=reset blue}/{/mark}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_length'>length</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}]{/mark}</span><span class='tstring_end'>&quot;</span></span>
2013
+
2014
+ <span class='comment'># Now execute
2015
+ </span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_dry_run'>dry_run</span> <span class='kw'>then</span>
2016
+ <span class='ivar'>@logger</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='ivar'>@command</span><span class='period'>.</span><span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_replace_markers'>replace_markers</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_prefix'>prefix</span><span class='rbrace'>}</span><span class='tstring_content'> {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='symbol'>:remove</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Removing</span><span class='tstring_end'>&quot;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Adding</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} address {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_address'>address</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type'>type</span> <span class='op'>!=</span> <span class='symbol'>:remove</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>to</span><span class='tstring_end'>&quot;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>from</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='tstring_content'> interface {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_interface'>interface</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}...</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
2017
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_execute_command'>execute_command</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='rparen'>)</span>
2018
+ <span class='ivar'>@logger</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='ivar'>@command</span><span class='period'>.</span><span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_replace_markers'>replace_markers</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cannot {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='symbol'>:remove</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>remove</span><span class='tstring_end'>&quot;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>add</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} address {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_address'>address</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type'>type</span> <span class='op'>!=</span> <span class='symbol'>:remove</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>to</span><span class='tstring_end'>&quot;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>from</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='tstring_content'> interface {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_interface'>interface</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_rv'>rv</span>
2019
+ <span class='kw'>else</span>
2020
+ <span class='ivar'>@logger</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='ivar'>@command</span><span class='period'>.</span><span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_console'>console</span><span class='period'>.</span><span class='id identifier rubyid_replace_markers'>replace_markers</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_prefix'>prefix</span><span class='rbrace'>}</span><span class='tstring_content'> I will {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='symbol'>:remove</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>remove</span><span class='tstring_end'>&quot;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>add</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} address {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_address'>address</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark} </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type'>type</span> <span class='op'>!=</span> <span class='symbol'>:remove</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>to</span><span class='tstring_end'>&quot;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>from</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='tstring_content'> interface {mark=bright}</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_interface'>interface</span><span class='rbrace'>}</span><span class='tstring_content'>{/mark}.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_quiet'>quiet</span>
2021
+ <span class='kw'>end</span>
2022
+
2023
+ <span class='id identifier rubyid_rv'>rv</span>
2024
+ <span class='kw'>end</span></pre>
2025
+ </td>
2026
+ </tr>
2027
+ </table>
2028
+ </div>
2029
+
2030
+ <div class="method_details ">
2031
+ <h3 class="signature " id="pad_number-instance_method">
2032
+
2033
+ - (<tt>String</tt>) <strong>pad_number</strong>(num, len = nil)
2034
+
2035
+
2036
+
2037
+
2038
+
2039
+ </h3><div class="docstring">
2040
+ <div class="discussion">
2041
+ <p>Pads a number to make it print friendly.</p>
2042
+
2043
+
2044
+ </div>
2045
+ </div>
2046
+ <div class="tags">
2047
+ <p class="tag_title">Parameters:</p>
2048
+ <ul class="param">
2049
+
2050
+ <li>
2051
+
2052
+ <span class='name'>num</span>
2053
+
2054
+
2055
+ <span class='type'>(<tt>Fixnum</tt>)</span>
2056
+
2057
+
2058
+
2059
+ &mdash;
2060
+ <div class='inline'><p>The number to pad.</p>
2061
+ </div>
2062
+
2063
+ </li>
2064
+
2065
+ <li>
2066
+
2067
+ <span class='name'>len</span>
2068
+
2069
+
2070
+ <span class='type'>(<tt>Fixnum</tt>)</span>
2071
+
2072
+
2073
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
2074
+
2075
+
2076
+ &mdash;
2077
+ <div class='inline'><p>The minimum length of the padded string.</p>
2078
+ </div>
2079
+
2080
+ </li>
2081
+
2082
+ </ul>
2083
+
2084
+ <p class="tag_title">Returns:</p>
2085
+ <ul class="return">
2086
+
2087
+ <li>
2088
+
2089
+
2090
+ <span class='type'>(<tt>String</tt>)</span>
2091
+
2092
+
2093
+
2094
+ &mdash;
2095
+ <div class='inline'><p>The padded number.</p>
2096
+ </div>
2097
+
2098
+ </li>
2099
+
2100
+ </ul>
2101
+
2102
+ </div><table class="source_code">
2103
+ <tr>
2104
+ <td>
2105
+ <pre class="lines">
2106
+
2107
+
2108
+ 104
2109
+ 105
2110
+ 106</pre>
2111
+ </td>
2112
+ <td>
2113
+ <pre class="code"><span class="info file"># File 'lib/akaer/application.rb', line 104</span>
2114
+
2115
+ <span class='kw'>def</span> <span class='id identifier rubyid_pad_number'>pad_number</span><span class='lparen'>(</span><span class='id identifier rubyid_num'>num</span><span class='comma'>,</span> <span class='id identifier rubyid_len'>len</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
2116
+ <span class='id identifier rubyid_num'>num</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_rjust'>rjust</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_len'>len</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='comma'>,</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
2117
+ <span class='kw'>end</span></pre>
2118
+ </td>
2119
+ </tr>
2120
+ </table>
2121
+ </div>
2122
+
2123
+ </div>
2124
+
2125
+ </div>
2126
+
2127
+ <div id="footer">
2128
+ Generated on Wed Aug 22 10:35:58 2012 by
2129
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2130
+ 0.8.2.1 (ruby-1.9.2).
2131
+ </div>
2132
+
2133
+ </body>
2134
+ </html>