rio 0.3.1

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.
Files changed (395) hide show
  1. data/COPYING +340 -0
  2. data/ChangeLog +755 -0
  3. data/README +65 -0
  4. data/RUNME.1st.rb +75 -0
  5. data/Rakefile +312 -0
  6. data/VERSION +1 -0
  7. data/doc/README_MSWIN32.txt +39 -0
  8. data/doc/RELEASE_NOTES +130 -0
  9. data/doc/generators/template/html/rio.rb +895 -0
  10. data/doc/rdoc/classes/Kernel.html +181 -0
  11. data/doc/rdoc/classes/Kernel.src/M000183.html +18 -0
  12. data/doc/rdoc/classes/RIO.html +508 -0
  13. data/doc/rdoc/classes/RIO.src/M000001.html +18 -0
  14. data/doc/rdoc/classes/RIO.src/M000002.html +18 -0
  15. data/doc/rdoc/classes/RIO.src/M000003.html +18 -0
  16. data/doc/rdoc/classes/RIO/Doc.html +138 -0
  17. data/doc/rdoc/classes/RIO/Doc/HOWTO.html +1031 -0
  18. data/doc/rdoc/classes/RIO/Doc/INTRO.html +1116 -0
  19. data/doc/rdoc/classes/RIO/Doc/MISC.html +443 -0
  20. data/doc/rdoc/classes/RIO/Doc/SYNOPSIS.html +325 -0
  21. data/doc/rdoc/classes/RIO/Rio.html +6333 -0
  22. data/doc/rdoc/classes/RIO/Rio.src/M000004.html +18 -0
  23. data/doc/rdoc/classes/RIO/Rio.src/M000005.html +20 -0
  24. data/doc/rdoc/classes/RIO/Rio.src/M000006.html +27 -0
  25. data/doc/rdoc/classes/RIO/Rio.src/M000007.html +27 -0
  26. data/doc/rdoc/classes/RIO/Rio.src/M000008.html +16 -0
  27. data/doc/rdoc/classes/RIO/Rio.src/M000009.html +18 -0
  28. data/doc/rdoc/classes/RIO/Rio.src/M000010.html +20 -0
  29. data/doc/rdoc/classes/RIO/Rio.src/M000011.html +16 -0
  30. data/doc/rdoc/classes/RIO/Rio.src/M000012.html +16 -0
  31. data/doc/rdoc/classes/RIO/Rio.src/M000013.html +16 -0
  32. data/doc/rdoc/classes/RIO/Rio.src/M000014.html +16 -0
  33. data/doc/rdoc/classes/RIO/Rio.src/M000015.html +16 -0
  34. data/doc/rdoc/classes/RIO/Rio.src/M000016.html +16 -0
  35. data/doc/rdoc/classes/RIO/Rio.src/M000017.html +16 -0
  36. data/doc/rdoc/classes/RIO/Rio.src/M000018.html +16 -0
  37. data/doc/rdoc/classes/RIO/Rio.src/M000019.html +16 -0
  38. data/doc/rdoc/classes/RIO/Rio.src/M000020.html +16 -0
  39. data/doc/rdoc/classes/RIO/Rio.src/M000021.html +16 -0
  40. data/doc/rdoc/classes/RIO/Rio.src/M000022.html +16 -0
  41. data/doc/rdoc/classes/RIO/Rio.src/M000023.html +16 -0
  42. data/doc/rdoc/classes/RIO/Rio.src/M000024.html +16 -0
  43. data/doc/rdoc/classes/RIO/Rio.src/M000025.html +16 -0
  44. data/doc/rdoc/classes/RIO/Rio.src/M000026.html +16 -0
  45. data/doc/rdoc/classes/RIO/Rio.src/M000027.html +16 -0
  46. data/doc/rdoc/classes/RIO/Rio.src/M000028.html +16 -0
  47. data/doc/rdoc/classes/RIO/Rio.src/M000029.html +16 -0
  48. data/doc/rdoc/classes/RIO/Rio.src/M000030.html +16 -0
  49. data/doc/rdoc/classes/RIO/Rio.src/M000031.html +16 -0
  50. data/doc/rdoc/classes/RIO/Rio.src/M000032.html +16 -0
  51. data/doc/rdoc/classes/RIO/Rio.src/M000033.html +16 -0
  52. data/doc/rdoc/classes/RIO/Rio.src/M000034.html +16 -0
  53. data/doc/rdoc/classes/RIO/Rio.src/M000035.html +16 -0
  54. data/doc/rdoc/classes/RIO/Rio.src/M000036.html +16 -0
  55. data/doc/rdoc/classes/RIO/Rio.src/M000037.html +16 -0
  56. data/doc/rdoc/classes/RIO/Rio.src/M000038.html +16 -0
  57. data/doc/rdoc/classes/RIO/Rio.src/M000039.html +16 -0
  58. data/doc/rdoc/classes/RIO/Rio.src/M000040.html +16 -0
  59. data/doc/rdoc/classes/RIO/Rio.src/M000041.html +16 -0
  60. data/doc/rdoc/classes/RIO/Rio.src/M000042.html +16 -0
  61. data/doc/rdoc/classes/RIO/Rio.src/M000043.html +16 -0
  62. data/doc/rdoc/classes/RIO/Rio.src/M000044.html +16 -0
  63. data/doc/rdoc/classes/RIO/Rio.src/M000045.html +16 -0
  64. data/doc/rdoc/classes/RIO/Rio.src/M000046.html +16 -0
  65. data/doc/rdoc/classes/RIO/Rio.src/M000047.html +16 -0
  66. data/doc/rdoc/classes/RIO/Rio.src/M000048.html +16 -0
  67. data/doc/rdoc/classes/RIO/Rio.src/M000049.html +16 -0
  68. data/doc/rdoc/classes/RIO/Rio.src/M000050.html +16 -0
  69. data/doc/rdoc/classes/RIO/Rio.src/M000051.html +16 -0
  70. data/doc/rdoc/classes/RIO/Rio.src/M000052.html +16 -0
  71. data/doc/rdoc/classes/RIO/Rio.src/M000053.html +16 -0
  72. data/doc/rdoc/classes/RIO/Rio.src/M000054.html +16 -0
  73. data/doc/rdoc/classes/RIO/Rio.src/M000055.html +16 -0
  74. data/doc/rdoc/classes/RIO/Rio.src/M000056.html +16 -0
  75. data/doc/rdoc/classes/RIO/Rio.src/M000057.html +16 -0
  76. data/doc/rdoc/classes/RIO/Rio.src/M000058.html +16 -0
  77. data/doc/rdoc/classes/RIO/Rio.src/M000059.html +16 -0
  78. data/doc/rdoc/classes/RIO/Rio.src/M000060.html +16 -0
  79. data/doc/rdoc/classes/RIO/Rio.src/M000061.html +16 -0
  80. data/doc/rdoc/classes/RIO/Rio.src/M000062.html +16 -0
  81. data/doc/rdoc/classes/RIO/Rio.src/M000063.html +16 -0
  82. data/doc/rdoc/classes/RIO/Rio.src/M000064.html +16 -0
  83. data/doc/rdoc/classes/RIO/Rio.src/M000065.html +16 -0
  84. data/doc/rdoc/classes/RIO/Rio.src/M000066.html +16 -0
  85. data/doc/rdoc/classes/RIO/Rio.src/M000067.html +16 -0
  86. data/doc/rdoc/classes/RIO/Rio.src/M000068.html +16 -0
  87. data/doc/rdoc/classes/RIO/Rio.src/M000069.html +16 -0
  88. data/doc/rdoc/classes/RIO/Rio.src/M000070.html +16 -0
  89. data/doc/rdoc/classes/RIO/Rio.src/M000071.html +16 -0
  90. data/doc/rdoc/classes/RIO/Rio.src/M000072.html +16 -0
  91. data/doc/rdoc/classes/RIO/Rio.src/M000073.html +16 -0
  92. data/doc/rdoc/classes/RIO/Rio.src/M000074.html +16 -0
  93. data/doc/rdoc/classes/RIO/Rio.src/M000075.html +16 -0
  94. data/doc/rdoc/classes/RIO/Rio.src/M000076.html +16 -0
  95. data/doc/rdoc/classes/RIO/Rio.src/M000077.html +16 -0
  96. data/doc/rdoc/classes/RIO/Rio.src/M000078.html +16 -0
  97. data/doc/rdoc/classes/RIO/Rio.src/M000079.html +16 -0
  98. data/doc/rdoc/classes/RIO/Rio.src/M000080.html +16 -0
  99. data/doc/rdoc/classes/RIO/Rio.src/M000081.html +16 -0
  100. data/doc/rdoc/classes/RIO/Rio.src/M000082.html +16 -0
  101. data/doc/rdoc/classes/RIO/Rio.src/M000083.html +16 -0
  102. data/doc/rdoc/classes/RIO/Rio.src/M000084.html +16 -0
  103. data/doc/rdoc/classes/RIO/Rio.src/M000085.html +16 -0
  104. data/doc/rdoc/classes/RIO/Rio.src/M000086.html +16 -0
  105. data/doc/rdoc/classes/RIO/Rio.src/M000087.html +16 -0
  106. data/doc/rdoc/classes/RIO/Rio.src/M000088.html +16 -0
  107. data/doc/rdoc/classes/RIO/Rio.src/M000089.html +16 -0
  108. data/doc/rdoc/classes/RIO/Rio.src/M000090.html +16 -0
  109. data/doc/rdoc/classes/RIO/Rio.src/M000091.html +16 -0
  110. data/doc/rdoc/classes/RIO/Rio.src/M000092.html +16 -0
  111. data/doc/rdoc/classes/RIO/Rio.src/M000093.html +16 -0
  112. data/doc/rdoc/classes/RIO/Rio.src/M000094.html +16 -0
  113. data/doc/rdoc/classes/RIO/Rio.src/M000095.html +16 -0
  114. data/doc/rdoc/classes/RIO/Rio.src/M000096.html +16 -0
  115. data/doc/rdoc/classes/RIO/Rio.src/M000097.html +16 -0
  116. data/doc/rdoc/classes/RIO/Rio.src/M000098.html +16 -0
  117. data/doc/rdoc/classes/RIO/Rio.src/M000099.html +16 -0
  118. data/doc/rdoc/classes/RIO/Rio.src/M000100.html +16 -0
  119. data/doc/rdoc/classes/RIO/Rio.src/M000101.html +16 -0
  120. data/doc/rdoc/classes/RIO/Rio.src/M000102.html +16 -0
  121. data/doc/rdoc/classes/RIO/Rio.src/M000103.html +16 -0
  122. data/doc/rdoc/classes/RIO/Rio.src/M000104.html +16 -0
  123. data/doc/rdoc/classes/RIO/Rio.src/M000105.html +16 -0
  124. data/doc/rdoc/classes/RIO/Rio.src/M000106.html +16 -0
  125. data/doc/rdoc/classes/RIO/Rio.src/M000107.html +16 -0
  126. data/doc/rdoc/classes/RIO/Rio.src/M000108.html +16 -0
  127. data/doc/rdoc/classes/RIO/Rio.src/M000109.html +16 -0
  128. data/doc/rdoc/classes/RIO/Rio.src/M000110.html +16 -0
  129. data/doc/rdoc/classes/RIO/Rio.src/M000111.html +16 -0
  130. data/doc/rdoc/classes/RIO/Rio.src/M000112.html +16 -0
  131. data/doc/rdoc/classes/RIO/Rio.src/M000113.html +16 -0
  132. data/doc/rdoc/classes/RIO/Rio.src/M000114.html +16 -0
  133. data/doc/rdoc/classes/RIO/Rio.src/M000115.html +16 -0
  134. data/doc/rdoc/classes/RIO/Rio.src/M000116.html +16 -0
  135. data/doc/rdoc/classes/RIO/Rio.src/M000117.html +16 -0
  136. data/doc/rdoc/classes/RIO/Rio.src/M000118.html +16 -0
  137. data/doc/rdoc/classes/RIO/Rio.src/M000119.html +16 -0
  138. data/doc/rdoc/classes/RIO/Rio.src/M000120.html +16 -0
  139. data/doc/rdoc/classes/RIO/Rio.src/M000121.html +16 -0
  140. data/doc/rdoc/classes/RIO/Rio.src/M000122.html +16 -0
  141. data/doc/rdoc/classes/RIO/Rio.src/M000123.html +16 -0
  142. data/doc/rdoc/classes/RIO/Rio.src/M000124.html +16 -0
  143. data/doc/rdoc/classes/RIO/Rio.src/M000125.html +16 -0
  144. data/doc/rdoc/classes/RIO/Rio.src/M000126.html +16 -0
  145. data/doc/rdoc/classes/RIO/Rio.src/M000127.html +16 -0
  146. data/doc/rdoc/classes/RIO/Rio.src/M000128.html +16 -0
  147. data/doc/rdoc/classes/RIO/Rio.src/M000129.html +16 -0
  148. data/doc/rdoc/classes/RIO/Rio.src/M000130.html +16 -0
  149. data/doc/rdoc/classes/RIO/Rio.src/M000131.html +16 -0
  150. data/doc/rdoc/classes/RIO/Rio.src/M000132.html +16 -0
  151. data/doc/rdoc/classes/RIO/Rio.src/M000133.html +16 -0
  152. data/doc/rdoc/classes/RIO/Rio.src/M000134.html +16 -0
  153. data/doc/rdoc/classes/RIO/Rio.src/M000135.html +16 -0
  154. data/doc/rdoc/classes/RIO/Rio.src/M000136.html +16 -0
  155. data/doc/rdoc/classes/RIO/Rio.src/M000137.html +16 -0
  156. data/doc/rdoc/classes/RIO/Rio.src/M000138.html +16 -0
  157. data/doc/rdoc/classes/RIO/Rio.src/M000139.html +16 -0
  158. data/doc/rdoc/classes/RIO/Rio.src/M000140.html +16 -0
  159. data/doc/rdoc/classes/RIO/Rio.src/M000141.html +16 -0
  160. data/doc/rdoc/classes/RIO/Rio.src/M000142.html +16 -0
  161. data/doc/rdoc/classes/RIO/Rio.src/M000143.html +16 -0
  162. data/doc/rdoc/classes/RIO/Rio.src/M000144.html +16 -0
  163. data/doc/rdoc/classes/RIO/Rio.src/M000145.html +16 -0
  164. data/doc/rdoc/classes/RIO/Rio.src/M000146.html +16 -0
  165. data/doc/rdoc/classes/RIO/Rio.src/M000147.html +16 -0
  166. data/doc/rdoc/classes/RIO/Rio.src/M000148.html +16 -0
  167. data/doc/rdoc/classes/RIO/Rio.src/M000149.html +16 -0
  168. data/doc/rdoc/classes/RIO/Rio.src/M000150.html +16 -0
  169. data/doc/rdoc/classes/RIO/Rio.src/M000151.html +16 -0
  170. data/doc/rdoc/classes/RIO/Rio.src/M000152.html +16 -0
  171. data/doc/rdoc/classes/RIO/Rio.src/M000153.html +16 -0
  172. data/doc/rdoc/classes/RIO/Rio.src/M000154.html +16 -0
  173. data/doc/rdoc/classes/RIO/Rio.src/M000155.html +16 -0
  174. data/doc/rdoc/classes/RIO/Rio.src/M000156.html +16 -0
  175. data/doc/rdoc/classes/RIO/Rio.src/M000157.html +16 -0
  176. data/doc/rdoc/classes/RIO/Rio.src/M000158.html +16 -0
  177. data/doc/rdoc/classes/RIO/Rio.src/M000159.html +16 -0
  178. data/doc/rdoc/classes/RIO/Rio.src/M000160.html +16 -0
  179. data/doc/rdoc/classes/RIO/Rio.src/M000161.html +16 -0
  180. data/doc/rdoc/classes/RIO/Rio.src/M000162.html +16 -0
  181. data/doc/rdoc/classes/RIO/Rio.src/M000163.html +16 -0
  182. data/doc/rdoc/classes/RIO/Rio.src/M000164.html +16 -0
  183. data/doc/rdoc/classes/RIO/Rio.src/M000165.html +16 -0
  184. data/doc/rdoc/classes/RIO/Rio.src/M000166.html +16 -0
  185. data/doc/rdoc/classes/RIO/Rio.src/M000167.html +16 -0
  186. data/doc/rdoc/classes/RIO/Rio.src/M000168.html +16 -0
  187. data/doc/rdoc/classes/RIO/Rio.src/M000169.html +16 -0
  188. data/doc/rdoc/classes/RIO/Rio.src/M000170.html +16 -0
  189. data/doc/rdoc/classes/RIO/Rio.src/M000171.html +16 -0
  190. data/doc/rdoc/classes/RIO/Rio.src/M000172.html +16 -0
  191. data/doc/rdoc/classes/RIO/Rio.src/M000173.html +16 -0
  192. data/doc/rdoc/classes/RIO/Rio.src/M000174.html +16 -0
  193. data/doc/rdoc/classes/RIO/Rio.src/M000175.html +16 -0
  194. data/doc/rdoc/classes/RIO/Rio.src/M000176.html +16 -0
  195. data/doc/rdoc/classes/RIO/Rio.src/M000177.html +16 -0
  196. data/doc/rdoc/classes/RIO/Rio.src/M000178.html +16 -0
  197. data/doc/rdoc/classes/RIO/Rio.src/M000179.html +16 -0
  198. data/doc/rdoc/classes/RIO/Rio.src/M000180.html +16 -0
  199. data/doc/rdoc/classes/RIO/Rio.src/M000181.html +16 -0
  200. data/doc/rdoc/classes/RIO/Rio.src/M000182.html +16 -0
  201. data/doc/rdoc/created.rid +1 -0
  202. data/doc/rdoc/files/README.html +215 -0
  203. data/doc/rdoc/files/lib/rio/constructor_rb.html +142 -0
  204. data/doc/rdoc/files/lib/rio/doc/HOWTO_rb.html +135 -0
  205. data/doc/rdoc/files/lib/rio/doc/INTRO_rb.html +135 -0
  206. data/doc/rdoc/files/lib/rio/doc/MISC_rb.html +135 -0
  207. data/doc/rdoc/files/lib/rio/doc/SYNOPSIS_rb.html +135 -0
  208. data/doc/rdoc/files/lib/rio/if/basic_rb.html +135 -0
  209. data/doc/rdoc/files/lib/rio/if/dir_rb.html +135 -0
  210. data/doc/rdoc/files/lib/rio/if/file_rb.html +135 -0
  211. data/doc/rdoc/files/lib/rio/if/fileordir_rb.html +135 -0
  212. data/doc/rdoc/files/lib/rio/if/grande_rb.html +135 -0
  213. data/doc/rdoc/files/lib/rio/if/internal_rb.html +135 -0
  214. data/doc/rdoc/files/lib/rio/if/methods_rb.html +135 -0
  215. data/doc/rdoc/files/lib/rio/if/path_rb.html +135 -0
  216. data/doc/rdoc/files/lib/rio/if/stream_rb.html +135 -0
  217. data/doc/rdoc/files/lib/rio/if/test_rb.html +135 -0
  218. data/doc/rdoc/files/lib/rio/kernel_rb.html +142 -0
  219. data/doc/rdoc/files/lib/rio_rb.html +153 -0
  220. data/doc/rdoc/fr_class_index.html +34 -0
  221. data/doc/rdoc/fr_file_index.html +44 -0
  222. data/doc/rdoc/fr_method_index.html +210 -0
  223. data/doc/rdoc/index.html +24 -0
  224. data/doc/rdoc/rdoc-style.css +384 -0
  225. data/doc/rfc1738.txt +1403 -0
  226. data/doc/rfc959.txt +3933 -0
  227. data/ex/colx.rb +6 -0
  228. data/ex/findinruby +19 -0
  229. data/ex/findruby +11 -0
  230. data/ex/prompt.rb +25 -0
  231. data/ex/rgb.txt.gz +0 -0
  232. data/ex/riocat +35 -0
  233. data/ex/riogunzip +31 -0
  234. data/ex/riogzip +24 -0
  235. data/ex/tolf +11 -0
  236. data/lib/rio.rb +163 -0
  237. data/lib/rio/abstract_method.rb +57 -0
  238. data/lib/rio/argv.rb +57 -0
  239. data/lib/rio/arrayio.rb +199 -0
  240. data/lib/rio/arycopy.rb +44 -0
  241. data/lib/rio/assert.rb +115 -0
  242. data/lib/rio/base.rb +59 -0
  243. data/lib/rio/constructor.rb +183 -0
  244. data/lib/rio/context.rb +117 -0
  245. data/lib/rio/context/chomp.rb +53 -0
  246. data/lib/rio/context/closeoneof.rb +50 -0
  247. data/lib/rio/context/cxx.rb +67 -0
  248. data/lib/rio/context/dir.rb +92 -0
  249. data/lib/rio/context/gzip.rb +51 -0
  250. data/lib/rio/context/methods.rb +196 -0
  251. data/lib/rio/context/stream.rb +170 -0
  252. data/lib/rio/cp.rb +305 -0
  253. data/lib/rio/cxdir.rb +79 -0
  254. data/lib/rio/dir.rb +145 -0
  255. data/lib/rio/doc.rb +45 -0
  256. data/lib/rio/doc/HOWTO.rb +691 -0
  257. data/lib/rio/doc/INTRO.rb +579 -0
  258. data/lib/rio/doc/MISC.rb +257 -0
  259. data/lib/rio/doc/SYNOPSIS.rb +170 -0
  260. data/lib/rio/entrysel.rb +162 -0
  261. data/lib/rio/exception.rb +42 -0
  262. data/lib/rio/exception/copy.rb +98 -0
  263. data/lib/rio/exception/open.rb +62 -0
  264. data/lib/rio/exception/state.rb +74 -0
  265. data/lib/rio/ext.rb +62 -0
  266. data/lib/rio/ext/csv.rb +261 -0
  267. data/lib/rio/factory.rb +236 -0
  268. data/lib/rio/file.rb +77 -0
  269. data/lib/rio/filter/chomp.rb +61 -0
  270. data/lib/rio/filter/closeoneof.rb +103 -0
  271. data/lib/rio/filter/gzip.rb +58 -0
  272. data/lib/rio/ftp.rb +275 -0
  273. data/lib/rio/ftp/conn.rb +167 -0
  274. data/lib/rio/ftp/ioh.rb +88 -0
  275. data/lib/rio/grande.rb +126 -0
  276. data/lib/rio/handle.rb +101 -0
  277. data/lib/rio/if.rb +53 -0
  278. data/lib/rio/if/basic.rb +64 -0
  279. data/lib/rio/if/dir.rb +362 -0
  280. data/lib/rio/if/file.rb +57 -0
  281. data/lib/rio/if/fileordir.rb +247 -0
  282. data/lib/rio/if/grande.rb +510 -0
  283. data/lib/rio/if/internal.rb +53 -0
  284. data/lib/rio/if/methods.rb +612 -0
  285. data/lib/rio/if/path.rb +413 -0
  286. data/lib/rio/if/stream.rb +599 -0
  287. data/lib/rio/if/test.rb +219 -0
  288. data/lib/rio/impl/path.rb +82 -0
  289. data/lib/rio/ioh.rb +137 -0
  290. data/lib/rio/iomode.rb +96 -0
  291. data/lib/rio/kernel.rb +47 -0
  292. data/lib/rio/local.rb +63 -0
  293. data/lib/rio/match.rb +51 -0
  294. data/lib/rio/matchrecord.rb +254 -0
  295. data/lib/rio/open3.rb +69 -0
  296. data/lib/rio/ops/create.rb +78 -0
  297. data/lib/rio/ops/dir.rb +302 -0
  298. data/lib/rio/ops/either.rb +117 -0
  299. data/lib/rio/ops/file.rb +94 -0
  300. data/lib/rio/ops/path.rb +292 -0
  301. data/lib/rio/ops/stream.rb +84 -0
  302. data/lib/rio/ops/stream/input.rb +237 -0
  303. data/lib/rio/ops/stream/output.rb +96 -0
  304. data/lib/rio/ops/stream/read.rb +84 -0
  305. data/lib/rio/ops/stream/write.rb +58 -0
  306. data/lib/rio/ops/symlink.rb +70 -0
  307. data/lib/rio/path.rb +117 -0
  308. data/lib/rio/path/reset.rb +70 -0
  309. data/lib/rio/record.rb +59 -0
  310. data/lib/rio/rectype.rb +86 -0
  311. data/lib/rio/rl/base.rb +147 -0
  312. data/lib/rio/rl/builder.rb +166 -0
  313. data/lib/rio/rl/ioi.rb +66 -0
  314. data/lib/rio/rl/path.rb +141 -0
  315. data/lib/rio/rl/uri.rb +118 -0
  316. data/lib/rio/scheme/aryio.rb +89 -0
  317. data/lib/rio/scheme/cmdio.rb +74 -0
  318. data/lib/rio/scheme/fd.rb +65 -0
  319. data/lib/rio/scheme/ftp.rb +73 -0
  320. data/lib/rio/scheme/http.rb +81 -0
  321. data/lib/rio/scheme/path.rb +100 -0
  322. data/lib/rio/scheme/stderr.rb +56 -0
  323. data/lib/rio/scheme/stdio.rb +71 -0
  324. data/lib/rio/scheme/strio.rb +82 -0
  325. data/lib/rio/scheme/sysio.rb +61 -0
  326. data/lib/rio/scheme/tcp.rb +74 -0
  327. data/lib/rio/scheme/tempfile.rb +104 -0
  328. data/lib/rio/state.rb +209 -0
  329. data/lib/rio/state/error.rb +73 -0
  330. data/lib/rio/stream.rb +181 -0
  331. data/lib/rio/stream/base.rb +50 -0
  332. data/lib/rio/stream/duplex.rb +76 -0
  333. data/lib/rio/stream/open.rb +203 -0
  334. data/lib/rio/symantics.rb +46 -0
  335. data/lib/rio/to_rio.rb +57 -0
  336. data/lib/rio/uri/file.rb +145 -0
  337. data/lib/rio/version.rb +52 -0
  338. data/setup.rb +1331 -0
  339. data/test/1.rb +14 -0
  340. data/test/mswin32.rb +28 -0
  341. data/test/once.rb +7 -0
  342. data/test/runtests.rb +12 -0
  343. data/test/runtests_gem.rb +15 -0
  344. data/test/tc/abs.rb +349 -0
  345. data/test/tc/all.rb +42 -0
  346. data/test/tc/cd1.rb +116 -0
  347. data/test/tc/clearsel.rb +69 -0
  348. data/test/tc/closeoncopy.rb +91 -0
  349. data/test/tc/closeoneof.rb +194 -0
  350. data/test/tc/copy-from.rb +183 -0
  351. data/test/tc/copy-to.rb +94 -0
  352. data/test/tc/copy.rb +72 -0
  353. data/test/tc/copyarray.rb +191 -0
  354. data/test/tc/copydest.rb +50 -0
  355. data/test/tc/copydir.rb +192 -0
  356. data/test/tc/copydirlines.rb +124 -0
  357. data/test/tc/copylines.rb +40 -0
  358. data/test/tc/copynonex.rb +121 -0
  359. data/test/tc/create.rb +104 -0
  360. data/test/tc/csv.rb +229 -0
  361. data/test/tc/dir.rb +79 -0
  362. data/test/tc/dirautoclose.rb +70 -0
  363. data/test/tc/dirent.rb +180 -0
  364. data/test/tc/dirss.rb +84 -0
  365. data/test/tc/each.rb +111 -0
  366. data/test/tc/each_break.rb +241 -0
  367. data/test/tc/edf.rb +82 -0
  368. data/test/tc/entary.rb +230 -0
  369. data/test/tc/eq.rb +101 -0
  370. data/test/tc/expand_path.rb +94 -0
  371. data/test/tc/ext.rb +115 -0
  372. data/test/tc/fileno.rb +95 -0
  373. data/test/tc/getrec.rb +140 -0
  374. data/test/tc/lineno.rb +197 -0
  375. data/test/tc/lines.rb +66 -0
  376. data/test/tc/methods.rb +185 -0
  377. data/test/tc/misc.rb +473 -0
  378. data/test/tc/nolines.rb +205 -0
  379. data/test/tc/noqae.rb +873 -0
  380. data/test/tc/once.rb +6 -0
  381. data/test/tc/overload.rb +137 -0
  382. data/test/tc/pa.rb +159 -0
  383. data/test/tc/pathop.rb +63 -0
  384. data/test/tc/paths.rb +147 -0
  385. data/test/tc/qae.rb +494 -0
  386. data/test/tc/qae_riovar.rb +500 -0
  387. data/test/tc/records.rb +69 -0
  388. data/test/tc/rename.rb +224 -0
  389. data/test/tc/rename_assign.rb +48 -0
  390. data/test/tc/sub.rb +49 -0
  391. data/test/tc/symlink.rb +177 -0
  392. data/test/tc/symlink0.rb +298 -0
  393. data/test/tc/symlink1.rb +115 -0
  394. data/test/tc/testcase.rb +152 -0
  395. metadata +461 -0
