rio 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. data/ChangeLog +140 -0
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/doc/ANNOUNCE +87 -0
  5. data/doc/RELEASE_NOTES +7 -0
  6. data/doc/rdoc/classes/Kernel.html +9 -9
  7. data/doc/rdoc/classes/Kernel.src/{M000183.html → M000182.html} +0 -0
  8. data/doc/rdoc/classes/RIO.html +35 -0
  9. data/doc/rdoc/classes/RIO.src/M000001.html +4 -4
  10. data/doc/rdoc/classes/RIO.src/M000002.html +4 -4
  11. data/doc/rdoc/classes/RIO.src/M000003.html +4 -4
  12. data/doc/rdoc/classes/RIO/Doc/HOWTO.html +11 -7
  13. data/doc/rdoc/classes/RIO/Doc/INTRO.html +255 -36
  14. data/doc/rdoc/classes/RIO/Doc/SYNOPSIS.html +47 -17
  15. data/doc/rdoc/classes/RIO/Rio.html +1032 -1007
  16. data/doc/rdoc/classes/RIO/Rio.src/M000011.html +3 -3
  17. data/doc/rdoc/classes/RIO/Rio.src/M000012.html +3 -3
  18. data/doc/rdoc/classes/RIO/Rio.src/M000013.html +3 -3
  19. data/doc/rdoc/classes/RIO/Rio.src/M000014.html +3 -3
  20. data/doc/rdoc/classes/RIO/Rio.src/M000015.html +3 -3
  21. data/doc/rdoc/classes/RIO/Rio.src/M000016.html +3 -3
  22. data/doc/rdoc/classes/RIO/Rio.src/M000017.html +3 -3
  23. data/doc/rdoc/classes/RIO/Rio.src/M000018.html +3 -3
  24. data/doc/rdoc/classes/RIO/Rio.src/M000019.html +3 -3
  25. data/doc/rdoc/classes/RIO/Rio.src/M000020.html +3 -3
  26. data/doc/rdoc/classes/RIO/Rio.src/M000021.html +3 -3
  27. data/doc/rdoc/classes/RIO/Rio.src/M000022.html +3 -3
  28. data/doc/rdoc/classes/RIO/Rio.src/M000023.html +3 -3
  29. data/doc/rdoc/classes/RIO/Rio.src/M000024.html +3 -3
  30. data/doc/rdoc/classes/RIO/Rio.src/M000025.html +3 -3
  31. data/doc/rdoc/classes/RIO/Rio.src/M000026.html +3 -3
  32. data/doc/rdoc/classes/RIO/Rio.src/M000027.html +3 -3
  33. data/doc/rdoc/classes/RIO/Rio.src/M000028.html +3 -3
  34. data/doc/rdoc/classes/RIO/Rio.src/M000029.html +3 -3
  35. data/doc/rdoc/classes/RIO/Rio.src/M000030.html +3 -3
  36. data/doc/rdoc/classes/RIO/Rio.src/M000031.html +3 -3
  37. data/doc/rdoc/classes/RIO/Rio.src/M000032.html +3 -3
  38. data/doc/rdoc/classes/RIO/Rio.src/M000033.html +3 -3
  39. data/doc/rdoc/classes/RIO/Rio.src/M000034.html +3 -3
  40. data/doc/rdoc/classes/RIO/Rio.src/M000035.html +3 -3
  41. data/doc/rdoc/classes/RIO/Rio.src/M000036.html +3 -3
  42. data/doc/rdoc/classes/RIO/Rio.src/M000037.html +3 -3
  43. data/doc/rdoc/classes/RIO/Rio.src/M000038.html +3 -3
  44. data/doc/rdoc/classes/RIO/Rio.src/M000039.html +3 -3
  45. data/doc/rdoc/classes/RIO/Rio.src/M000040.html +3 -3
  46. data/doc/rdoc/classes/RIO/Rio.src/M000041.html +3 -3
  47. data/doc/rdoc/classes/RIO/Rio.src/M000042.html +3 -3
  48. data/doc/rdoc/classes/RIO/Rio.src/M000043.html +3 -3
  49. data/doc/rdoc/classes/RIO/Rio.src/M000044.html +3 -3
  50. data/doc/rdoc/classes/RIO/Rio.src/M000045.html +3 -3
  51. data/doc/rdoc/classes/RIO/Rio.src/M000046.html +3 -3
  52. data/doc/rdoc/classes/RIO/Rio.src/M000047.html +3 -3
  53. data/doc/rdoc/classes/RIO/Rio.src/M000048.html +3 -3
  54. data/doc/rdoc/classes/RIO/Rio.src/M000049.html +3 -3
  55. data/doc/rdoc/classes/RIO/Rio.src/M000050.html +3 -3
  56. data/doc/rdoc/classes/RIO/Rio.src/M000051.html +3 -3
  57. data/doc/rdoc/classes/RIO/Rio.src/M000052.html +3 -3
  58. data/doc/rdoc/classes/RIO/Rio.src/M000053.html +3 -3
  59. data/doc/rdoc/classes/RIO/Rio.src/M000054.html +3 -3
  60. data/doc/rdoc/classes/RIO/Rio.src/M000055.html +3 -3
  61. data/doc/rdoc/classes/RIO/Rio.src/M000056.html +3 -3
  62. data/doc/rdoc/classes/RIO/Rio.src/M000057.html +3 -3
  63. data/doc/rdoc/classes/RIO/Rio.src/M000058.html +3 -3
  64. data/doc/rdoc/classes/RIO/Rio.src/M000059.html +3 -3
  65. data/doc/rdoc/classes/RIO/Rio.src/M000060.html +3 -3
  66. data/doc/rdoc/classes/RIO/Rio.src/M000061.html +3 -3
  67. data/doc/rdoc/classes/RIO/Rio.src/M000062.html +3 -3
  68. data/doc/rdoc/classes/RIO/Rio.src/M000063.html +3 -3
  69. data/doc/rdoc/classes/RIO/Rio.src/M000064.html +3 -3
  70. data/doc/rdoc/classes/RIO/Rio.src/M000065.html +3 -3
  71. data/doc/rdoc/classes/RIO/Rio.src/M000066.html +3 -3
  72. data/doc/rdoc/classes/RIO/Rio.src/M000067.html +3 -3
  73. data/doc/rdoc/classes/RIO/Rio.src/M000068.html +3 -3
  74. data/doc/rdoc/classes/RIO/Rio.src/M000069.html +3 -3
  75. data/doc/rdoc/classes/RIO/Rio.src/M000070.html +3 -3
  76. data/doc/rdoc/classes/RIO/Rio.src/M000071.html +3 -3
  77. data/doc/rdoc/classes/RIO/Rio.src/M000072.html +3 -3
  78. data/doc/rdoc/classes/RIO/Rio.src/M000073.html +3 -3
  79. data/doc/rdoc/classes/RIO/Rio.src/M000074.html +3 -3
  80. data/doc/rdoc/classes/RIO/Rio.src/M000075.html +3 -3
  81. data/doc/rdoc/classes/RIO/Rio.src/M000076.html +3 -3
  82. data/doc/rdoc/classes/RIO/Rio.src/M000077.html +3 -3
  83. data/doc/rdoc/classes/RIO/Rio.src/M000078.html +3 -3
  84. data/doc/rdoc/classes/RIO/Rio.src/M000079.html +3 -3
  85. data/doc/rdoc/classes/RIO/Rio.src/M000080.html +3 -3
  86. data/doc/rdoc/classes/RIO/Rio.src/M000081.html +3 -3
  87. data/doc/rdoc/classes/RIO/Rio.src/M000082.html +3 -3
  88. data/doc/rdoc/classes/RIO/Rio.src/M000083.html +3 -3
  89. data/doc/rdoc/classes/RIO/Rio.src/M000084.html +3 -3
  90. data/doc/rdoc/classes/RIO/Rio.src/M000085.html +3 -3
  91. data/doc/rdoc/classes/RIO/Rio.src/M000086.html +3 -3
  92. data/doc/rdoc/classes/RIO/Rio.src/M000087.html +3 -3
  93. data/doc/rdoc/classes/RIO/Rio.src/M000088.html +3 -3
  94. data/doc/rdoc/classes/RIO/Rio.src/M000089.html +2 -2
  95. data/doc/rdoc/classes/RIO/Rio.src/M000090.html +2 -2
  96. data/doc/rdoc/classes/RIO/Rio.src/M000091.html +2 -2
  97. data/doc/rdoc/classes/RIO/Rio.src/M000092.html +2 -2
  98. data/doc/rdoc/classes/RIO/Rio.src/M000093.html +2 -2
  99. data/doc/rdoc/classes/RIO/Rio.src/M000094.html +2 -2
  100. data/doc/rdoc/classes/RIO/Rio.src/M000095.html +2 -2
  101. data/doc/rdoc/classes/RIO/Rio.src/M000096.html +2 -2
  102. data/doc/rdoc/classes/RIO/Rio.src/M000097.html +2 -2
  103. data/doc/rdoc/classes/RIO/Rio.src/M000098.html +2 -2
  104. data/doc/rdoc/classes/RIO/Rio.src/M000099.html +2 -2
  105. data/doc/rdoc/classes/RIO/Rio.src/M000100.html +2 -2
  106. data/doc/rdoc/classes/RIO/Rio.src/M000101.html +2 -2
  107. data/doc/rdoc/classes/RIO/Rio.src/M000102.html +2 -2
  108. data/doc/rdoc/classes/RIO/Rio.src/M000103.html +2 -2
  109. data/doc/rdoc/classes/RIO/Rio.src/M000104.html +2 -2
  110. data/doc/rdoc/classes/RIO/Rio.src/M000105.html +2 -2
  111. data/doc/rdoc/classes/RIO/Rio.src/M000106.html +2 -2
  112. data/doc/rdoc/classes/RIO/Rio.src/M000107.html +2 -2
  113. data/doc/rdoc/classes/RIO/Rio.src/M000108.html +3 -3
  114. data/doc/rdoc/classes/RIO/Rio.src/M000109.html +3 -3
  115. data/doc/rdoc/classes/RIO/Rio.src/M000110.html +3 -3
  116. data/doc/rdoc/classes/RIO/Rio.src/M000111.html +3 -3
  117. data/doc/rdoc/classes/RIO/Rio.src/M000112.html +3 -3
  118. data/doc/rdoc/classes/RIO/Rio.src/M000113.html +3 -3
  119. data/doc/rdoc/classes/RIO/Rio.src/M000114.html +3 -3
  120. data/doc/rdoc/classes/RIO/Rio.src/M000115.html +3 -3
  121. data/doc/rdoc/classes/RIO/Rio.src/M000116.html +3 -3
  122. data/doc/rdoc/classes/RIO/Rio.src/M000117.html +3 -3
  123. data/doc/rdoc/classes/RIO/Rio.src/M000118.html +3 -3
  124. data/doc/rdoc/classes/RIO/Rio.src/M000119.html +3 -3
  125. data/doc/rdoc/classes/RIO/Rio.src/M000120.html +3 -3
  126. data/doc/rdoc/classes/RIO/Rio.src/M000121.html +3 -3
  127. data/doc/rdoc/classes/RIO/Rio.src/M000122.html +3 -3
  128. data/doc/rdoc/classes/RIO/Rio.src/M000123.html +3 -3
  129. data/doc/rdoc/classes/RIO/Rio.src/M000124.html +3 -3
  130. data/doc/rdoc/classes/RIO/Rio.src/M000125.html +3 -3
  131. data/doc/rdoc/classes/RIO/Rio.src/M000126.html +3 -3
  132. data/doc/rdoc/classes/RIO/Rio.src/M000127.html +3 -3
  133. data/doc/rdoc/classes/RIO/Rio.src/M000128.html +3 -3
  134. data/doc/rdoc/classes/RIO/Rio.src/M000129.html +3 -3
  135. data/doc/rdoc/classes/RIO/Rio.src/M000130.html +3 -3
  136. data/doc/rdoc/classes/RIO/Rio.src/M000131.html +3 -3
  137. data/doc/rdoc/classes/RIO/Rio.src/M000132.html +3 -3
  138. data/doc/rdoc/classes/RIO/Rio.src/M000133.html +3 -3
  139. data/doc/rdoc/classes/RIO/Rio.src/M000134.html +3 -3
  140. data/doc/rdoc/classes/RIO/Rio.src/M000135.html +3 -3
  141. data/doc/rdoc/classes/RIO/Rio.src/M000136.html +3 -3
  142. data/doc/rdoc/classes/RIO/Rio.src/M000137.html +3 -3
  143. data/doc/rdoc/classes/RIO/Rio.src/M000138.html +3 -3
  144. data/doc/rdoc/classes/RIO/Rio.src/M000139.html +3 -3
  145. data/doc/rdoc/classes/RIO/Rio.src/M000140.html +3 -3
  146. data/doc/rdoc/classes/RIO/Rio.src/M000141.html +3 -3
  147. data/doc/rdoc/classes/RIO/Rio.src/M000142.html +3 -3
  148. data/doc/rdoc/classes/RIO/Rio.src/M000143.html +3 -3
  149. data/doc/rdoc/classes/RIO/Rio.src/M000144.html +3 -3
  150. data/doc/rdoc/classes/RIO/Rio.src/M000145.html +3 -3
  151. data/doc/rdoc/classes/RIO/Rio.src/M000146.html +3 -3
  152. data/doc/rdoc/classes/RIO/Rio.src/M000147.html +3 -3
  153. data/doc/rdoc/classes/RIO/Rio.src/M000148.html +3 -3
  154. data/doc/rdoc/classes/RIO/Rio.src/M000149.html +3 -3
  155. data/doc/rdoc/classes/RIO/Rio.src/M000150.html +3 -3
  156. data/doc/rdoc/classes/RIO/Rio.src/M000151.html +3 -3
  157. data/doc/rdoc/classes/RIO/Rio.src/M000152.html +3 -3
  158. data/doc/rdoc/classes/RIO/Rio.src/M000153.html +3 -3
  159. data/doc/rdoc/classes/RIO/Rio.src/M000154.html +3 -3
  160. data/doc/rdoc/classes/RIO/Rio.src/M000155.html +3 -3
  161. data/doc/rdoc/classes/RIO/Rio.src/M000156.html +3 -3
  162. data/doc/rdoc/classes/RIO/Rio.src/M000157.html +3 -3
  163. data/doc/rdoc/classes/RIO/Rio.src/M000158.html +3 -3
  164. data/doc/rdoc/classes/RIO/Rio.src/M000159.html +3 -3
  165. data/doc/rdoc/classes/RIO/Rio.src/M000160.html +3 -3
  166. data/doc/rdoc/classes/RIO/Rio.src/M000161.html +3 -3
  167. data/doc/rdoc/classes/RIO/Rio.src/M000162.html +3 -3
  168. data/doc/rdoc/classes/RIO/Rio.src/M000163.html +3 -3
  169. data/doc/rdoc/classes/RIO/Rio.src/M000164.html +3 -3
  170. data/doc/rdoc/classes/RIO/Rio.src/M000165.html +3 -3
  171. data/doc/rdoc/classes/RIO/Rio.src/M000166.html +3 -3
  172. data/doc/rdoc/classes/RIO/Rio.src/M000167.html +3 -3
  173. data/doc/rdoc/classes/RIO/Rio.src/M000168.html +3 -3
  174. data/doc/rdoc/classes/RIO/Rio.src/M000169.html +3 -3
  175. data/doc/rdoc/classes/RIO/Rio.src/M000170.html +3 -3
  176. data/doc/rdoc/classes/RIO/Rio.src/M000171.html +3 -3
  177. data/doc/rdoc/classes/RIO/Rio.src/M000172.html +3 -3
  178. data/doc/rdoc/classes/RIO/Rio.src/M000173.html +3 -3
  179. data/doc/rdoc/classes/RIO/Rio.src/M000174.html +3 -3
  180. data/doc/rdoc/classes/RIO/Rio.src/M000175.html +3 -3
  181. data/doc/rdoc/classes/RIO/Rio.src/M000176.html +3 -3
  182. data/doc/rdoc/classes/RIO/Rio.src/M000177.html +3 -3
  183. data/doc/rdoc/classes/RIO/Rio.src/M000178.html +3 -3
  184. data/doc/rdoc/classes/RIO/Rio.src/M000179.html +3 -3
  185. data/doc/rdoc/classes/RIO/Rio.src/M000180.html +3 -3
  186. data/doc/rdoc/classes/RIO/Rio.src/M000181.html +3 -3
  187. data/doc/rdoc/created.rid +1 -1
  188. data/doc/rdoc/files/lib/rio/constructor_rb.html +1 -1
  189. data/doc/rdoc/files/lib/rio/doc/HOWTO_rb.html +1 -1
  190. data/doc/rdoc/files/lib/rio/doc/INTRO_rb.html +1 -1
  191. data/doc/rdoc/files/lib/rio/doc/SYNOPSIS_rb.html +1 -1
  192. data/doc/rdoc/files/lib/rio/if/basic_rb.html +1 -1
  193. data/doc/rdoc/files/lib/rio/if/path_rb.html +1 -1
  194. data/doc/rdoc/files/lib/rio_rb.html +1 -1
  195. data/doc/rdoc/fr_method_index.html +154 -155
  196. data/ex/findinruby +7 -3
  197. data/ex/findruby +6 -2
  198. data/lib/rio.rb +1 -1
  199. data/lib/rio/argv.rb +4 -0
  200. data/lib/rio/constructor.rb +17 -0
  201. data/lib/rio/context.rb +1 -1
  202. data/lib/rio/context/dir.rb +1 -0
  203. data/lib/rio/context/methods.rb +3 -3
  204. data/lib/rio/dir.rb +2 -2
  205. data/lib/rio/doc/HOWTO.rb +11 -6
  206. data/lib/rio/doc/INTRO.rb +149 -12
  207. data/lib/rio/doc/SYNOPSIS.rb +26 -13
  208. data/lib/rio/factory.rb +13 -2
  209. data/lib/rio/grande.rb +25 -0
  210. data/lib/rio/if/basic.rb +1 -1
  211. data/lib/rio/if/path.rb +61 -35
  212. data/lib/rio/matchrecord.rb +20 -1
  213. data/lib/rio/ops/dir.rb +2 -3
  214. data/lib/rio/ops/path.rb +25 -11
  215. data/lib/rio/ops/stream/input.rb +6 -3
  216. data/lib/rio/rl/base.rb +3 -2
  217. data/lib/rio/rl/ioi.rb +2 -1
  218. data/lib/rio/rl/path.rb +18 -3
  219. data/lib/rio/rl/uri.rb +8 -4
  220. data/lib/rio/scheme/cmdio.rb +1 -1
  221. data/lib/rio/scheme/path.rb +1 -0
  222. data/lib/rio/scheme/stdio.rb +1 -1
  223. data/lib/rio/scheme/strio.rb +1 -1
  224. data/lib/rio/scheme/sysio.rb +1 -1
  225. data/lib/rio/scheme/tcp.rb +1 -0
  226. data/lib/rio/scheme/temp.rb +184 -0
  227. data/lib/rio/state.rb +17 -6
  228. data/lib/rio/stream.rb +1 -1
  229. data/lib/rio/stream/open.rb +1 -1
  230. data/lib/rio/tempdir.rb +132 -0
  231. data/lib/rio/version.rb +1 -1
  232. data/test/tc/all.rb +4 -0
  233. data/test/tc/copylines.rb +38 -32
  234. data/test/tc/riorl.rb +104 -0
  235. data/test/tc/temp.rb +155 -0
  236. data/test/tc/tempdir.rb +63 -0
  237. data/test/tc/tempfile.rb +38 -0
  238. metadata +10 -5
  239. data/doc/rdoc/classes/RIO/Rio.src/M000182.html +0 -16
  240. data/lib/rio/scheme/tempfile.rb +0 -104
