imp 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1108 @@
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: PasswdManage::EncryptedTree
8
+
9
+ &mdash; Documentation by YARD 0.8.7.3
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" 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 (E)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../PasswdManage.html" title="PasswdManage (module)">PasswdManage</a></span></span>
36
+ &raquo;
37
+ <span class="title">EncryptedTree</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: PasswdManage::EncryptedTree
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"><span class='object_link'><a href="EncryptedFile.html" title="PasswdManage::EncryptedFile (class)">EncryptedFile</a></span></span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next"><span class='object_link'><a href="EncryptedFile.html" title="PasswdManage::EncryptedFile (class)">EncryptedFile</a></span></li>
82
+
83
+ <li class="next">PasswdManage::EncryptedTree</li>
84
+
85
+ </ul>
86
+ <a href="#" class="inheritanceTree">show all</a>
87
+
88
+ </dd>
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dt class="r2">Includes:</dt>
96
+ <dd class="r2">Enumerable</dd>
97
+
98
+
99
+
100
+
101
+
102
+ <dt class="r1 last">Defined in:</dt>
103
+ <dd class="r1 last">lib/passwd_manage/tree.rb</dd>
104
+
105
+ </dl>
106
+ <div class="clear"></div>
107
+
108
+ <h2>Overview</h2><div class="docstring">
109
+ <div class="discussion">
110
+
111
+ <p>A tree loaded from an encrypted file.</p>
112
+
113
+ <p>All values are themselves encrypted with the key again. This doesn&#39;t
114
+ add additional security, but prevents them from appearing in memory in
115
+ plaintext if avoidable. Note that any program designed specifically to tap
116
+ into this programs memory will have no problem with this.</p>
117
+
118
+
119
+ </div>
120
+ </div>
121
+ <div class="tags">
122
+
123
+
124
+ </div>
125
+
126
+
127
+
128
+
129
+
130
+ <h2>Instance Attribute Summary</h2>
131
+
132
+ <h3 class="inherited">Attributes inherited from <span class='object_link'><a href="EncryptedFile.html" title="PasswdManage::EncryptedFile (class)">EncryptedFile</a></span></h3>
133
+ <p class="inherited"><span class='object_link'><a href="EncryptedFile.html#cont-instance_method" title="PasswdManage::EncryptedFile#cont (method)">#cont</a></span></p>
134
+
135
+
136
+
137
+ <h2>
138
+ Instance Method Summary
139
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
140
+ </h2>
141
+
142
+ <ul class="summary">
143
+
144
+ <li class="public ">
145
+ <span class="summary_signature">
146
+
147
+ <a href="#%5B%5D-instance_method" title="#[] (instance method)">- (String) <strong>[]</strong>(key) </a>
148
+
149
+
150
+
151
+ </span>
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+ <span class="summary_desc"><div class='inline'>
162
+ <p>Retrieves a node label following a forward-slash seperated list of edge
163
+ labels.</p>
164
+ </div></span>
165
+
166
+ </li>
167
+
168
+
169
+ <li class="public ">
170
+ <span class="summary_signature">
171
+
172
+ <a href="#%5B%5D%3D-instance_method" title="#[]= (instance method)">- (Object) <strong>[]=</strong>(key, val) </a>
173
+
174
+
175
+
176
+ </span>
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+ <span class="summary_desc"><div class='inline'>
187
+ <p>Sets a node label corresponding to a forward-slash seperated list of edge
188
+ labels.</p>
189
+ </div></span>
190
+
191
+ </li>
192
+
193
+
194
+ <li class="public ">
195
+ <span class="summary_signature">
196
+
197
+ <a href="#delete-instance_method" title="#delete (instance method)">- (Object) <strong>delete</strong>(key) </a>
198
+
199
+
200
+
201
+ </span>
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+ <span class="summary_desc"><div class='inline'>
212
+ <p>Deletes a node corresponding to a forward-slash seperated list of edge
213
+ labels.</p>
214
+ </div></span>
215
+
216
+ </li>
217
+
218
+
219
+ <li class="public ">
220
+ <span class="summary_signature">
221
+
222
+ <a href="#each-instance_method" title="#each (instance method)">- (Object) <strong>each</strong>(keys = [], subtree = @cont) {|String, String| ... }</a>
223
+
224
+
225
+
226
+ </span>
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+ <span class="summary_desc"><div class='inline'>
237
+ <p>Iterates over key/value pairs.</p>
238
+ </div></span>
239
+
240
+ </li>
241
+
242
+
243
+ <li class="public ">
244
+ <span class="summary_signature">
245
+
246
+ <a href="#include%3F-instance_method" title="#include? (instance method)">- (Boolean) <strong>include?</strong>(item) </a>
247
+
248
+
249
+
250
+ </span>
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+ <span class="summary_desc"><div class='inline'>
261
+ <p>Checks whether a tree contains a key.</p>
262
+ </div></span>
263
+
264
+ </li>
265
+
266
+
267
+ <li class="public ">
268
+ <span class="summary_signature">
269
+
270
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (EncryptedTree) <strong>initialize</strong>(passwd, file) </a>
271
+
272
+
273
+
274
+ </span>
275
+
276
+
277
+ <span class="note title constructor">constructor</span>
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+ <span class="summary_desc"><div class='inline'>
287
+ <p>Creates a new tree / load an existing one from a file.</p>
288
+ </div></span>
289
+
290
+ </li>
291
+
292
+
293
+ <li class="public ">
294
+ <span class="summary_signature">
295
+
296
+ <a href="#password%3D-instance_method" title="#password= (instance method)">- (Object) <strong>password=</strong>(passwd) </a>
297
+
298
+
299
+
300
+ </span>
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+ <span class="summary_desc"><div class='inline'>
311
+ <p>Sets a new password for the file.</p>
312
+ </div></span>
313
+
314
+ </li>
315
+
316
+
317
+ <li class="public ">
318
+ <span class="summary_signature">
319
+
320
+ <a href="#prune-instance_method" title="#prune (instance method)">- (Object) <strong>prune</strong> </a>
321
+
322
+
323
+
324
+ </span>
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+ <span class="summary_desc"><div class='inline'>
335
+ <p>Iteratively removes any leaves with a nil value.</p>
336
+ </div></span>
337
+
338
+ </li>
339
+
340
+
341
+ <li class="public ">
342
+ <span class="summary_signature">
343
+
344
+ <a href="#to_s-instance_method" title="#to_s (instance method)">- (String) <strong>to_s</strong> </a>
345
+
346
+
347
+
348
+ </span>
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+ <span class="summary_desc"><div class='inline'>
359
+ <p>Delegates to the tree for string representation.</p>
360
+ </div></span>
361
+
362
+ </li>
363
+
364
+
365
+ </ul>
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="EncryptedFile.html" title="PasswdManage::EncryptedFile (class)">EncryptedFile</a></span></h3>
379
+ <p class="inherited"><span class='object_link'><a href="EncryptedFile.html#close-instance_method" title="PasswdManage::EncryptedFile#close (method)">#close</a></span>, <span class='object_link'><a href="EncryptedFile.html#flush-instance_method" title="PasswdManage::EncryptedFile#flush (method)">#flush</a></span></p>
380
+ <div id="constructor_details" class="method_details_list">
381
+ <h2>Constructor Details</h2>
382
+
383
+ <div class="method_details first">
384
+ <h3 class="signature first" id="initialize-instance_method">
385
+
386
+ - (<tt><span class='object_link'><a href="" title="PasswdManage::EncryptedTree (class)">EncryptedTree</a></span></tt>) <strong>initialize</strong>(passwd, file)
387
+
388
+
389
+
390
+
391
+
392
+ </h3><div class="docstring">
393
+ <div class="discussion">
394
+
395
+ <p>Creates a new tree / load an existing one from a file.</p>
396
+
397
+
398
+ </div>
399
+ </div>
400
+ <div class="tags">
401
+ <p class="tag_title">Parameters:</p>
402
+ <ul class="param">
403
+
404
+ <li>
405
+
406
+ <span class='name'>passwd</span>
407
+
408
+
409
+ <span class='type'>(<tt>String</tt>)</span>
410
+
411
+
412
+
413
+ &mdash;
414
+ <div class='inline'>
415
+ <p>The password to decrypt the file. Discarded after this call (although the
416
+ key is kept in memory)</p>
417
+ </div>
418
+
419
+ </li>
420
+
421
+ <li>
422
+
423
+ <span class='name'>file</span>
424
+
425
+
426
+ <span class='type'>(<tt>String</tt>)</span>
427
+
428
+
429
+
430
+ &mdash;
431
+ <div class='inline'>
432
+ <p>The location of the file to decrypt. If this does not exist, a new tree is
433
+ made.</p>
434
+ </div>
435
+
436
+ </li>
437
+
438
+ </ul>
439
+
440
+
441
+ </div><table class="source_code">
442
+ <tr>
443
+ <td>
444
+ <pre class="lines">
445
+
446
+
447
+ 119
448
+ 120
449
+ 121
450
+ 122
451
+ 123
452
+ 124</pre>
453
+ </td>
454
+ <td>
455
+ <pre class="code"><span class="info file"># File 'lib/passwd_manage/tree.rb', line 119</span>
456
+
457
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_passwd'>passwd</span><span class='comma'>,</span> <span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span>
458
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_passwd'>passwd</span><span class='comma'>,</span> <span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span>
459
+ <span class='kw'>if</span> <span class='ivar'>@cont</span> <span class='op'>==</span> <span class='kw'>nil</span>
460
+ <span class='ivar'>@cont</span> <span class='op'>=</span> <span class='const'>Tree</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
461
+ <span class='kw'>end</span>
462
+ <span class='kw'>end</span></pre>
463
+ </td>
464
+ </tr>
465
+ </table>
466
+ </div>
467
+
468
+ </div>
469
+
470
+
471
+ <div id="instance_method_details" class="method_details_list">
472
+ <h2>Instance Method Details</h2>
473
+
474
+
475
+ <div class="method_details first">
476
+ <h3 class="signature first" id="[]-instance_method">
477
+
478
+ - (<tt>String</tt>) <strong>[]</strong>(key)
479
+
480
+
481
+
482
+
483
+
484
+ </h3><div class="docstring">
485
+ <div class="discussion">
486
+
487
+ <p>Retrieves a node label following a forward-slash seperated list of edge
488
+ labels.</p>
489
+
490
+
491
+ </div>
492
+ </div>
493
+ <div class="tags">
494
+ <p class="tag_title">Parameters:</p>
495
+ <ul class="param">
496
+
497
+ <li>
498
+
499
+ <span class='name'>key</span>
500
+
501
+
502
+ <span class='type'>(<tt>String</tt>)</span>
503
+
504
+
505
+
506
+ &mdash;
507
+ <div class='inline'>
508
+ <p>The forward-slash seperated list of edge labels.</p>
509
+ </div>
510
+
511
+ </li>
512
+
513
+ </ul>
514
+
515
+ <p class="tag_title">Returns:</p>
516
+ <ul class="return">
517
+
518
+ <li>
519
+
520
+
521
+ <span class='type'>(<tt>String</tt>)</span>
522
+
523
+
524
+
525
+ &mdash;
526
+ <div class='inline'>
527
+ <p>The decrypted value of the corresponding node label.</p>
528
+ </div>
529
+
530
+ </li>
531
+
532
+ </ul>
533
+
534
+ </div><table class="source_code">
535
+ <tr>
536
+ <td>
537
+ <pre class="lines">
538
+
539
+
540
+ 131
541
+ 132
542
+ 133</pre>
543
+ </td>
544
+ <td>
545
+ <pre class="code"><span class="info file"># File 'lib/passwd_manage/tree.rb', line 131</span>
546
+
547
+ <span class='kw'>def</span> <span class='op'>[]</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
548
+ <span class='const'>Crypto</span><span class='period'>.</span><span class='id identifier rubyid_decrypt'>decrypt</span><span class='lparen'>(</span><span class='ivar'>@key</span><span class='comma'>,</span> <span class='ivar'>@cont</span><span class='period'>.</span><span class='id identifier rubyid_descendant'>descendant</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
549
+ <span class='kw'>end</span></pre>
550
+ </td>
551
+ </tr>
552
+ </table>
553
+ </div>
554
+
555
+ <div class="method_details ">
556
+ <h3 class="signature " id="[]=-instance_method">
557
+
558
+ - (<tt>Object</tt>) <strong>[]=</strong>(key, val)
559
+
560
+
561
+
562
+
563
+
564
+ </h3><div class="docstring">
565
+ <div class="discussion">
566
+
567
+ <p>Sets a node label corresponding to a forward-slash seperated list of edge
568
+ labels.</p>
569
+
570
+
571
+ </div>
572
+ </div>
573
+ <div class="tags">
574
+ <p class="tag_title">Parameters:</p>
575
+ <ul class="param">
576
+
577
+ <li>
578
+
579
+ <span class='name'>key</span>
580
+
581
+
582
+ <span class='type'>(<tt>String</tt>)</span>
583
+
584
+
585
+
586
+ &mdash;
587
+ <div class='inline'>
588
+ <p>The list of edge labels.</p>
589
+ </div>
590
+
591
+ </li>
592
+
593
+ <li>
594
+
595
+ <span class='name'>val</span>
596
+
597
+
598
+ <span class='type'>(<tt>String</tt>)</span>
599
+
600
+
601
+
602
+ &mdash;
603
+ <div class='inline'>
604
+ <p>The value to set the node label to. This will be encrypted.</p>
605
+ </div>
606
+
607
+ </li>
608
+
609
+ </ul>
610
+
611
+
612
+ </div><table class="source_code">
613
+ <tr>
614
+ <td>
615
+ <pre class="lines">
616
+
617
+
618
+ 141
619
+ 142
620
+ 143</pre>
621
+ </td>
622
+ <td>
623
+ <pre class="code"><span class="info file"># File 'lib/passwd_manage/tree.rb', line 141</span>
624
+
625
+ <span class='kw'>def</span> <span class='op'>[]=</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
626
+ <span class='ivar'>@cont</span><span class='period'>.</span><span class='id identifier rubyid_descendant'>descendant</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_val'>val</span> <span class='op'>=</span> <span class='const'>Crypto</span><span class='period'>.</span><span class='id identifier rubyid_encrypt'>encrypt</span><span class='lparen'>(</span><span class='ivar'>@key</span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span><span class='rparen'>)</span>
627
+ <span class='kw'>end</span></pre>
628
+ </td>
629
+ </tr>
630
+ </table>
631
+ </div>
632
+
633
+ <div class="method_details ">
634
+ <h3 class="signature " id="delete-instance_method">
635
+
636
+ - (<tt>Object</tt>) <strong>delete</strong>(key)
637
+
638
+
639
+
640
+
641
+
642
+ </h3><div class="docstring">
643
+ <div class="discussion">
644
+
645
+ <p>Deletes a node corresponding to a forward-slash seperated list of edge
646
+ labels.</p>
647
+
648
+
649
+ </div>
650
+ </div>
651
+ <div class="tags">
652
+ <p class="tag_title">Parameters:</p>
653
+ <ul class="param">
654
+
655
+ <li>
656
+
657
+ <span class='name'>key</span>
658
+
659
+
660
+ <span class='type'>(<tt>String</tt>)</span>
661
+
662
+
663
+
664
+ &mdash;
665
+ <div class='inline'>
666
+ <p>The list of edge labels. Must be a valid key.</p>
667
+ </div>
668
+
669
+ </li>
670
+
671
+ </ul>
672
+
673
+
674
+ </div><table class="source_code">
675
+ <tr>
676
+ <td>
677
+ <pre class="lines">
678
+
679
+
680
+ 172
681
+ 173
682
+ 174
683
+ 175
684
+ 176
685
+ 177
686
+ 178
687
+ 179
688
+ 180
689
+ 181
690
+ 182</pre>
691
+ </td>
692
+ <td>
693
+ <pre class="code"><span class="info file"># File 'lib/passwd_manage/tree.rb', line 172</span>
694
+
695
+ <span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
696
+ <span class='comment'># We seperate the last key from the first keys.
697
+ </span> <span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
698
+ <span class='id identifier rubyid_finalkey'>finalkey</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span><span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
699
+ <span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>...</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
700
+
701
+ <span class='comment'># Instead of using descendant we reduce over the root. This also handels
702
+ </span> <span class='comment'># the root being the parent node well.
703
+ </span> <span class='id identifier rubyid_node'>node</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='ivar'>@cont</span><span class='comma'>,</span> <span class='symbol'>:[]</span><span class='rparen'>)</span>
704
+ <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_finalkey'>finalkey</span>
705
+ <span class='kw'>end</span></pre>
706
+ </td>
707
+ </tr>
708
+ </table>
709
+ </div>
710
+
711
+ <div class="method_details ">
712
+ <h3 class="signature " id="each-instance_method">
713
+
714
+ - (<tt>Object</tt>) <strong>each</strong>(keys = [], subtree = @cont) {|String, String| ... }
715
+
716
+
717
+
718
+
719
+
720
+ </h3><div class="docstring">
721
+ <div class="discussion">
722
+
723
+ <p>Iterates over key/value pairs.</p>
724
+
725
+
726
+ </div>
727
+ </div>
728
+ <div class="tags">
729
+ <p class="tag_title">Parameters:</p>
730
+ <ul class="param">
731
+
732
+ <li>
733
+
734
+ <span class='name'>keys</span>
735
+
736
+
737
+ <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
738
+
739
+
740
+ <em class="default">(defaults to: <tt>[]</tt>)</em>
741
+
742
+
743
+ &mdash;
744
+ <div class='inline'>
745
+ <p>A list of the keys followed to reach the current subtree.</p>
746
+ </div>
747
+
748
+ </li>
749
+
750
+ <li>
751
+
752
+ <span class='name'>subtree</span>
753
+
754
+
755
+ <span class='type'>(<tt><span class='object_link'><a href="Tree.html" title="PasswdManage::Tree (class)">Tree</a></span></tt>)</span>
756
+
757
+
758
+ <em class="default">(defaults to: <tt>@cont</tt>)</em>
759
+
760
+
761
+ &mdash;
762
+ <div class='inline'>
763
+ <p>The tree currently iterating over.</p>
764
+ </div>
765
+
766
+ </li>
767
+
768
+ </ul>
769
+
770
+ <p class="tag_title">Yields:</p>
771
+ <ul class="yield">
772
+
773
+ <li>
774
+
775
+
776
+ <span class='type'>(<tt>String</tt>, <tt>String</tt>)</span>
777
+
778
+
779
+
780
+ &mdash;
781
+ <div class='inline'>
782
+ <p>Key, value pairs where the key is a forward slash seperated string of edge
783
+ labels. Values are not decrypted or processed.</p>
784
+ </div>
785
+
786
+ </li>
787
+
788
+ </ul>
789
+
790
+ </div><table class="source_code">
791
+ <tr>
792
+ <td>
793
+ <pre class="lines">
794
+
795
+
796
+ 153
797
+ 154
798
+ 155
799
+ 156
800
+ 157
801
+ 158
802
+ 159</pre>
803
+ </td>
804
+ <td>
805
+ <pre class="code"><span class="info file"># File 'lib/passwd_manage/tree.rb', line 153</span>
806
+
807
+ <span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_subtree'>subtree</span> <span class='op'>=</span> <span class='ivar'>@cont</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
808
+ <span class='comment'># Yield the subtree&#39;s value unless it is the root.
809
+ </span> <span class='kw'>yield</span> <span class='lbracket'>[</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_subtree'>subtree</span><span class='period'>.</span><span class='id identifier rubyid_val'>val</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_keys'>keys</span> <span class='op'>==</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
810
+ <span class='id identifier rubyid_subtree'>subtree</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_tree'>tree</span><span class='op'>|</span>
811
+ <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span> <span class='op'>+</span> <span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_tree'>tree</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
812
+ <span class='kw'>end</span>
813
+ <span class='kw'>end</span></pre>
814
+ </td>
815
+ </tr>
816
+ </table>
817
+ </div>
818
+
819
+ <div class="method_details ">
820
+ <h3 class="signature " id="include?-instance_method">
821
+
822
+ - (<tt>Boolean</tt>) <strong>include?</strong>(item)
823
+
824
+
825
+
826
+
827
+
828
+ </h3><div class="docstring">
829
+ <div class="discussion">
830
+
831
+ <p>Checks whether a tree contains a key.</p>
832
+
833
+
834
+ </div>
835
+ </div>
836
+ <div class="tags">
837
+ <p class="tag_title">Parameters:</p>
838
+ <ul class="param">
839
+
840
+ <li>
841
+
842
+ <span class='name'>item</span>
843
+
844
+
845
+ <span class='type'>(<tt>String</tt>)</span>
846
+
847
+
848
+
849
+ &mdash;
850
+ <div class='inline'>
851
+ <p>The forward slash seperated string of edge labels.</p>
852
+ </div>
853
+
854
+ </li>
855
+
856
+ </ul>
857
+
858
+ <p class="tag_title">Returns:</p>
859
+ <ul class="return">
860
+
861
+ <li>
862
+
863
+
864
+ <span class='type'>(<tt>Boolean</tt>)</span>
865
+
866
+
867
+
868
+ </li>
869
+
870
+ </ul>
871
+
872
+ </div><table class="source_code">
873
+ <tr>
874
+ <td>
875
+ <pre class="lines">
876
+
877
+
878
+ 164
879
+ 165
880
+ 166</pre>
881
+ </td>
882
+ <td>
883
+ <pre class="code"><span class="info file"># File 'lib/passwd_manage/tree.rb', line 164</span>
884
+
885
+ <span class='kw'>def</span> <span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_item'>item</span><span class='rparen'>)</span>
886
+ <span class='ivar'>@cont</span><span class='period'>.</span><span class='id identifier rubyid_descendant'>descendant</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='op'>!=</span> <span class='kw'>nil</span>
887
+ <span class='kw'>end</span></pre>
888
+ </td>
889
+ </tr>
890
+ </table>
891
+ </div>
892
+
893
+ <div class="method_details ">
894
+ <h3 class="signature " id="password=-instance_method">
895
+
896
+ - (<tt>Object</tt>) <strong>password=</strong>(passwd)
897
+
898
+
899
+
900
+
901
+
902
+ </h3><div class="docstring">
903
+ <div class="discussion">
904
+
905
+ <p>Sets a new password for the file.</p>
906
+
907
+
908
+ </div>
909
+ </div>
910
+ <div class="tags">
911
+ <p class="tag_title">Parameters:</p>
912
+ <ul class="param">
913
+
914
+ <li>
915
+
916
+ <span class='name'>The</span>
917
+
918
+
919
+ <span class='type'>(<tt>String</tt>)</span>
920
+
921
+
922
+
923
+ &mdash;
924
+ <div class='inline'>
925
+ <p>new password to generate a key from.</p>
926
+ </div>
927
+
928
+ </li>
929
+
930
+ </ul>
931
+
932
+
933
+ </div><table class="source_code">
934
+ <tr>
935
+ <td>
936
+ <pre class="lines">
937
+
938
+
939
+ 202
940
+ 203
941
+ 204
942
+ 205
943
+ 206
944
+ 207
945
+ 208
946
+ 209
947
+ 210
948
+ 211
949
+ 212
950
+ 213
951
+ 214
952
+ 215
953
+ 216</pre>
954
+ </td>
955
+ <td>
956
+ <pre class="code"><span class="info file"># File 'lib/passwd_manage/tree.rb', line 202</span>
957
+
958
+ <span class='kw'>def</span> <span class='id identifier rubyid_password='>password=</span><span class='lparen'>(</span><span class='id identifier rubyid_passwd'>passwd</span><span class='rparen'>)</span>
959
+ <span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='ivar'>@key</span>
960
+ <span class='comment'># Super call.
961
+ </span> <span class='const'>EncryptedFile</span><span class='period'>.</span><span class='id identifier rubyid_instance_method'>instance_method</span><span class='lparen'>(</span><span class='symbol'>:password=</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_bind'>bind</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_passwd'>passwd</span><span class='rparen'>)</span>
962
+ <span class='comment'># If the file is still being initialized, @cont may be nil. In this case
963
+ </span> <span class='comment'># return.
964
+ </span> <span class='kw'>return</span> <span class='kw'>unless</span> <span class='ivar'>@cont</span>
965
+ <span class='id identifier rubyid_each'>each</span> <span class='kw'>do</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>
966
+ <span class='comment'># Don&#39;t change nil values.
967
+ </span> <span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_v'>v</span>
968
+ <span class='comment'># Otherwise decrypt with the old key and encrypt with the new.
969
+ </span> <span class='comment'># (Encryption is done automatically by #[]=)
970
+ </span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>Crypto</span><span class='period'>.</span><span class='id identifier rubyid_decrypt'>decrypt</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span>
971
+ <span class='kw'>end</span>
972
+ <span class='kw'>end</span></pre>
973
+ </td>
974
+ </tr>
975
+ </table>
976
+ </div>
977
+
978
+ <div class="method_details ">
979
+ <h3 class="signature " id="prune-instance_method">
980
+
981
+ - (<tt>Object</tt>) <strong>prune</strong>
982
+
983
+
984
+
985
+
986
+
987
+ </h3><div class="docstring">
988
+ <div class="discussion">
989
+
990
+ <p>Iteratively removes any leaves with a nil value. Not terribly efficient but
991
+ there is no need to be.</p>
992
+
993
+
994
+ </div>
995
+ </div>
996
+ <div class="tags">
997
+
998
+
999
+ </div><table class="source_code">
1000
+ <tr>
1001
+ <td>
1002
+ <pre class="lines">
1003
+
1004
+
1005
+ 186
1006
+ 187
1007
+ 188
1008
+ 189
1009
+ 190
1010
+ 191
1011
+ 192
1012
+ 193
1013
+ 194
1014
+ 195
1015
+ 196
1016
+ 197</pre>
1017
+ </td>
1018
+ <td>
1019
+ <pre class="code"><span class="info file"># File 'lib/passwd_manage/tree.rb', line 186</span>
1020
+
1021
+ <span class='kw'>def</span> <span class='id identifier rubyid_prune'>prune</span>
1022
+ <span class='id identifier rubyid_pruned'>pruned</span> <span class='op'>=</span> <span class='kw'>true</span>
1023
+ <span class='kw'>while</span> <span class='id identifier rubyid_pruned'>pruned</span>
1024
+ <span class='id identifier rubyid_pruned'>pruned</span> <span class='op'>=</span> <span class='kw'>false</span>
1025
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
1026
+ <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>==</span> <span class='kw'>nil</span> <span class='op'>&amp;&amp;</span> <span class='ivar'>@cont</span><span class='period'>.</span><span class='id identifier rubyid_descendant'>descendant</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_leaf?'>leaf?</span>
1027
+ <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
1028
+ <span class='id identifier rubyid_pruned'>pruned</span> <span class='op'>=</span> <span class='kw'>true</span>
1029
+ <span class='kw'>end</span>
1030
+ <span class='kw'>end</span>
1031
+ <span class='kw'>end</span>
1032
+ <span class='kw'>end</span></pre>
1033
+ </td>
1034
+ </tr>
1035
+ </table>
1036
+ </div>
1037
+
1038
+ <div class="method_details ">
1039
+ <h3 class="signature " id="to_s-instance_method">
1040
+
1041
+ - (<tt>String</tt>) <strong>to_s</strong>
1042
+
1043
+
1044
+
1045
+
1046
+
1047
+ </h3><div class="docstring">
1048
+ <div class="discussion">
1049
+
1050
+ <p>Delegates to the tree for string representation.</p>
1051
+
1052
+
1053
+ </div>
1054
+ </div>
1055
+ <div class="tags">
1056
+
1057
+ <p class="tag_title">Returns:</p>
1058
+ <ul class="return">
1059
+
1060
+ <li>
1061
+
1062
+
1063
+ <span class='type'>(<tt>String</tt>)</span>
1064
+
1065
+
1066
+
1067
+ &mdash;
1068
+ <div class='inline'>
1069
+ <p>The string representation of the tree.</p>
1070
+ </div>
1071
+
1072
+ </li>
1073
+
1074
+ </ul>
1075
+
1076
+ </div><table class="source_code">
1077
+ <tr>
1078
+ <td>
1079
+ <pre class="lines">
1080
+
1081
+
1082
+ 221
1083
+ 222
1084
+ 223</pre>
1085
+ </td>
1086
+ <td>
1087
+ <pre class="code"><span class="info file"># File 'lib/passwd_manage/tree.rb', line 221</span>
1088
+
1089
+ <span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
1090
+ <span class='ivar'>@cont</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
1091
+ <span class='kw'>end</span></pre>
1092
+ </td>
1093
+ </tr>
1094
+ </table>
1095
+ </div>
1096
+
1097
+ </div>
1098
+
1099
+ </div>
1100
+
1101
+ <div id="footer">
1102
+ Generated on Sat Nov 9 18:07:46 2013 by
1103
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1104
+ 0.8.7.3 (ruby-2.0.0).
1105
+ </div>
1106
+
1107
+ </body>
1108
+ </html>