@@ -0,0 +1,57 @@
1
+ #--
2
+ # ===============================================================================
3
+ # Copyright (c) 2005, Christopher Kleckner
4
+ # All rights reserved
5
+ #
6
+ # This file is part of the Rio library for ruby.
7
+ #
8
+ # Rio is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # Rio is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with Rio; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # ===============================================================================
22
+ #++
23
+ #
24
+ # To create the documentation for Rio run the command
25
+ # rake rdoc
26
+ # from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
27
+ #
28
+ # Suggested Reading
29
+ # * RIO::Doc::SYNOPSIS
30
+ # * RIO::Doc::INTRO
31
+ # * RIO::Doc::HOWTO
32
+ # * RIO::Rio
33
+ #
34
+ # <b>Rio is pre-alpha software.
35
+ # The documented interface and behavior is subject to change without notice.</b>
36
+
37
+
38
+ module RIO
39
+ class Rio
40
+ # Calls FileUtils#rm
41
+ #
42
+ # Deletes the referenced file, returning the Rio. Raises an exception on any error.
43
+ #
44
+ # See also Rio#delete, Rio#delete!, Rio#rmdir.
45
+ def rm() target.rm(); self end
46
+
47
+
48
+ # Calls FileUtils#touch
49
+ #
50
+ # Updates modification time (mtime) and access time (atime) of a Rio.
51
+ # A file is created if it doesn't exist.
52
+ #
53
+ def touch() target.touch(); self end
54
+
55
+
56
+ end
57
+ end
@@ -0,0 +1,247 @@
1
+ #--
2
+ # ===============================================================================
3
+ # Copyright (c) 2005, Christopher Kleckner
4
+ # All rights reserved
5
+ #
6
+ # This file is part of the Rio library for ruby.
7
+ #
8
+ # Rio is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # Rio is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with Rio; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # ===============================================================================
22
+ #++
23
+ #
24
+ # To create the documentation for Rio run the command
25
+ # rake rdoc
26
+ # from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
27
+ #
28
+ # Suggested Reading
29
+ # * RIO::Doc::SYNOPSIS
30
+ # * RIO::Doc::INTRO
31
+ # * RIO::Doc::HOWTO
32
+ # * RIO::Rio
33
+ #
34
+ # <b>Rio is pre-alpha software.
35
+ # The documented interface and behavior is subject to change without notice.</b>
36
+
37
+
38
+ module RIO
39
+ class Rio
40
+
41
+ # Creates a symbolic link _dest_ which points to the Rio's Rio#fspath.
42
+ # Raises a NotImplementedError exception on platforms that do not support symbolic links.
43
+ # _dest_ may be a Rio, a String, or anything that will create an appropriate Rio
44
+ # when passed to Rio#new
45
+ # If _dest_ already exists and is a directory, creates a symbolic link in the _dest_ directory,
46
+ # named with the name returned by Rio#filename
47
+ # If _dest_ already exists and it is not a directory, raises Errno::EEXIST.
48
+ #
49
+ # Returns the Rio (not the symlink)
50
+ #
51
+ # Rio#symlink differs from File#symlink when the Rio or the _dest_ path has directory information.
52
+ # In this case Rio#symlink creates a symlink that actually refers to the Rio's location
53
+ # from the perspective of the link's location.
54
+ #
55
+ # For example: Given an existing file 'adir/afile' and a _dest_ of 'adir/alink'
56
+ # ::File.symlink('adir/afile','adir/alink1') # creates 'adir/alink1 -> adir/afile'
57
+ # ::File.exist?('adir/alink1') # false
58
+ # rio('adir/afile').symlink('adir/alink2') # creates 'adir/alink2 -> afile'
59
+ # ::File.exist?('adir/alink2') # true
60
+ #
61
+ # To replace an existing symlink use the following Rio idiom
62
+ # rio('afile').symlink( rio('link_name').delete ) # delete 'link_name' and recreate linked to 'afile'
63
+ #
64
+ # Examples
65
+ # rio('afile').symlink('alink') # create the symbolic link 'alink' which references 'afile'
66
+ # rio('afile').symlink('adir/alink') # create a symlink 'adir/alink' -> '../afile'
67
+ # rio('adir/afile').symlink('alink') # create a symlink 'alink' -> 'adir/afile'
68
+ # rio('adir/afile').symlink('adir/alink') # create a symlink 'adir/alink' -> 'afile'
69
+ # rio('adir/afile').symlink('adir/alink') # create a symlink 'adir/alink' -> 'afile'
70
+ # rio('adir1/afile').symlink('adir2/alink') # create a symlink 'adir2/alink' -> '../adir1/afile'
71
+ # rio('/tmp/afile').symlink('alink') # create a symlink 'adir/alink' -> '/tmp/afile'
72
+ def symlink(dest) target.symlink(dest); self end
73
+
74
+
75
+ # Calls File#readlink
76
+ #
77
+ # Returns a Rio referencing the file referenced by the given link. Not available on all platforms.
78
+ #
79
+ def readlink(*args) target.readlink(*args) end
80
+
81
+ # If called with an argument calls FileUtils#rename
82
+ # If called without an argument puts the Rio in a rename mode in
83
+ # which changes to the Rio's path affect a rename of the file
84
+ # on the file system.
85
+ #
86
+ # Proxy for FileUtils#rename
87
+ # ario = rio('afile.cpp')
88
+ # ario.rename('afile.cxx') # renamed the file, but ario still references
89
+ # # the old path
90
+ # Rename Mode
91
+ #
92
+ # Change the extension of all'.cpp' files in 'adir' to '.cxx'
93
+ # rio('adir').rename.files('*.cpp') do |file|
94
+ # file.ext = '.cxx' # 'file' references the new path and the actual file is renamed
95
+ # end
96
+ #
97
+ # Recursively change all '.tar.gz' files to '.tgz' files
98
+ # rio('adir').rename.all.files('*.tar.gz') do |gzfile|
99
+ # gzfile.ext('.tar.gz').ext = '.tgz'
100
+ # end
101
+ #
102
+ # See Rio#dirname=, Rio#filename=, Rio#basename=, and Rio#extname=
103
+ #
104
+ def rename(*args,&block) target.rename(*args,&block); self end
105
+
106
+ # For directories proxies Dir#read, otherwise proxies IO#read
107
+ #
108
+ # Proxy for IO#read
109
+ # ario.read([integer [, buffer]]) => string, buffer, or nil
110
+ # Reads at most _integer_ bytes from the I/O stream, or to the end of
111
+ # file if _integer_ is omitted or is +nil+. If the optional _buffer_
112
+ # argument is present, it must reference a String, which will receive
113
+ # the data. Returns +nil+ if called at end of file.
114
+ #
115
+ # f = rio("testfile")
116
+ # f.read(16) #=> "This is line one"
117
+ #
118
+ # rio("testfile").read(16) #=> "This is line one"
119
+ #
120
+ # Proxy for Dir#read
121
+ # dir.read => ario or nil
122
+ #------------------------------------------------------------------------
123
+ # Reads the next entry from _dir_ and returns it as a Rio. Returns
124
+ # +nil+ at the end of the stream.
125
+ # d = rio("testdir")
126
+ # d.read #=> rio(".")
127
+ # d.read #=> rio("..")
128
+ # d.read #=> rio("config.h")
129
+ #
130
+ def read(*args) target.read(*args)end
131
+
132
+ # For directories proxies Dir#rewind, otherwise proxies IO#rewind
133
+ #
134
+ # Proxy for IO#rewind
135
+ # ario.rewind => ario
136
+ # Positions _ario_ to the beginning of input, resetting lineno to zero.
137
+ #
138
+ # Returns the Rio
139
+ #
140
+ # f = rio("testfile")
141
+ # f.readline #=> "This is line one\n"
142
+ # f.rewind #=> f
143
+ # f.lineno #=> 0
144
+ # f.readline #=> "This is line one\n"
145
+ #
146
+ # f.rewind.readline #=> "This is line one\n"
147
+ #
148
+ # Proxy for Dir#rewind
149
+ # ario.rewind => ario
150
+ #------------------------------------------------------------------------
151
+ # Repositions _ario_ to the first entry.
152
+ #
153
+ # d = rio("testdir")
154
+ # d.read #=> rio(".")
155
+ # d.rewind.read #=> rio(".")
156
+ def rewind(&block) target.rewind(&block); self end
157
+
158
+ # For directories proxies Dir#seek, otherwise proxies IO#seek
159
+ #
160
+ # Proxy for IO#seek
161
+ # ario.seek(amount, whence=SEEK_SET) -> ario
162
+ # Seeks to a given offset _amount_ in the stream according to the
163
+ # value of _whence_:
164
+ #
165
+ # IO::SEEK_CUR | Seeks to <em>amount</em> plus current position
166
+ # --------------+----------------------------------------------------
167
+ # IO::SEEK_END | Seeks to <em>amount</em> plus end of stream (you probably
168
+ # | want a negative value for <em>amount</em>)
169
+ # --------------+----------------------------------------------------
170
+ # IO::SEEK_SET | Seeks to the absolute location given by <em>amount</em>
171
+ #
172
+ # Example:
173
+ #
174
+ # f = rio("testfile")
175
+ # f.seek(-28, IO::SEEK_END).readline #=> "happily ever after. The End\n"
176
+ #
177
+ # Proxy for Dir#seek
178
+ # ario.seek( integer ) => ario
179
+ # Seeks to a particular location in _ario_. _integer_ must be a value
180
+ # returned by +Dir#tell+ or Rio#tell.
181
+ #
182
+ # d = rio("testdir") #=> #<RIO::Rio:0x401b3c40>
183
+ # d.read #=> rio(".")
184
+ # i = d.tell #=> 12
185
+ # d.read #=> rio("..")
186
+ # d.seek(i) #=> #<RIO::Rio:0x401b3c40>
187
+ # d.read #=> rio("..")
188
+ def seek(*args) target.seek(*args); self end
189
+ #def seek(amount,whence=IO::SEEK_SET) target.seek(amount,whence) end
190
+
191
+
192
+
193
+ # For directories proxies Dir#pos, otherwise proxies IO#pos
194
+ #
195
+ # Proxy for IO#pos
196
+ # ario.pos => integer
197
+ # ario.tell => integer
198
+ # Returns the current offset (in bytes) of _ario_.
199
+ #
200
+ # f = rio("testfile")
201
+ # f.pos #=> 0
202
+ # f.gets #=> "This is line one\n"
203
+ # f.pos #=> 17
204
+ #
205
+ #
206
+ # Proxy for Dir#pos
207
+ # ario.pos => integer
208
+ # ario.tell => integer
209
+ # Returns the current position in _dir_. See also +Rio#seek+.
210
+ #
211
+ # d = rio("testdir")
212
+ # d.pos #=> 0
213
+ # d.read #=> rio(".")
214
+ # d.pos #=> 12
215
+ #
216
+ def pos() target.pos end
217
+
218
+ # See Rio#pos
219
+ def tell() target.tell end
220
+
221
+ # For directories proxies Dir#pos=, otherwise proxies IO#pos=
222
+ #
223
+ # Proxy for IO#pos=
224
+ # ario.pos = integer => 0
225
+ # Seeks to the given position (in bytes) in _ario_.
226
+ #
227
+ # f = rio("testfile")
228
+ # f.pos = 17
229
+ # f.gets #=> "This is line two\n"
230
+ #
231
+ # Proxy for Dir#pos=
232
+ # ario.pos = integer => integer
233
+ #------------------------------------------------------------------------
234
+ # Synonym for +Rio#seek+, but returns the position parameter.
235
+ #
236
+ # d = rio("testdir") #=> d
237
+ # d.read #=> rio(".")
238
+ # i = d.pos #=> 12
239
+ # d.read #=> rio("..")
240
+ # d.pos = i #=> 12
241
+ # d.read #=> rio("..")
242
+ #
243
+ def pos=(integer) target.pos = integer end
244
+ end
245
+ end
246
+
247
+
@@ -0,0 +1,510 @@
1
+ #--
2
+ # ===============================================================================
3
+ # Copyright (c) 2005, Christopher Kleckner
4
+ # All rights reserved
5
+ #
6
+ # This file is part of the Rio library for ruby.
7
+ #
8
+ # Rio is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # Rio is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with Rio; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # ===============================================================================
22
+ #++
23
+ #
24
+ # To create the documentation for Rio run the command
25
+ # rake rdoc
26
+ # from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
27
+ #
28
+ # Suggested Reading
29
+ # * RIO::Doc::SYNOPSIS
30
+ # * RIO::Doc::INTRO
31
+ # * RIO::Doc::HOWTO
32
+ # * RIO::Rio
33
+ #
34
+ # <b>Rio is pre-alpha software.
35
+ # The documented interface and behavior is subject to change without notice.</b>
36
+
37
+
38
+ module RIO
39
+ class Rio
40
+ # Returns the contents of the rio as an array.
41
+ # Rio#to_a is implemented in terms of Rio#each so the the following are roughly equivelent
42
+ #
43
+ # ary = ario.to_a
44
+ #
45
+ # ary = []
46
+ # ario.each do |rec|
47
+ # ary << ary
48
+ # end
49
+ #
50
+ # What constitutes an array element is determined by Rio#lines, Rio#bytes, or
51
+ # by an extension such as Rio#csv. Rio#lines is the default.
52
+ #
53
+ # rio('afile.txt').to_a # returns an array of the lines in afile.txt
54
+ #
55
+ # rio('afile.txt').lines(1...3).to_a # an array containing lines 1 and 2 of afile.txt
56
+ #
57
+ # rio('afile.dat').bytes(50).to_a # an array containing the contents of afile.dat broken
58
+ # # up into 50 byte chunks
59
+ #
60
+ # See also Rio#[] (subscript operator)
61
+ #
62
+ # def to_a() target.to_a() end
63
+
64
+ # Grande subscript operator.
65
+ #
66
+ # For files this returns all or part of a file as an array.
67
+ #
68
+ # For directories this returns all or some of the entries in a directory
69
+ #
70
+ # === Files
71
+ #
72
+ # This combines the record selection offered by Rio#records with
73
+ # the conversion to an array provided by Rio#to_a. The following two are equivelant:
74
+ # * ario[*args]
75
+ # * ario.records(*args).to_a
76
+ #
77
+ # What constitutes an array element is determined by Rio#lines, Rio#bytes,
78
+ # or by an extension such as Rio#csv. Rio#lines is the default.
79
+ #
80
+ # Arguments may consist of zero or more integers, ranges, regular expressions, symbols
81
+ # and procs.
82
+ # An empty argument list selects all records
83
+ #
84
+ # Records are selected as follows.
85
+ # range:: specifies a range of records to be selected (zero based)
86
+ # regexp:: matching records will be selected.
87
+ # integer:: treated like a one element range
88
+ # symbol:: the symbol is sent to the string. record is selected unless false is returned
89
+ # proc:: the proc is called with the string as an argument. record is selected unless false is returned
90
+ #
91
+ # A record matching *any* of the selectors will be included in the array. (acts like an _or_)
92
+ #
93
+ # Because this is implemented in terms of the Rio#each,
94
+ # When only record ranges are used to select records,
95
+ # iteration will stop when the recno exceeds the maximum of any range. That is to say
96
+ #
97
+ # This reads one record from a file and returns it
98
+ # rio('bigfile.mp3').bytes(1024)[0]
99
+ # While this reads *all* records from a file and returns the first one
100
+ # rio('bigfile.mp3').bytes(1024).to_a[0]
101
+ #
102
+ # === Directories
103
+ #
104
+ # This combines the entry selection offered by Rio#entries with
105
+ # the conversion to an array provided by Rio#to_a. The following two are equivelant:
106
+ # * ario[*args]
107
+ # * ario.entries(*args).to_a
108
+ #
109
+ # Arguments may consist of strings (treated as globs) or regular expressions.
110
+ # An empty argument list selects all entries
111
+ # See ::Dir#glob and ::File::fnmatch? for more in information on _globs_. Be warned that using the '**' glob
112
+ # recurses into directories independently of Rio#all and using both is unsupported.
113
+ #
114
+ # ario = rio('adir')
115
+ # ario[] # returns an array containg all entries in _adir_
116
+ # ario[/^zippy/] # all entries starting with 'zippy'
117
+ # ario['zippy*'] # same thing
118
+ #
119
+ # As with Rio#each:
120
+ # * Files and directories are returned as Rios
121
+ # * The types of entries is also affected by Rio#files and Rio#dirs.
122
+ # rio('adir').files['*.txt'] # array of all _.txt_ files
123
+ # rio('adir').dirs(/^\./) # array of all dot directories
124
+ # * Recursion is enabled using Rio#all
125
+ # rio('adir').all.files['*.[ch]'] # array of c source files in _adir_ and its subdirecories
126
+ # rio('adir').all.dirs[/^\.svn/] # array of subversion directories in _adir_ and subdirectories
127
+ # * Rio#files and Rio#dirs act independetly of each other. Specifying both will cause both to be returned.
128
+ # The argument list to Rio#[] will be applied to the closest.
129
+ # rio('adir').files('*.rb').dirs['ruby*'] # array of _.rb_ files and
130
+ # # directories starting with 'ruby'
131
+ # rio('adir').dirs('ruby*').files['*.rb'] # same thing
132
+ #
133
+ # === Lines
134
+ # This section applies similarly to Rio#lines, Rio#bytes, Rio#records, and Rio#rows
135
+ #
136
+ # Using Rio#lines and related methods with a Rio referencing a directory
137
+ # imples Rio#files and will cause an array of the lines or bytes in the files to be returned. As above,
138
+ # the arguments to the subscript operator will be applied to the closest.
139
+ # rio('adir').lines[] # array of all lines in the files in 'adir'
140
+ # rio('adir').files.lines[] # same thing
141
+ # rio('adir').lines(0..9).files['*.txt'] # array of the first ten lines of all .txt files
142
+ # rio('adir').files('*.txt').lines[0..9] # same thing
143
+ # rio('adir').all.files('*.rb').lines[/^\s*require/] # array of 'require' lines in .rb files in
144
+ # # 'adir and its subdirectories
145
+ #
146
+ # Note the difference between the following similar usages
147
+ # it1 = rio('adir').files('*.rb') # returns a Rio, prepared for selecting ruby files
148
+ # it2 = rio('adir').files['*.rb'] # returns an array of the ruby files
149
+ #
150
+ # The second example above could have been written
151
+ # it2 = it1.to_a
152
+ #
153
+ # Examples:
154
+ #
155
+ # rio('afile.txt').lines[1..2] # array containing the 2nd and 3rd line
156
+ #
157
+ # rio('afile.txt')[1,3..5] # array containing lines 1,3,4 and 5
158
+ #
159
+ # rio('afile.txt')[/Zippy/] # array of all lines containing 'Zippy'
160
+ #
161
+ # rio('afile.txt')[1,3..5,/Zippy/] # array with lines 1,3,4 and 5 and all lines containing 'Zippy'
162
+ #
163
+ # rio('afile.dat').bytes(50)[] # array containing the contents of afile.dat broken up into 50 byte chunks
164
+ #
165
+ # rio('afile.dat').bytes(50)[0,2] # array containing the first and third such chunk
166
+ #
167
+ # rio('afile.dat').bytes(50).records[0,2] # same thing
168
+ #
169
+ # rio('afile.dat').bytes(50).records(0,2).to_a # once again
170
+ #
171
+ # rio('afile.csv').csv[0..9] # array of the first 10 records of afile.csv parsed by the ::CSV module
172
+ #
173
+ # rio('afile.csv').csv.records[0..9] # same thing
174
+ #
175
+ # rio('afile.csv').csv(';').records[0..9] # same thing using semi-colon as the value separator
176
+ #
177
+ # rio('afile.csv').csv.records[0,/Zippy/] # record 0 and all records containing 'Zippy'
178
+ # # the regexp is matched against the line before parsing by ::CSV
179
+ #
180
+ # rio('adir')[] # array of entries in 'adir'
181
+ #
182
+ # rio('adir')['*.txt'] # array of all .txt entries
183
+ #
184
+ # rio('adir').all['*.txt'] # array of all .txt entries in 'adir and its subdirectories
185
+ #
186
+ # rio('adir').files['*.txt'] # array of all .txt files
187
+ #
188
+ # rio('adir').dirs['CSV'] # array of all CSV directories
189
+ # rio('adir').nodirs['CSV'] # array of all non-CSV directories
190
+ #
191
+ def [](*selectors) target[*selectors] end
192
+
193
+
194
+
195
+ # Iterate through a rio. Executes the block for each item selected for the Rio.
196
+ # See Rio#lines, Rio#records, Rio#bytes, Rio#files, Rio#dirs, Rio#[]
197
+ # and Rio#to_a for more information
198
+ # on how records are selected and what kind of record is passed to the block.
199
+ #
200
+ # Rio#each is the fundemental method for all the Rio grande operators.
201
+ # Rio#to_a and the Rio copy operators Rio#< Rio#<< Rio#>> Rio#> are all implemented
202
+ # in terms of Rio#each.
203
+ #
204
+ # While Rio#each is fundamental to a Rio, it rarely needs
205
+ # actually be called because all the grande configuration methods will also take a block
206
+ # and call Rio#each if one is given.
207
+ # So the existance of a block after many methods is taken as an implied
208
+ # Rio#each
209
+ #
210
+ # For Rios that refer to directories, the item passed to the block is a Rio refering to
211
+ # the directory entry.
212
+ #
213
+ # rio('adir').files.each do |file|
214
+ # file.kind_of?(RIO::Rio) # true
215
+ # end
216
+ #
217
+ # In addition, the Rio passed to the block inherits certain attributes from the directory Rio.
218
+ #
219
+ # rio('adir').files.chomp.each do |file| # chomp is ignored for directories,
220
+ # file.each do |line| # chomp attribute is inherited by the file rio
221
+ # # .. line is chomped
222
+ # end
223
+ # end
224
+ #
225
+ # Rio#each returns the Rio which called it.
226
+ #
227
+ # Here are a few illustrative examples
228
+ #
229
+ # * Processing lines in a file
230
+ #
231
+ # rio('f.txt').each { |line| ... } # execute block for every line in the file
232
+ # rio('f.txt').lines.each { |line| ... } # same thing
233
+ # rio('f.txt').lines { |line| ... } # same thing
234
+ #
235
+ # rio('f.txt').chomp.each { |line| ... } # same as above with lines chomped
236
+ # rio('f.txt').chomp { |line| ... } # ditto
237
+ # rio('f.txt').lines.chomp { |line| ... } # ditto
238
+ # rio('f.txt').chomp.lines { |line| ... } # ditto
239
+ #
240
+ # rio('f.txt.gz').gzip.each { |line| ... } # execute block for every line in a gzipped file
241
+ # rio('f.txt.gz').gzip { |line| ... } # same thing
242
+ # rio('f.txt.gz').lines.gzip { |line| ... } # same thing
243
+ #
244
+ # rio('f.txt.gz').gzip.chomp { |line| ... } # chomp lines from a gzipped file
245
+ # rio('f.txt.gz').gzip.chomp.each { |line| ... } # ditto
246
+ # rio('f.txt.gz').chomp.lines.gzip { |line| ... } # ditto
247
+ #
248
+ # rio('f.txt').lines(0..9) { |line| ... } # execute block for the first 10 lines in the file
249
+ # rio('f.txt').lines(0..9).each { |line| ... } # same thing
250
+ #
251
+ # rio('f.txt').lines(/^\s*#/) { |line| ... } # execute block for comment-only lines
252
+ # rio('f.txt').lines(/^\s*#/).each { |line| ... } # same thing
253
+ #
254
+ # rio('f.txt').lines(0,/Rio/) { |line| ... } # execute block for the first line and
255
+ # # all lines containing 'Rio'
256
+ #
257
+ # rio('f.txt.gz').gzip.chomp.lines(0..1) { |line| ... } # first 2 lines chomped from a gzip file
258
+ #
259
+ # * Processing a file a block at a time
260
+ #
261
+ # rio('f.dat').bytes(10).each { |data| ... } # process the file 10 bytes at a time
262
+ # rio('f.dat').bytes(10) { |data| ... } # same thing
263
+ # rio('f.dat').bytes(10).records(2,4) { |data| ... } # only 3rd and 5th ten-byte data-block
264
+ # rio('f.dat.gz').gzip.records(2,4).bytes(10) { |data| ... } # same from a gzipped file
265
+ #
266
+ # * Iterating over directories
267
+ # rio('adir').each { |ent| ... } # execute the block for each entry in the directory 'adir'
268
+ # rio('adir').files.each { |file| ...} # only files
269
+ # rio('adir').files { |file| ...} # ditto
270
+ # rio('adir').all.files { |file| ...} # files, recurse into subdirectories
271
+ # rio('adir').dirs { |dir| ...} # only directories
272
+ # rio('adir').files('*.rb') { |file| ...} # only .rb files using a glob
273
+ # rio('adir').files(/\.rb$/) { |file| ...} # only .rb files using a regular expression
274
+ # rio('adir').all.files('*.rb') { |file| ...} # .rb files, recursing into subdirectories
275
+ # rio('adir').dirs(/^\./) { |dir| ... } # only dot directories
276
+ # rio('adir').dirs('/home/*') { |dir| ... } # home directories
277
+ #
278
+ # See RIO::Doc::HOWTO and RIO::Doc::SYNOPSIS for more examples, and RIO::Doc::INTRO for further explanation.
279
+ #
280
+ def each(*args,&block) target.each(*args,&block); self end
281
+
282
+
283
+ # For a file Rio +delete+ calls FileUtils#rm.
284
+ # For a directory Rio +delete+ calls FileUtils#rmdir
285
+ # Returns the Rio. If the Rio does not exist, simply return the Rio.
286
+ #
287
+ # rio('afile,txt').delete # delete 'afile.txt'
288
+ # rio('adir').delete # delete adir
289
+ # rio('something').delete # delete something
290
+ #
291
+ def delete() target.delete(); self end
292
+
293
+ # For a file Rio#delete! calls FileUtils#rm.
294
+ # For a directory Rio#delete! calls FileUtils#rmtree
295
+ # Returns the Rio. If the rio does not exist, simply return itself.
296
+ #
297
+ # rio('afile,txt').delete! # delete f.txt
298
+ # rio('adir').delete! # delete adir
299
+ #
300
+ # # create a directory, after deleting anything that previously had its name
301
+ # rio('adir/asubdir').delete!.mkpath
302
+ #
303
+ # ==== Deleting Summary
304
+ # * To delete something only if it is not a directory use Rio#rm
305
+ # * To delete an empty directory use Rio#rmdir
306
+ # * To delete an entire directory tree use Rio#rmtree
307
+ # * To delete anything except a populated directory use Rio#delete
308
+ # * To delete anything use Rio#delete!
309
+ #
310
+ # In all cases, deleting something that does not exist is considered successful
311
+ #
312
+ def delete!() target.delete!(); self end
313
+
314
+ # Grande Copy-To Operator
315
+ #
316
+ # The copy grande-operator copies a Rio to a another Rio or another ruby object. The behaviour
317
+ # and the library used depend on the types of the of the source and destination. For
318
+ # simple file or directory copying ::FileUtils#cp or ::FileUtils#cp_r will be used. If
319
+ # any of the Rio grande methods are specified for the source or destination, the
320
+ # source Rio will be iterated through copying records to the destintion as specified. Roughly
321
+ # equivelant to
322
+ # dst = rio('dst_file')
323
+ # rio('src_file').each do |line|
324
+ # dst.print(line)
325
+ # end
326
+ # dst.close
327
+ #
328
+ # The destination of the copy operators may be a:
329
+ # IO:: Each record of the Rio is written to the IO using IO#print. The IO must be opened for writing.
330
+ # Array:: Each record or entry of the Rio becomes an element of the array
331
+ # String:: Puts the entire contents of the Rio into the string
332
+ # Rio:: Depends on the destination. See below.
333
+ #
334
+ # Copy a file to a file
335
+ # rio('src_file') > rio('dst_file')
336
+ #
337
+ # Copy a file to a directory
338
+ # rio('src_file') > rio('dst_dir')
339
+ #
340
+ # Copy a directory to another directory
341
+ # rio('src_dir') > rio('dst_dir')
342
+ #
343
+ # Make an ungizipped copy of a gzipped file
344
+ # rio('src.txt.gz').gzip > rio('dst.txt')
345
+ #
346
+ # Copying to an array
347
+ # rio('afile') > ary # each line of the file becomes and element of the ary
348
+ # rio('afile').chomp > ary # same thing with lines chomped
349
+ # rio('afile.gz').gzip.chomp > ary # same thing from a gzipped file
350
+ #
351
+ # rio('afile').lines(0..9) > ary # ary will contain only the first ten lines of the file
352
+ # rio('afile').chomp.lines(0..9) > ary # same thing with lines chomped
353
+ # rio('afile').gzip.chomp.lines(0..9) > ary # same thing from a gzipped file
354
+ #
355
+ # rio('afile').nolines(0..9) > ary # ary will contain all but the first ten lines of the file
356
+ #
357
+ # rio('adir') > ary # ary will contain a Rio for each entry in the directory
358
+ # rio('adir').files > ary # same, but only files
359
+ # rio('adir').files('*.rb') >ary # same, but only .rb files
360
+ #
361
+ # Copying to a string
362
+ # rio('afile') > astring # slurp the entire contents of the file into astring
363
+ # astring = rio('afile').slurp # same effect
364
+ #
365
+ # Copy the first line *and* every line containing the word Rio into a gzipped file
366
+ # rio('src').lines(1,/Rio/) > rio('dst.gz').gzip
367
+ #
368
+ # Copy lines of a web page into an array with each line chomped
369
+ # rio('http://ruby-doc.org/index.html').chomp > an_array
370
+ #
371
+ # Copy the first and 8th through 10th columns of the first ten rows of a gzipped csv
372
+ # file on a web site into a local gzipped csv file that uses semi-colons as separators
373
+ # rio('http://domain/file.csv.gz').columns(0,7..9).gzip.csv[0..9] > rio('localfile.csv.gz').csv(';').gzip
374
+ #
375
+ def >(destination) target > destination; self end
376
+
377
+ # Grande Append-To Operator
378
+ #
379
+ # The append-to grande-operator is the same as Rio#> (copy-to) except that it opens the destination
380
+ # for append.
381
+ # The destination can be a kind of:
382
+ # IO:: Each record of the Rio is written to the IO using IO#print. The IO must be opened for writing.
383
+ # Array:: Each record or entry of the Rio is appended to the destination array
384
+ # String:: Appends the entire contents of the Rio to destination
385
+ # Rio:: Just like Rio#> (copy-to) except the unopened object are
386
+ # opened for append. If the destination is already opened for writing or is a
387
+ # directory, this is identical to Rio#> (copy-to)
388
+ #
389
+ # See Rio#> (copy-to)
390
+ #
391
+ # rio('afile') >> rio('anotherfile') # append the contents of 'afile' to 'anotherfile'
392
+ # rio('afile') >> rio('adir') # copies 'afile' to the directory 'adir'
393
+ # rio('adir') >> rio('anotherdir') # copy directory 'adir' recursively to 'anotherdir'
394
+ # rio('adir') >> array # appendscopy directory 'adir' recursively to 'anotherdir'
395
+ # rio('adir') >> ary # a Rio for each entry in the directory will be appended to ary
396
+ def >>(destination) target >> destination; self end
397
+
398
+
399
+ # Grande Append-From Operator
400
+ #
401
+ # The append-from grande-operator copies a Rio from another Rio or another ruby object. This
402
+ # behaves like Rio#< (copy-from) except unopened Rios are opened for append.
403
+ #
404
+ # The following summarizes how objects are copied:
405
+ # IO:: IO#each is used to iterate through the source with each record appended to the Rio
406
+ # Array:: Each element of the Array is appended individually to the Rio.
407
+ # String:: The string is appended to the Rio using Rio#print
408
+ # Rio:: The source Rio is appended using its Rio#>> (append-to) operator
409
+ #
410
+ # See Rio#< (copy-from)
411
+ def <<(source) target << source; self end
412
+
413
+ # Grande Copy-From Operator
414
+ #
415
+ # The copy-from grande-operator copies a Rio from another Rio or another ruby object.
416
+ # Its operation is dependent on the the file system objects referenced, the rio
417
+ # options set, and the state of its source and destination. In the broadest of terms
418
+ # it could be described as doing the following:
419
+ # source.each do |entry|
420
+ # destination << entry
421
+ # end
422
+ # That is to say, it iterates through its argument, calling the copy-from operator
423
+ # again for each element. While it is not implemented like this, and the above code would
424
+ # not give the same results, This generalized description is convenient.
425
+ # For example the code:
426
+ # dst < src
427
+ # # is like
428
+ # src.each { |line| dst << line }
429
+ # for any of the following definitions of src and dst
430
+ # * copying files
431
+ # src = rio('afile')
432
+ # dst = rio('acopy')
433
+ # * copying parts of files
434
+ # src = rio('afile').lines(0..9)
435
+ # dst = rio('acopy')
436
+ # * copying directories
437
+ # src = rio('srcdir')
438
+ # dst = rio('dstdir')
439
+ # * copy directories selectively
440
+ # src = rio('srcdir').dirs(/^\./).files('*.tmp')
441
+ # dst = rio('dstdir')
442
+ # * copying to a file from an array
443
+ # src = ["line0\n","line1\n"]
444
+ # dst = rio('afile')
445
+ # * copying to a directory from an array
446
+ # array = [rio("file1"),rio("file2")]
447
+ # dst = rio('adir')
448
+ #
449
+ # Arrays are handled differently depending on whether the rio references a file or a directory.
450
+ # * If the destination is a file.
451
+ # dest = rio('afile')
452
+ # dest < array
453
+ # # is roughly equivelent to
454
+ # array.each do |el|
455
+ # case el
456
+ # when ::String then dest.print(el)
457
+ # when ::Rio then dest << el
458
+ # else dest << rio(el)
459
+ # end
460
+ # * If the destination is a directory
461
+ # dest = rio('adir')
462
+ # dest < array
463
+ # # is roughly equivelent to
464
+ # array.each do |el|
465
+ # case el
466
+ # when ::String then rio(el)
467
+ # when ::Rio then dest << el
468
+ # else dest << rio(el)
469
+ # end
470
+ #
471
+ # To improve run-time efficiency, Rio will choose from among several strategies when
472
+ # copying. For instance when no file or directory filtering is specified, FileUtils#cp_r is
473
+ # used to copy directories; and when no line filtering is specified, FileUtils#cp is used to copy
474
+ # files.
475
+ #
476
+ # rio('adir') < rio('anotherdir') # 'anotherdir' is copied to 'adir' using FileUtils#cp_r
477
+ # rio('adir') < rio('anotherdir').files('*.rb') # copy only .rb files
478
+ # rio('afile') < rio('anotherfile') # 'anotherfile' is copied to 'afile' using FileUtils#cp
479
+ # rio('afile') < ios # ios must be an IO object opened for reading
480
+ # rio('afile') < astring # basically the same as rio('afile').print(astring)
481
+ #
482
+ # anarray = [ astring, rio('anotherfile') ]
483
+ # rio('afile') < anarray # copies each element to 'afile' as if one had written
484
+ # ario = rio('afile')
485
+ # anarray.each do |el|
486
+ # ario << el
487
+ # end
488
+ # ario.close
489
+ # rio('skeldir') < rio('adir').dirs # copy only the directory structure
490
+ # rio('destdir') < rio('adir').dirs.files(/^\./) # copy the directory structure and all dot files
491
+ #
492
+ # See also Rio#> (copy-to), Rio#each, Rio#[]
493
+ #
494
+ def <(source) target < source; self end
495
+
496
+ # Reads and returns the next record from a Rio, honoring the grande selection methods.
497
+ #
498
+ # Returns nil on end of file.
499
+ #
500
+ # See also Rio#records, Rio#lines, Rio#each, Rio#[]
501
+ #
502
+ # ario = rio('afile').lines(10..12)
503
+ # line10 = ario.getrec
504
+ # line11 = ario.getrec
505
+ # line12 = ario.getrec
506
+ # a_nil = ario.getrec
507
+ def getrec() target.getrec() end
508
+
509
+ end
510
+ end