@@ -119,7 +119,7 @@ Using a <a href="../Rio.html">Rio</a> can be described as having 3 steps:
119
119
  </p>
120
120
  <ul>
121
121
  <li>Creating a <a href="../Rio.html">Rio</a> (using the constructor or as the
122
- result of one of path manipulation methods)
122
+ result of one of the path manipulation methods)
123
123
 
124
124
  </li>
125
125
  <li>Configuring a <a href="../Rio.html">Rio</a>
@@ -269,9 +269,9 @@ to specify stdin or stdout in place of a file)
269
269
  <p>
270
270
  Just as a <a href="../Rio.html">Rio</a> that refers to a file, does not
271
271
  know whether that file will be opened for reading or writing until an io
272
- operation is specified, a +stdio:+ <a href="../Rio.html">Rio</a> does not
273
- know whether it will connect to stdin or stdout until an io operation is
274
- specified.
272
+ operation is specified, a <tt>stdio:</tt> <a href="../Rio.html">Rio</a>
273
+ does not know whether it will connect to stdin or stdout until an I/O
274
+ operation is specified.
275
275
  </p>
276
276
  <h5>Creating a <a href="../Rio.html">Rio</a> that refers to a clone of your programs stderr.</h5>
277
277
  <p>
@@ -314,14 +314,45 @@ choosing
314
314
  astring = &quot;&quot;
315
315
  rio(?&quot;,&quot;&quot;)
316
316
  </pre>
317
- <h5>Creating a <a href="../Rio.html">Rio</a> that refers to a Tempfile object</h5>
317
+ <h5>Creating a <a href="../Rio.html">Rio</a> that refers to a Temporary object</h5>
318
318
  <p>
319
319
  <tt>rio(??)</tt> (mnemonic: &#8217;?&#8217; you don&#8217;t know its name)
320
320
  </p>
321
+ <p>
322
+ To create a temporary object that will become a file or a directory,
323
+ depending on how you use it:
324
+ </p>
321
325
  <pre>
322
326
  rio(??)
323
327
  rio(??,basename='rio',tmpdir=Dir::tmpdir)
324
328
  </pre>
329
+ <p>
330
+ To force it to become a file
331
+ </p>
332
+ <pre>
333
+ rio(??).file
334
+ </pre>
335
+ <p>
336
+ or just write to it.
337
+ </p>
338
+ <p>
339
+ To force it to become a directory:
340
+ </p>
341
+ <pre>
342
+ rio(??).dir
343
+ </pre>
344
+ <p>
345
+ or
346
+ </p>
347
+ <pre>
348
+ rio(??).mkdir
349
+ </pre>
350
+ <p>
351
+ or
352
+ </p>
353
+ <pre>
354
+ rio(??).chdir
355
+ </pre>
325
356
  <h5>Creating a <a href="../Rio.html">Rio</a> that refers to an arbitrary TCPSocket</h5>
326
357
  <pre>
327
358
  rio('tcp:',hostname,port)
@@ -476,7 +507,7 @@ href="../Rio.html#M000008">Rio#to_s</a>.
476
507
  </pre>
477
508
  <h4>Creating a <a href="../Rio.html">Rio</a> based on its relationship to another</h4>
478
509
  <p>
479
- <a href="../Rio.html#M000087">Rio#abs</a> creates a new rio whose path is
510
+ <a href="../Rio.html#M000086">Rio#abs</a> creates a new rio whose path is
480
511
  the absolute path of a <a href="../Rio.html">Rio</a>. If provided with an
481
512
  argument, it uses that as the base path, otherwise it uses an internal base
482
513
  path (usually the current working directory when it was created).
@@ -488,7 +519,7 @@ path (usually the current working directory when it was created).
488
519
  end
489
520
  </pre>
490
521
  <p>
491
- <a href="../Rio.html#M000088">Rio#rel</a> creates a new rio with a path
522
+ <a href="../Rio.html#M000087">Rio#rel</a> creates a new rio with a path
492
523
  relative to a <a href="../Rio.html">Rio</a>.
493
524
  </p>
494
525
  <pre>
@@ -498,8 +529,8 @@ relative to a <a href="../Rio.html">Rio</a>.
498
529
  rio('/tmp/b').rel('/tmp') #=&gt; rio('b')
499
530
  </pre>
500
531
  <p>
501
- <a href="../Rio.html#M000114">Rio#route_to</a> and <a
502
- href="../Rio.html#M000113">Rio#route_from</a> creates a new rio with a path
532
+ <a href="../Rio.html#M000113">Rio#route_to</a> and <a
533
+ href="../Rio.html#M000112">Rio#route_from</a> creates a new rio with a path
503
534
  representing the route to get to/from a <a href="../Rio.html">Rio</a>. They
504
535
  are based on the methods of the same names in the URI class
505
536
  </p>
@@ -728,7 +759,7 @@ be used for further I/O operations it is returned as a <a
728
759
  href="../Rio.html">Rio</a>. For example: where File#dirname returns a
729
760
  string, <a href="../Rio.html#M000093">Rio#dirname</a> returns a <a
730
761
  href="../Rio.html">Rio</a>; where Dir#read returns a string representing a
731
- directory entry, <a href="../Rio.html#M000039">Rio#read</a> returns a <a
762
+ directory entry, <a href="../Rio.html#M000038">Rio#read</a> returns a <a
732
763
  href="../Rio.html">Rio</a>.
733
764
  </p>
734
765
  <p>
@@ -771,7 +802,7 @@ FileTest.
771
802
  <li><a href="../Rio.html">Rio</a> has its own <a
772
803
  href="../Rio.html#M000092">Rio#basename</a>, <a
773
804
  href="../Rio.html#M000100">Rio#join</a> and <a
774
- href="../Rio.html#M000036">Rio#symlink</a>, which provide similar
805
+ href="../Rio.html#M000035">Rio#symlink</a>, which provide similar
775
806
  functionality.
776
807
 
777
808
  </li>
@@ -846,7 +877,7 @@ provided as instance methods.
846
877
 
847
878
  </li>
848
879
  <li><tt>chdir</tt> is provided as an instance method. <a
849
- href="../Rio.html#M000018">Rio#chdir</a> returns a <a
880
+ href="../Rio.html#M000017">Rio#chdir</a> returns a <a
850
881
  href="../Rio.html">Rio</a> and passes a <a href="../Rio.html">Rio</a> to a
851
882
  block if one is provided.
852
883
 
@@ -879,7 +910,7 @@ open-uri
879
910
  </ul>
880
911
  <h4>Grande operators</h4>
881
912
  <p>
882
- The primary grande operator is <a href="../Rio.html#M000046">Rio#each</a>.
913
+ The primary grande operator is <a href="../Rio.html#M000045">Rio#each</a>.
883
914
  <tt>each</tt> is used to iterate through Rios. When applied to a file it
884
915
  iterates through records in the file. When applied to a directory it
885
916
  iterates through the entries in the directory. Its behavior is modified by
@@ -973,12 +1004,12 @@ For example:
973
1004
  <h3>Renaming and Moving</h3>
974
1005
  <p>
975
1006
  <a href="../Rio.html">Rio</a> provides two methods for directly renaming
976
- objects on the filesystem: <a href="../Rio.html#M000038">Rio#rename</a> and
977
- <a href="../Rio.html#M000038">Rio#rename</a>!. Both of these use
1007
+ objects on the filesystem: <a href="../Rio.html#M000037">Rio#rename</a> and
1008
+ <a href="../Rio.html#M000037">Rio#rename</a>!. Both of these use
978
1009
  File#rename. The difference between them is the returned <a
979
- href="../Rio.html">Rio</a>. <a href="../Rio.html#M000038">Rio#rename</a>
1010
+ href="../Rio.html">Rio</a>. <a href="../Rio.html#M000037">Rio#rename</a>
980
1011
  leaves the path of the <a href="../Rio.html">Rio</a> unchanged, while <a
981
- href="../Rio.html#M000038">Rio#rename</a>! changes the path of the <a
1012
+ href="../Rio.html#M000037">Rio#rename</a>! changes the path of the <a
982
1013
  href="../Rio.html">Rio</a> to refer to the renamed path.
983
1014
  </p>
984
1015
  <pre>
@@ -996,7 +1027,7 @@ href="../Rio.html#M000094">Rio#extname</a>= to rename an object on the
996
1027
  filesystem when they are used to change a <a
997
1028
  href="../Rio.html">Rio</a>&#8217;s path. A <a href="../Rio.html">Rio</a> is
998
1029
  put in <tt>rename</tt> mode by calling <a
999
- href="../Rio.html#M000038">Rio#rename</a> with no arguments.
1030
+ href="../Rio.html#M000037">Rio#rename</a> with no arguments.
1000
1031
  </p>
1001
1032
  <pre>
1002
1033
  rio('adir/afile.txt').rename.filename = 'bfile.rb' # adir/afile.txt =&gt; adir/bfile.rb
@@ -1017,42 +1048,42 @@ when iterating through that directory.
1017
1048
  <h3>Deleting</h3>
1018
1049
  <p>
1019
1050
  The <a href="../Rio.html">Rio</a> methods for deleting filesystem objects
1020
- are <a href="../Rio.html#M000034">Rio#rm</a>, <a
1021
- href="../Rio.html#M000030">Rio#rmdir</a>, <a
1022
- href="../Rio.html#M000031">Rio#rmtree</a>, <a
1023
- href="../Rio.html#M000047">Rio#delete</a>, and <a
1024
- href="../Rio.html#M000047">Rio#delete</a>!. <tt>rm</tt>, <tt>rmdir</tt> and
1051
+ are <a href="../Rio.html#M000033">Rio#rm</a>, <a
1052
+ href="../Rio.html#M000029">Rio#rmdir</a>, <a
1053
+ href="../Rio.html#M000030">Rio#rmtree</a>, <a
1054
+ href="../Rio.html#M000046">Rio#delete</a>, and <a
1055
+ href="../Rio.html#M000046">Rio#delete</a>!. <tt>rm</tt>, <tt>rmdir</tt> and
1025
1056
  <tt>rmtree</tt> are passed the like named methods in the FileUtils module.
1026
- <a href="../Rio.html#M000047">Rio#delete</a> calls <tt>rmdir</tt> for
1057
+ <a href="../Rio.html#M000046">Rio#delete</a> calls <tt>rmdir</tt> for
1027
1058
  directories and <tt>rm</tt> for anything else, while <a
1028
- href="../Rio.html#M000047">Rio#delete</a>! calls <a
1029
- href="../Rio.html#M000031">Rio#rmtree</a> for directories.
1059
+ href="../Rio.html#M000046">Rio#delete</a>! calls <a
1060
+ href="../Rio.html#M000030">Rio#rmtree</a> for directories.
1030
1061
  </p>
1031
1062
  <ul>
1032
1063
  <li>To delete something only if it is not a directory use <a
1033
- href="../Rio.html#M000034">Rio#rm</a>
1064
+ href="../Rio.html#M000033">Rio#rm</a>
1034
1065
 
1035
1066
  </li>
1036
1067
  <li>To delete an empty directory use <a
1037
- href="../Rio.html#M000030">Rio#rmdir</a>
1068
+ href="../Rio.html#M000029">Rio#rmdir</a>
1038
1069
 
1039
1070
  </li>
1040
1071
  <li>To delete an entire directory tree use <a
1041
- href="../Rio.html#M000031">Rio#rmtree</a>
1072
+ href="../Rio.html#M000030">Rio#rmtree</a>
1042
1073
 
1043
1074
  </li>
1044
1075
  <li>To delete anything except a populated directory use <a
1045
- href="../Rio.html#M000047">Rio#delete</a>
1076
+ href="../Rio.html#M000046">Rio#delete</a>
1046
1077
 
1047
1078
  </li>
1048
- <li>To delete anything use <a href="../Rio.html#M000047">Rio#delete</a>!
1079
+ <li>To delete anything use <a href="../Rio.html#M000046">Rio#delete</a>!
1049
1080
 
1050
1081
  </li>
1051
1082
  </ul>
1052
1083
  <p>
1053
1084
  It is not an error to call any of the deleting methods on something that
1054
1085
  does not exist. <a href="../Rio.html">Rio</a> provides Rio#exist? and <a
1055
- href="../Rio.html#M000036">Rio#symlink</a>? to check if something exists
1086
+ href="../Rio.html#M000035">Rio#symlink</a>? to check if something exists
1056
1087
  (<tt>exist?</tt> returns false for symlinks to non-existant object even
1057
1088
  though the symlink itself exists). The deleting methods&#8217; purpose is
1058
1089
  to make things not exist, so calling one of them on something that already
@@ -1060,14 +1091,202 @@ does not exist is considered a success.
1060
1091
  </p>
1061
1092
  <p>
1062
1093
  To create a clean copy of a directory whether or not anything with that
1063
- name exists you might do this
1094
+ name exists one might do this
1064
1095
  </p>
1065
1096
  <pre>
1066
- rio('adir').delete!.mkpath.chdir do
1067
- # do something in adir
1068
- end
1097
+ rio('adir').delete!.mkpath.chdir do
1098
+ # do something in adir
1099
+ end
1100
+ </pre>
1101
+ <hr size="1"></hr><h2>Miscellany</h2>
1102
+ <h4>Using Symbolic Links</h4>
1103
+ <p>
1104
+ To create a symbolic link (symlink) to the file-system entry refered to by
1105
+ a <a href="../Rio.html">Rio</a>, use <a
1106
+ href="../Rio.html#M000035">Rio#symlink</a>. <a
1107
+ href="../Rio.html#M000035">Rio#symlink</a> differs from File#symlink in
1108
+ that it calculates the path from the symlink location to the <a
1109
+ href="../Rio.html">Rio</a>&#8217;s position. So:
1110
+ </p>
1111
+ <pre>
1112
+ File#symlink('adir/afile','adir/alink')
1113
+ </pre>
1114
+ <p>
1115
+ creates a symlink in the directory &#8216;adir&#8217; named
1116
+ &#8216;alink&#8217; which references &#8216;adir/afile&#8217;. From the
1117
+ perspective of &#8216;alink&#8217;, &#8216;adir/afile&#8217; does not
1118
+ exist. While:
1119
+ </p>
1120
+ <pre>
1121
+ rio('adir/afile').symlink('adir/alink')
1122
+ </pre>
1123
+ <p>
1124
+ creates a symlink in the directory &#8216;adir&#8217; named
1125
+ &#8216;alink&#8217; which references &#8216;afile&#8217;. This is the route
1126
+ to &#8216;adir/afile&#8217; from the perspective of
1127
+ &#8216;adir/alink&#8217;.
1128
+ </p>
1129
+ <p>
1130
+ Note that the return value from <tt>symlink</tt> is the calling <a
1131
+ href="../Rio.html">Rio</a> and not a <a href="../Rio.html">Rio</a> refering
1132
+ to the symlink. This is done for consistency with the rest of <a
1133
+ href="../Rio.html">Rio</a>.
1134
+ </p>
1135
+ <p>
1136
+ <a href="../Rio.html#M000035">Rio#symlink</a>? can be used to test if a
1137
+ file-system object is a symlink. A <a href="../Rio.html">Rio</a> is
1138
+ extended with <a href="../Rio.html#M000036">Rio#readlink</a>, and <a
1139
+ href="../Rio.html#M000161">Rio#lstat</a> only if <a
1140
+ href="../Rio.html#M000035">Rio#symlink</a>? returns true. So for
1141
+ non-symlinks, these will raise a NoMethodError. These are both passed to
1142
+ their counterparts in File. <a href="../Rio.html#M000036">Rio#readlink</a>
1143
+ returns a <a href="../Rio.html">Rio</a> refering to the result of
1144
+ File#readlink.
1145
+ </p>
1146
+ <h4>Using A <a href="../Rio.html">Rio</a> as an IO (or File or Dir)</h4>
1147
+ <p>
1148
+ <a href="../Rio.html">Rio</a> supports so much of IO&#8217;s interface that
1149
+ one might be tempted to pass it to a method that expects an IO. While <a
1150
+ href="../Rio.html">Rio</a> is not and is not intended to be a stand in for
1151
+ IO, this can work. It requires knowledge of every IO method that will be
1152
+ called, under any circumstances.
1153
+ </p>
1154
+ <p>
1155
+ Even in cases where <a href="../Rio.html">Rio</a> supports the required IO
1156
+ interface, A <a href="../Rio.html">Rio</a> feature that seems to cause the
1157
+ most incompatibility, is its automatic closing of files. To turn off all of
1158
+ <a href="../Rio.html">Rio</a>&#8217;s automatic closing use
1159
+ Rio#noautoclose.
1160
+ </p>
1161
+ <p>
1162
+ For example:
1163
+ </p>
1164
+ <pre>
1165
+ require 'yaml'
1166
+ yrio = rio('ran.yaml').delete!.noautoclose
1167
+ YAML.dump( ['badger', 'elephant', 'tiger'], yrio )
1168
+ obj = YAML::load( yrio ) #=&gt; [&quot;badger&quot;, &quot;tiger&quot;, &quot;elephant&quot;]
1169
+ </pre>
1170
+ <h4>Automatic Closing of Files</h4>
1171
+ <p>
1172
+ <a href="../Rio.html">Rio</a> closes files automatically in three
1173
+ instances.
1174
+ </p>
1175
+ <p>
1176
+ When reading from an IO it is closed when the end of file is reached. While
1177
+ this is a reasonable thing to do in many cases, sometimes this is not
1178
+ desired. To turn <a href="../Rio.html">Rio</a>&#8217;s automatic closing on
1179
+ end of file use <a href="../Rio.html#M000069">Rio#nocloseoneof</a> (it can
1180
+ be turned back on via <a href="../Rio.html#M000068">Rio#closeoneof</a>)
1181
+ </p>
1182
+ <pre>
1183
+ ario = rio('afile').nocloseoneof
1184
+ lines = ario[]
1185
+ ario.closed? #=&gt; false
1186
+ </pre>
1187
+ <p>
1188
+ Closing on end-of-file is necessary for many of <a
1189
+ href="../Rio.html">Rio</a>&#8217;s &quot;one-liners&quot;, but has an
1190
+ implication that may be surprising at first. A <a
1191
+ href="../Rio.html">Rio</a> starts life as a path, not much more than a
1192
+ string. When one of its read methods is called it becomes an input stream.
1193
+ When the stream is closed, it becomes a path again. This means that when
1194
+ reading from a <a href="../Rio.html">Rio</a>, the end-of-file condition is
1195
+ seen only once before it becomes a path again, and will be reopened if
1196
+ another read operation is attempted.
1197
+ </p>
1198
+ <p>
1199
+ Another time a <a href="../Rio.html">Rio</a> will be closed atomatically is
1200
+ when writing to it with one of the copy operators (<tt>&lt;, &lt;&lt;,
1201
+ &gt;, &gt;&gt;</tt>). This behavior can be turned off with <a
1202
+ href="../Rio.html#M000072">Rio#nocloseoncopy</a>.
1203
+ </p>
1204
+ <p>
1205
+ To turn off both of thes types of automatic closing use Rio#noautoclose.
1206
+ </p>
1207
+ <p>
1208
+ The third instance when <a href="../Rio.html">Rio</a> will close a file
1209
+ automatically is when a file opened for one type of access receives a
1210
+ method which that access mode does not support. So, the code
1211
+ </p>
1212
+ <pre>
1213
+ rio('afile').puts(&quot;Hello World&quot;).gets
1214
+ </pre>
1215
+ <p>
1216
+ will open the file for write access when the <tt>puts</tt> method is
1217
+ received. When <tt>gets</tt> is called the file is closed and reopened with
1218
+ read access.
1219
+ </p>
1220
+ <h4>Explicit Closing of Files</h4>
1221
+ <p>
1222
+ <a href="../Rio.html">Rio</a> can not determine when the client is finished
1223
+ writing to it, as it does using <tt>eof</tt> on read. It is the
1224
+ author&#8217;s understanding that Ruby does not support a mechanism to have
1225
+ code run when there are no more references to it &#8212; that finalizers
1226
+ are not necessarily run immediatly upon an object&#8217;s reference count
1227
+ reaching 0. If this understanding is incorrect, some of <a
1228
+ href="../Rio.html">Rio</a>&#8217;s extranious ways of closing a file may be
1229
+ rethought.
1230
+ </p>
1231
+ <p>
1232
+ That being said, <a href="../Rio.html">Rio</a> support several ways to
1233
+ explicitly close a file. <a href="../Rio.html#M000141">Rio#close</a> will
1234
+ close any open <a href="../Rio.html">Rio</a>. The output methods <a
1235
+ href="../Rio.html#M000132">Rio#puts</a>!, <a
1236
+ href="../Rio.html#M000131">Rio#putc</a>!, <a
1237
+ href="../Rio.html#M000129">Rio#printf</a>!, <a
1238
+ href="../Rio.html#M000126">Rio#print</a>!, and <a
1239
+ href="../Rio.html#M000135">Rio#write</a>! behave as if their counterparts
1240
+ without the exclamation point had been called and then call <a
1241
+ href="../Rio.html#M000141">Rio#close</a> or Rio#close_write if the
1242
+ underlying IO object is opened for duplex access.
1243
+ </p>
1244
+ <h4>Open mode selection</h4>
1245
+ <p>
1246
+ A <a href="../Rio.html">Rio</a> is typically not explicitly opened. It
1247
+ opens a file automatically when an input or output methed is called. For
1248
+ output methods <a href="../Rio.html">Rio</a> opens a file with mode
1249
+ &#8216;w&#8217;, and otherwise opens a file with mode &#8216;r&#8217;. This
1250
+ behavior can be modified using the tersely named methods <a
1251
+ href="../Rio.html#M000062">Rio#a</a>, <a
1252
+ href="../Rio.html#M000062">Rio#a</a>!, <a
1253
+ href="../Rio.html#M000064">Rio#r</a>, <a
1254
+ href="../Rio.html#M000064">Rio#r</a>!, <a
1255
+ href="../Rio.html#M000066">Rio#w</a>, and <a
1256
+ href="../Rio.html#M000066">Rio#w</a>!, which cause the <a
1257
+ href="../Rio.html">Rio</a> to use modes
1258
+ &#8216;a&#8217;,&#8217;a+&#8217;,&#8217;r&#8217;,&#8217;r+&#8217;,&#8217;w&#8217;,and
1259
+ &#8216;w+&#8217; respectively.
1260
+ </p>
1261
+ <p>
1262
+ One way to append a string to a file and close it in one line is
1263
+ </p>
1264
+ <pre>
1265
+ rio('afile').a.puts!(&quot;Hello World&quot;)
1069
1266
  </pre>
1070
1267
  <p>
1268
+ Run a cmd that must be opened for read and write
1269
+ </p>
1270
+ <pre>
1271
+ ans = rio(?-,'cat').w!.puts!(&quot;Hello Kitty&quot;).readlines
1272
+ </pre>
1273
+ <p>
1274
+ The automatic selection of mode can be bypassed entirely using <a
1275
+ href="../Rio.html#M000139">Rio#mode</a> and <a
1276
+ href="../Rio.html#M000007">Rio#open</a>.
1277
+ </p>
1278
+ <p>
1279
+ If a mode is specified using <tt>mode</tt>, the file will still be opened
1280
+ automatically, but the mode specified in the <tt>mode</tt> method will be
1281
+ used regardless of whether it makes sense.
1282
+ </p>
1283
+ <p>
1284
+ A <a href="../Rio.html">Rio</a> can also be opened explicitly using <a
1285
+ href="../Rio.html#M000007">Rio#open</a>. <tt>open</tt> takes one parameter,
1286
+ a mode. This also will override all of <a
1287
+ href="../Rio.html">Rio</a>&#8217;s automatic mode selection.
1288
+ </p>
1289
+ <hr size="1"></hr><p>
1071
1290
  See also:
1072
1291
  </p>
1073
1292
  <ul>
@@ -92,6 +92,12 @@ Copy a file into a string
92
92
  rio('afile') &gt; astring
93
93
  </pre>
94
94
  <p>
95
+ Copy a string into a file
96
+ </p>
97
+ <pre>
98
+ rio('afile') &lt; astring
99
+ </pre>
100
+ <p>
95
101
  Copy the chomped lines of a file into an array
96
102
  </p>
97
103
  <pre>
@@ -122,7 +128,7 @@ Copy a web page into a file
122
128
  rio('http://rubydoc.org/') &gt; rio('afile')
123
129
  </pre>
124
130
  <p>
125
- Copy a file from a ftp server into a file
131
+ Copy a file from a ftp server into a local file
126
132
  </p>
127
133
  <pre>
128
134
  rio('ftp://host/afile.gz') &gt; rio('afile.gz')
@@ -134,16 +140,16 @@ Copy a gzipped file un-gzipping it
134
140
  rio('afile.gz').gzip &gt; rio('afile')
135
141
  </pre>
136
142
  <p>
137
- Copy a file from a ftp server into a local file un-gzipping it
143
+ Copy a plain file, gzipping it
138
144
  </p>
139
145
  <pre>
140
- rio('ftp://host/afile.gz').gzip &gt; rio('afile')
146
+ rio('afile.gz').gzip &lt; rio('afile')
141
147
  </pre>
142
148
  <p>
143
- Copy a plain file, gzipping it
149
+ Copy a file from a ftp server into a local file un-gzipping it
144
150
  </p>
145
151
  <pre>
146
- rio('afile.gz').gzip &lt; rio('afile')
152
+ rio('ftp://host/afile.gz').gzip &gt; rio('afile')
147
153
  </pre>
148
154
  <p>
149
155
  Iterate over the entries in a directory
@@ -164,6 +170,25 @@ Iterate over only the .rb files in a directory
164
170
  rio('adir').files('*.rb') { |entrio| ... }
165
171
  </pre>
166
172
  <p>
173
+ Iterate over only the directories in a directory
174
+ </p>
175
+ <pre>
176
+ rio('adir').dirs { |entrio| ... }
177
+ </pre>
178
+ <p>
179
+ Iterate over only the <em>dot</em> files in a directory
180
+ </p>
181
+ <pre>
182
+ rio('adir').dirs(/^\./) { |entrio| ... }
183
+ </pre>
184
+ <p>
185
+ Iterate over the files in a directory and its subdirectories, skipping
186
+ &#8217;.svn&#8217; and &#8216;CVS&#8217; directories
187
+ </p>
188
+ <pre>
189
+ rio('adir').norecurse(/^\.svn$/,'CVS').files { |entrio| ... }
190
+ </pre>
191
+ <p>
167
192
  Create an array of the .rb entries in a directory
168
193
  </p>
169
194
  <pre>
@@ -188,8 +213,7 @@ Create an array of the .rb files in a directory and its subdirectories
188
213
  anarray = rio('adir').all.files['*.rb']
189
214
  </pre>
190
215
  <p>
191
- Copy an entire directory structure but only the .rb files from a directory
192
- and its subdirectories into another directory
216
+ Copy an entire directory structure and the .rb files within it
193
217
  </p>
194
218
  <pre>
195
219
  rio('adir').dirs.files('*.rb') &gt; rio('another_directory')
@@ -231,22 +255,29 @@ Copy the first 10 lines of a file to stdout
231
255
  rio('afile').lines(0..9) &gt; rio(?-)
232
256
  </pre>
233
257
  <p>
234
- Copy the first 10 lines of a gzipped file to stdout
258
+ Copy the first 10 lines of a gzipped file on an ftp server to stdout
235
259
  </p>
236
260
  <pre>
237
- rio('afile.gz').gzip.lines(0..9) &gt; rio(?-)
261
+ rio('ftp://host/afile.gz').gzip.lines(0..9) &gt; rio(?-)
238
262
  </pre>
239
263
  <p>
240
- Copy the first 10 lines of a gzipped file on an ftp server to stdout
264
+ Put the first 100 chomped lines of a gzipped file into an array
241
265
  </p>
242
266
  <pre>
243
- rio('ftp://host/afile.gz').gzip.lines(0..9) &gt; rio(?-)
267
+ anarray = rio('afile.gz').chomp.gzip[0...100]
244
268
  </pre>
245
269
  <p>
246
- Put the first 100 chomped lines of a gzipped file into an array
270
+ Put chomped lines that start with &#8216;<a
271
+ href="../Rio.html">Rio</a>&#8217; into an array
272
+ </p>
273
+ <pre>
274
+ anarray = rio('afile').chomp[/^Rio/]
275
+ </pre>
276
+ <p>
277
+ Iterate over the non-empty, non-comment chomped lines of a file
247
278
  </p>
248
279
  <pre>
249
- anarray = rio('afile.gz').gzip[0...100]
280
+ rio('afile').chomp.nolines(:empty?,/^\s*#/) { |line| ... }
250
281
  </pre>
251
282
  <p>
252
283
  Copy the output of th ps command into an array, skipping the header line
@@ -262,9 +293,8 @@ Prompt for input and return what was typed
262
293
  ans = rio(?-).print(&quot;Type Something: &quot;).chomp.gets
263
294
  </pre>
264
295
  <p>
265
- Change the extension of all files with the extension &#8217;.htm&#8217; in
266
- a directory and its subdirectories to have the extension
267
- &#8217;.html&#8217;
296
+ Change the extension of all .htm files in a directory and its
297
+ subdirectories to .html
268
298
  </p>
269
299
  <pre>
270
300
  rio('adir').rename.all.files('*.htm') do |htmfile|
@@ -276,7 +306,7 @@ Create a symbolic link &#8216;asymlink&#8217; in &#8216;adir&#8217; which
276
306
  refers to &#8216;adir/afile&#8216;
277
307
  </p>
278
308
  <pre>
279
- rio('adir/afile').symlinke('adir/asymlink')
309
+ rio('adir/afile').symlink('adir/asymlink')
280
310
  </pre>
281
311
  <h3>SUGGESTED READING</h3>
282
312
  <ul>