rio 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +340 -0
- data/ChangeLog +755 -0
- data/README +65 -0
- data/RUNME.1st.rb +75 -0
- data/Rakefile +312 -0
- data/VERSION +1 -0
- data/doc/README_MSWIN32.txt +39 -0
- data/doc/RELEASE_NOTES +130 -0
- data/doc/generators/template/html/rio.rb +895 -0
- data/doc/rdoc/classes/Kernel.html +181 -0
- data/doc/rdoc/classes/Kernel.src/M000183.html +18 -0
- data/doc/rdoc/classes/RIO.html +508 -0
- data/doc/rdoc/classes/RIO.src/M000001.html +18 -0
- data/doc/rdoc/classes/RIO.src/M000002.html +18 -0
- data/doc/rdoc/classes/RIO.src/M000003.html +18 -0
- data/doc/rdoc/classes/RIO/Doc.html +138 -0
- data/doc/rdoc/classes/RIO/Doc/HOWTO.html +1031 -0
- data/doc/rdoc/classes/RIO/Doc/INTRO.html +1116 -0
- data/doc/rdoc/classes/RIO/Doc/MISC.html +443 -0
- data/doc/rdoc/classes/RIO/Doc/SYNOPSIS.html +325 -0
- data/doc/rdoc/classes/RIO/Rio.html +6333 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000004.html +18 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000005.html +20 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000006.html +27 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000007.html +27 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000008.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000009.html +18 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000010.html +20 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000011.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000012.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000013.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000014.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000015.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000016.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000017.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000018.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000019.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000020.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000021.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000022.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000023.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000024.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000025.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000026.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000027.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000028.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000029.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000030.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000031.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000032.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000033.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000034.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000035.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000036.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000037.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000038.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000039.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000040.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000041.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000042.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000043.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000044.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000045.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000046.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000047.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000048.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000049.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000050.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000051.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000052.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000053.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000054.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000055.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000056.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000057.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000058.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000059.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000060.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000061.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000062.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000063.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000064.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000065.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000066.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000067.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000068.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000069.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000070.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000071.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000072.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000073.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000074.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000075.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000076.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000077.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000078.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000079.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000080.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000081.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000082.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000083.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000084.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000085.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000086.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000087.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000088.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000089.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000090.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000091.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000092.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000093.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000094.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000095.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000096.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000097.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000098.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000099.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000100.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000101.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000102.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000103.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000104.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000105.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000106.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000107.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000108.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000109.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000110.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000111.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000112.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000113.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000114.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000115.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000116.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000117.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000118.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000119.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000120.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000121.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000122.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000123.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000124.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000125.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000126.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000127.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000128.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000129.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000130.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000131.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000132.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000133.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000134.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000135.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000136.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000137.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000138.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000139.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000140.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000141.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000142.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000143.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000144.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000145.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000146.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000147.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000148.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000149.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000150.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000151.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000152.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000153.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000154.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000155.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000156.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000157.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000158.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000159.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000160.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000161.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000162.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000163.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000164.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000165.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000166.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000167.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000168.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000169.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000170.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000171.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000172.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000173.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000174.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000175.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000176.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000177.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000178.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000179.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000180.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000181.html +16 -0
- data/doc/rdoc/classes/RIO/Rio.src/M000182.html +16 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/README.html +215 -0
- data/doc/rdoc/files/lib/rio/constructor_rb.html +142 -0
- data/doc/rdoc/files/lib/rio/doc/HOWTO_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/doc/INTRO_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/doc/MISC_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/doc/SYNOPSIS_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/if/basic_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/if/dir_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/if/file_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/if/fileordir_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/if/grande_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/if/internal_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/if/methods_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/if/path_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/if/stream_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/if/test_rb.html +135 -0
- data/doc/rdoc/files/lib/rio/kernel_rb.html +142 -0
- data/doc/rdoc/files/lib/rio_rb.html +153 -0
- data/doc/rdoc/fr_class_index.html +34 -0
- data/doc/rdoc/fr_file_index.html +44 -0
- data/doc/rdoc/fr_method_index.html +210 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +384 -0
- data/doc/rfc1738.txt +1403 -0
- data/doc/rfc959.txt +3933 -0
- data/ex/colx.rb +6 -0
- data/ex/findinruby +19 -0
- data/ex/findruby +11 -0
- data/ex/prompt.rb +25 -0
- data/ex/rgb.txt.gz +0 -0
- data/ex/riocat +35 -0
- data/ex/riogunzip +31 -0
- data/ex/riogzip +24 -0
- data/ex/tolf +11 -0
- data/lib/rio.rb +163 -0
- data/lib/rio/abstract_method.rb +57 -0
- data/lib/rio/argv.rb +57 -0
- data/lib/rio/arrayio.rb +199 -0
- data/lib/rio/arycopy.rb +44 -0
- data/lib/rio/assert.rb +115 -0
- data/lib/rio/base.rb +59 -0
- data/lib/rio/constructor.rb +183 -0
- data/lib/rio/context.rb +117 -0
- data/lib/rio/context/chomp.rb +53 -0
- data/lib/rio/context/closeoneof.rb +50 -0
- data/lib/rio/context/cxx.rb +67 -0
- data/lib/rio/context/dir.rb +92 -0
- data/lib/rio/context/gzip.rb +51 -0
- data/lib/rio/context/methods.rb +196 -0
- data/lib/rio/context/stream.rb +170 -0
- data/lib/rio/cp.rb +305 -0
- data/lib/rio/cxdir.rb +79 -0
- data/lib/rio/dir.rb +145 -0
- data/lib/rio/doc.rb +45 -0
- data/lib/rio/doc/HOWTO.rb +691 -0
- data/lib/rio/doc/INTRO.rb +579 -0
- data/lib/rio/doc/MISC.rb +257 -0
- data/lib/rio/doc/SYNOPSIS.rb +170 -0
- data/lib/rio/entrysel.rb +162 -0
- data/lib/rio/exception.rb +42 -0
- data/lib/rio/exception/copy.rb +98 -0
- data/lib/rio/exception/open.rb +62 -0
- data/lib/rio/exception/state.rb +74 -0
- data/lib/rio/ext.rb +62 -0
- data/lib/rio/ext/csv.rb +261 -0
- data/lib/rio/factory.rb +236 -0
- data/lib/rio/file.rb +77 -0
- data/lib/rio/filter/chomp.rb +61 -0
- data/lib/rio/filter/closeoneof.rb +103 -0
- data/lib/rio/filter/gzip.rb +58 -0
- data/lib/rio/ftp.rb +275 -0
- data/lib/rio/ftp/conn.rb +167 -0
- data/lib/rio/ftp/ioh.rb +88 -0
- data/lib/rio/grande.rb +126 -0
- data/lib/rio/handle.rb +101 -0
- data/lib/rio/if.rb +53 -0
- data/lib/rio/if/basic.rb +64 -0
- data/lib/rio/if/dir.rb +362 -0
- data/lib/rio/if/file.rb +57 -0
- data/lib/rio/if/fileordir.rb +247 -0
- data/lib/rio/if/grande.rb +510 -0
- data/lib/rio/if/internal.rb +53 -0
- data/lib/rio/if/methods.rb +612 -0
- data/lib/rio/if/path.rb +413 -0
- data/lib/rio/if/stream.rb +599 -0
- data/lib/rio/if/test.rb +219 -0
- data/lib/rio/impl/path.rb +82 -0
- data/lib/rio/ioh.rb +137 -0
- data/lib/rio/iomode.rb +96 -0
- data/lib/rio/kernel.rb +47 -0
- data/lib/rio/local.rb +63 -0
- data/lib/rio/match.rb +51 -0
- data/lib/rio/matchrecord.rb +254 -0
- data/lib/rio/open3.rb +69 -0
- data/lib/rio/ops/create.rb +78 -0
- data/lib/rio/ops/dir.rb +302 -0
- data/lib/rio/ops/either.rb +117 -0
- data/lib/rio/ops/file.rb +94 -0
- data/lib/rio/ops/path.rb +292 -0
- data/lib/rio/ops/stream.rb +84 -0
- data/lib/rio/ops/stream/input.rb +237 -0
- data/lib/rio/ops/stream/output.rb +96 -0
- data/lib/rio/ops/stream/read.rb +84 -0
- data/lib/rio/ops/stream/write.rb +58 -0
- data/lib/rio/ops/symlink.rb +70 -0
- data/lib/rio/path.rb +117 -0
- data/lib/rio/path/reset.rb +70 -0
- data/lib/rio/record.rb +59 -0
- data/lib/rio/rectype.rb +86 -0
- data/lib/rio/rl/base.rb +147 -0
- data/lib/rio/rl/builder.rb +166 -0
- data/lib/rio/rl/ioi.rb +66 -0
- data/lib/rio/rl/path.rb +141 -0
- data/lib/rio/rl/uri.rb +118 -0
- data/lib/rio/scheme/aryio.rb +89 -0
- data/lib/rio/scheme/cmdio.rb +74 -0
- data/lib/rio/scheme/fd.rb +65 -0
- data/lib/rio/scheme/ftp.rb +73 -0
- data/lib/rio/scheme/http.rb +81 -0
- data/lib/rio/scheme/path.rb +100 -0
- data/lib/rio/scheme/stderr.rb +56 -0
- data/lib/rio/scheme/stdio.rb +71 -0
- data/lib/rio/scheme/strio.rb +82 -0
- data/lib/rio/scheme/sysio.rb +61 -0
- data/lib/rio/scheme/tcp.rb +74 -0
- data/lib/rio/scheme/tempfile.rb +104 -0
- data/lib/rio/state.rb +209 -0
- data/lib/rio/state/error.rb +73 -0
- data/lib/rio/stream.rb +181 -0
- data/lib/rio/stream/base.rb +50 -0
- data/lib/rio/stream/duplex.rb +76 -0
- data/lib/rio/stream/open.rb +203 -0
- data/lib/rio/symantics.rb +46 -0
- data/lib/rio/to_rio.rb +57 -0
- data/lib/rio/uri/file.rb +145 -0
- data/lib/rio/version.rb +52 -0
- data/setup.rb +1331 -0
- data/test/1.rb +14 -0
- data/test/mswin32.rb +28 -0
- data/test/once.rb +7 -0
- data/test/runtests.rb +12 -0
- data/test/runtests_gem.rb +15 -0
- data/test/tc/abs.rb +349 -0
- data/test/tc/all.rb +42 -0
- data/test/tc/cd1.rb +116 -0
- data/test/tc/clearsel.rb +69 -0
- data/test/tc/closeoncopy.rb +91 -0
- data/test/tc/closeoneof.rb +194 -0
- data/test/tc/copy-from.rb +183 -0
- data/test/tc/copy-to.rb +94 -0
- data/test/tc/copy.rb +72 -0
- data/test/tc/copyarray.rb +191 -0
- data/test/tc/copydest.rb +50 -0
- data/test/tc/copydir.rb +192 -0
- data/test/tc/copydirlines.rb +124 -0
- data/test/tc/copylines.rb +40 -0
- data/test/tc/copynonex.rb +121 -0
- data/test/tc/create.rb +104 -0
- data/test/tc/csv.rb +229 -0
- data/test/tc/dir.rb +79 -0
- data/test/tc/dirautoclose.rb +70 -0
- data/test/tc/dirent.rb +180 -0
- data/test/tc/dirss.rb +84 -0
- data/test/tc/each.rb +111 -0
- data/test/tc/each_break.rb +241 -0
- data/test/tc/edf.rb +82 -0
- data/test/tc/entary.rb +230 -0
- data/test/tc/eq.rb +101 -0
- data/test/tc/expand_path.rb +94 -0
- data/test/tc/ext.rb +115 -0
- data/test/tc/fileno.rb +95 -0
- data/test/tc/getrec.rb +140 -0
- data/test/tc/lineno.rb +197 -0
- data/test/tc/lines.rb +66 -0
- data/test/tc/methods.rb +185 -0
- data/test/tc/misc.rb +473 -0
- data/test/tc/nolines.rb +205 -0
- data/test/tc/noqae.rb +873 -0
- data/test/tc/once.rb +6 -0
- data/test/tc/overload.rb +137 -0
- data/test/tc/pa.rb +159 -0
- data/test/tc/pathop.rb +63 -0
- data/test/tc/paths.rb +147 -0
- data/test/tc/qae.rb +494 -0
- data/test/tc/qae_riovar.rb +500 -0
- data/test/tc/records.rb +69 -0
- data/test/tc/rename.rb +224 -0
- data/test/tc/rename_assign.rb +48 -0
- data/test/tc/sub.rb +49 -0
- data/test/tc/symlink.rb +177 -0
- data/test/tc/symlink0.rb +298 -0
- data/test/tc/symlink1.rb +115 -0
- data/test/tc/testcase.rb +152 -0
- metadata +461 -0
@@ -0,0 +1,579 @@
|
|
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
|
+
module Doc
|
40
|
+
=begin rdoc
|
41
|
+
|
42
|
+
= Rio - Ruby I/O Comfort Class
|
43
|
+
|
44
|
+
Rio is a convenience class wrapping much of the functionality of
|
45
|
+
IO, File, Dir, Pathname, FileUtils,
|
46
|
+
Tempfile, StringIO, and OpenURI and uses Zlib, and CSV
|
47
|
+
to extend that functionality using a simple consistent interface.
|
48
|
+
Most of the instance methods of IO, File and Dir are simply forwarded to the appropriate handle
|
49
|
+
to provide identical functionality. Rio also provides a "grande" interface that
|
50
|
+
allows many application level IO tasks to be accomplished in line or two of code.
|
51
|
+
|
52
|
+
Rio functionality can be broadly broken into three categories
|
53
|
+
* path manipulation
|
54
|
+
* file system access
|
55
|
+
* stream manipulation
|
56
|
+
|
57
|
+
Which methods are available to a given Rio, depends on the underlying object.
|
58
|
+
|
59
|
+
A Rio generally does not need to be opened or have its mode specified.
|
60
|
+
Most of Rio's methods simply configure it.
|
61
|
+
When an actual IO operation is specified, Rio determines how to open it based
|
62
|
+
on the object it is opening, the operation it is performing, and the options specified.
|
63
|
+
|
64
|
+
Rio configuration methods return the Rio for easy chaining and regard the presence of a block
|
65
|
+
as an implied +each+.
|
66
|
+
|
67
|
+
== Using a Rio
|
68
|
+
|
69
|
+
Using a Rio can be described as having 3 steps:
|
70
|
+
* Creating a Rio (using the constructor or as the result of one of path manipulation methods)
|
71
|
+
* Configuring a Rio
|
72
|
+
* Rio I/O
|
73
|
+
|
74
|
+
=== Creating a Rio
|
75
|
+
|
76
|
+
Rio extends Kernel with one function +rio+, its constructor. This function is overloaded to
|
77
|
+
create any type of Rio. +rio+ looks at the class and sometimes the value of its first argument
|
78
|
+
to create an internal representation of the resource specified, additional arguments are used
|
79
|
+
as needed by the resource type. The rio constructor does not initiate any io, it does not check
|
80
|
+
for a resources existance or type. It neither knows nor cares what can be done with this Rio.
|
81
|
+
Using methods like +respond_to?+ are meaningless at best and usually misleading.
|
82
|
+
|
83
|
+
For purposes of discussion, we divide Rios into two catagories, those that have a path
|
84
|
+
and those that don't.
|
85
|
+
|
86
|
+
==== Creating a Rio that has a path
|
87
|
+
|
88
|
+
To create a Rio that has a path the arguments to +rio+ may be:
|
89
|
+
|
90
|
+
* a string representing the entire path. The separator used for Rios is as specified in RFC1738 ('/').
|
91
|
+
rio('adir/afile')
|
92
|
+
* a string representing a fully qualified +file+ URI as per RFC1738
|
93
|
+
rio('file:///atopleveldir/adir/afile')
|
94
|
+
* a +URI+ object representing a +file+ or generic +URI+
|
95
|
+
rio(URI('adir/afile'))
|
96
|
+
* the components of a path as separate arguments
|
97
|
+
rio('adir','afile')
|
98
|
+
* the components of a path as an array
|
99
|
+
rio(%w/adir afile/)
|
100
|
+
* another Rio
|
101
|
+
another_rio = rio('adir/afile')
|
102
|
+
rio(another_rio)
|
103
|
+
* any object whose +to_s+ method returns one of the above
|
104
|
+
rio(Pathname.new('apath'))
|
105
|
+
* any combination of the above either as separate arguments or as elements of an array,
|
106
|
+
another_rio = rio('dir1/dir2')
|
107
|
+
auri = URI('dir4/dir5)
|
108
|
+
rio(another_rio,'dir3',auri,'dir6/dir7')
|
109
|
+
|
110
|
+
===== Creating a Rio that refers to a web page
|
111
|
+
|
112
|
+
To create a Rio that refers to a web page the arguments to +rio+ may be:
|
113
|
+
|
114
|
+
* a string representing a fully qualified +http+ URI
|
115
|
+
rio('http://ruby-doc.org/index.html')
|
116
|
+
* a +URI+ object representing a +http+ +URI+
|
117
|
+
rio(URI('http://ruby-doc.org/index.html'))
|
118
|
+
* either of the above with additional path elements
|
119
|
+
rio('http://www.ruby-doc.org/','core','classes/Object.html')
|
120
|
+
|
121
|
+
===== Creating a Rio that refers to a file or directory on a FTP server
|
122
|
+
|
123
|
+
To create a Rio that refers to a file on a FTP server the arguments to +rio+ may be:
|
124
|
+
|
125
|
+
* a string representing a fully qualified +ftp+ URI
|
126
|
+
rio('ftp://user:password@ftp.example.com/afile.tar.gz')
|
127
|
+
* a +URI+ object representing a +ftp+ +URI+
|
128
|
+
rio(URI('ftp://ftp.example.com/afile.tar.gz'))
|
129
|
+
* either of the above with additional path elements
|
130
|
+
rio('ftp://ftp.gnu.org/pub/gnu','emacs','windows','README')
|
131
|
+
|
132
|
+
==== Creating Rios that do not have a path
|
133
|
+
|
134
|
+
To create a Rio without a path, the first argument to +rio+ is usually a single
|
135
|
+
character.
|
136
|
+
|
137
|
+
===== Creating a Rio that refers to a clone of your programs stdin or stdout.
|
138
|
+
|
139
|
+
<tt>rio(?-)</tt> (mnemonic: '-' is used by some Unix programs to specify stdin or stdout in place of a file)
|
140
|
+
|
141
|
+
Just as a Rio that refers to a file, does not know whether that file will be opened for reading or
|
142
|
+
writing until an io operation is specified, a +stdio:+ Rio does not know whether it will connect
|
143
|
+
to stdin or stdout until an io operation is specified.
|
144
|
+
|
145
|
+
===== Creating a Rio that refers to a clone of your programs stderr.
|
146
|
+
|
147
|
+
<tt>rio(?=)</tt> (mnemonic: '-' refers to fileno 1, so '=' refers to fileno 2)
|
148
|
+
|
149
|
+
===== Creating a Rio that refers to an arbitrary IO object.
|
150
|
+
|
151
|
+
an_io = ::File.new('afile')
|
152
|
+
rio(an_io)
|
153
|
+
|
154
|
+
===== Creating a Rio that refers to a file descriptor
|
155
|
+
|
156
|
+
<tt>rio(?#,fd)</tt> (mnemonic: a file descriptor is a number '#' )
|
157
|
+
|
158
|
+
an_io = ::File.new('afile')
|
159
|
+
rio(an_io)
|
160
|
+
|
161
|
+
===== Creating a Rio that refers to a StringIO object
|
162
|
+
|
163
|
+
<tt>rio(?")</tt> (mnemonic: '"' surrounds strings)
|
164
|
+
* create a Rio that refers to its own string
|
165
|
+
rio(?")
|
166
|
+
* create a Rio that refers to a string of your choosing
|
167
|
+
astring = ""
|
168
|
+
rio(?","")
|
169
|
+
|
170
|
+
===== Creating a Rio that refers to a Tempfile object
|
171
|
+
|
172
|
+
<tt>rio(??)</tt> (mnemonic: '?' you don't know its name)
|
173
|
+
rio(??)
|
174
|
+
rio(??,basename='rio',tmpdir=Dir::tmpdir)
|
175
|
+
|
176
|
+
===== Creating a Rio that refers to an arbitrary TCPSocket
|
177
|
+
|
178
|
+
rio('tcp:',hostname,port)
|
179
|
+
or
|
180
|
+
rio('tcp://hostname:port')
|
181
|
+
|
182
|
+
===== Creating a Rio that runs an external program and connects to its stdin and stdout
|
183
|
+
|
184
|
+
<tt>rio(?-,cmd)</tt> (mnemonic: '-' is used by some Unix programs to specify stdin or stdout in place of a file)
|
185
|
+
|
186
|
+
or
|
187
|
+
|
188
|
+
<tt>rio(?`,cmd)</tt> (mnemonic: '`' (backtick) runs an external program in ruby)
|
189
|
+
|
190
|
+
This is Rio's interface to IO#popen
|
191
|
+
|
192
|
+
=== Path Manipulation
|
193
|
+
|
194
|
+
Rio's path manipulation methods are for the most part simply forwarded to the File or URI classes with
|
195
|
+
the return values converted to a Rio.
|
196
|
+
|
197
|
+
==== Creating a Rio from a Rio's component parts.
|
198
|
+
|
199
|
+
The Rio methods for creating a Rio from a Rio's component parts are Rio#dirname,
|
200
|
+
Rio#filename, Rio#basename,
|
201
|
+
and Rio#extname.
|
202
|
+
The behavior of Rio#basename depends on the setting of the +ext+ configuration variable
|
203
|
+
and is different from its counterpart in the File class. The default value of the +ext+ configuration variable
|
204
|
+
is the string returned File#extname. The +ext+ configuration variable can be changed using Rio#ext and Rio#noext
|
205
|
+
and can be queried using Rio#ext?. This value is used by calls to Rio#basename.
|
206
|
+
|
207
|
+
Rio#filename returns the last component of a path, and is basically the same as +basename+ without consideration
|
208
|
+
of an extension. So
|
209
|
+
|
210
|
+
rio('afile.txt').basename #=> rio('afile')
|
211
|
+
rio('afile.txt').filename #=> rio('afile.txt')
|
212
|
+
|
213
|
+
ario = rio('afile.tar.gz')
|
214
|
+
ario.basename #=> rio('afile.tar')
|
215
|
+
ario.ext? #=> ".gz"
|
216
|
+
ario.ext('.tar.gz').basename #=> rio('afile')
|
217
|
+
ario.ext? #=> ".tar.gz"
|
218
|
+
|
219
|
+
==== Changing a path's component parts.
|
220
|
+
|
221
|
+
Rio also provides methods for changing the component parts of its path.
|
222
|
+
They are Rio#dirname=, Rio#filename=, Rio#basename=, and Rio#extname=. These
|
223
|
+
methods replace the part extracted as described above with their argument.
|
224
|
+
|
225
|
+
ario = rio('dirA/dirB/afile.rb')
|
226
|
+
ario.dirname = 'dirC' # rio('dirC/afile.rb')
|
227
|
+
ario.basename = 'bfile' # rio('dirC/bfile.rb')
|
228
|
+
ario.extname = '.txt' # rio('dirC/bfile.txt')
|
229
|
+
ario.filename = 'cfile.rb' # rio('dirC/cfile.rb')
|
230
|
+
|
231
|
+
Rio also has a +rename+ mode which causes each of these to rename the actual file system
|
232
|
+
object as well as changing the Rio. This is discussed in the section on
|
233
|
+
Renaming and Moving.
|
234
|
+
|
235
|
+
|
236
|
+
==== Splitting a Rio
|
237
|
+
|
238
|
+
Rio#split returns an array of Rios, one for each path element. (Note that this behavior differs
|
239
|
+
from File#split.)
|
240
|
+
|
241
|
+
rio('a/b/c').split #=> [rio('a'),rio('b'),rio('c')]
|
242
|
+
|
243
|
+
The array returned is extended with a +to_rio+ method, which will put the parts back together again.
|
244
|
+
|
245
|
+
ary = rio('a/b/c').split #=> [rio('a'),rio('b'),rio('c')]
|
246
|
+
ary.to_rio #=> rio('a/b/c')
|
247
|
+
|
248
|
+
==== Creating a Rio by specifying the individual parts of its path
|
249
|
+
|
250
|
+
The first way to create a Rio by specifying its parts is to use the Rio constructor Rio#rio. Since
|
251
|
+
a Rio is among the arguments the constructor will take, the constructor can be used.
|
252
|
+
ario = rio('adir')
|
253
|
+
rio(ario,'b') #=> rio('adir/b')
|
254
|
+
|
255
|
+
Rio#join and Rio#/ do the same thing, but the operator version <tt>/</tt> can take only one argument.
|
256
|
+
|
257
|
+
a = rio('a')
|
258
|
+
b = rio('b')
|
259
|
+
c = a.join(b) #=> rio('a/b')
|
260
|
+
c = a/b #=> rio('a/b')
|
261
|
+
|
262
|
+
The arguments to +join+ and <tt>/</tt> do not need to be Rios, of course
|
263
|
+
ario = rio('adir')
|
264
|
+
ario/'afile.rb' #=> rio('ario/afile.rb')
|
265
|
+
ario.join('b','c','d') #=> rio('ario/b/c/d')
|
266
|
+
ario/'b'/'c'/'d' #=> rio('ario/b/c/d')
|
267
|
+
ario /= 'e' #=> rio('ario/b/c/d/e')
|
268
|
+
|
269
|
+
==== Manipulating a Rio path by treating it as a string.
|
270
|
+
|
271
|
+
The Rio methods which treat a Rio as a string are Rio#sub, Rio#gsub and Rio#+.
|
272
|
+
These methods create a new Rio using the string created by forwarding the method
|
273
|
+
to the String returned by Rio#to_s.
|
274
|
+
|
275
|
+
ario = rio('dirA/dirB/afile') + '-1.1.1' # rio('dirA/dirB/afile-1.1.1')
|
276
|
+
brio = ario.sub(/^dirA/, 'dirC') # rio('dirC/dirB/afile-1.1.1')
|
277
|
+
|
278
|
+
|
279
|
+
==== Creating a Rio based on its relationship to another
|
280
|
+
|
281
|
+
Rio#abs creates a new rio whose path is the absolute path of a Rio.
|
282
|
+
If provided with an argument, it uses that as the base path, otherwise
|
283
|
+
it uses an internal base path (usually the current working directory when
|
284
|
+
it was created).
|
285
|
+
|
286
|
+
rio('/tmp').chdir do
|
287
|
+
rio('a').abs #=> rio('/tmp/a')
|
288
|
+
rio('a').abs('/usr') #=> rio('/usr/a')
|
289
|
+
end
|
290
|
+
|
291
|
+
Rio#rel creates a new rio with a path relative to a Rio.
|
292
|
+
|
293
|
+
rio('/tmp').chdir do
|
294
|
+
rio('/tmp/a').rel #=> rio('a')
|
295
|
+
end
|
296
|
+
rio('/tmp/b').rel('/tmp') #=> rio('b')
|
297
|
+
|
298
|
+
Rio#route_to and Rio#route_from creates a new rio with a path representing
|
299
|
+
the route to get to/from a Rio. They are based on the methods of the
|
300
|
+
same names in the URI class
|
301
|
+
|
302
|
+
=== Configuring a Rio
|
303
|
+
|
304
|
+
The second step in using a rio is configuring it. Note that many times no configuration is necessary
|
305
|
+
and that this is not a comprehensive list of all of Rio's configuration methods.
|
306
|
+
|
307
|
+
Rio's configuration mehods fall into three categories.
|
308
|
+
|
309
|
+
[IO manipulators]
|
310
|
+
An IO manipulator alters the behavior of a Rio's underlying IO object. These affect the behaviour
|
311
|
+
of I/O methods which are forwarded directly to the underlying object as well as the grande I/O methods.
|
312
|
+
|
313
|
+
[Grande configuration methods]
|
314
|
+
The grande configuration methods affect the behaviour of Rio's grande I/O methods
|
315
|
+
|
316
|
+
[Grande selection methods]
|
317
|
+
The grande selection methods select what data is returned by Rio's grande I/O methods
|
318
|
+
|
319
|
+
All of Rio's configuration and selection methods can be passed a block, which will cause the Rio to behave as if
|
320
|
+
+each+ had been called with the block after the method.
|
321
|
+
|
322
|
+
==== IO manipulators
|
323
|
+
|
324
|
+
* +gzip+ a file on output, and ungzip it on input
|
325
|
+
rio('afile.gz').gzip
|
326
|
+
This causes the rio to read through a Zlib::GzipReader and to write Zlib::GzipWriter.
|
327
|
+
|
328
|
+
* +chomp+ lines as they are read
|
329
|
+
rio('afile').chomp
|
330
|
+
This causes a Rio to call String#chomp on the the String returned by all line oriented read operations.
|
331
|
+
|
332
|
+
==== Grande configuration methods
|
333
|
+
|
334
|
+
* +all+, +recurse+, +norecurse+
|
335
|
+
rio('adir').all
|
336
|
+
rio('adir').norecurse('CVS')
|
337
|
+
These methods instruct the Rio to also include entries in subdirectories when iterating through directories
|
338
|
+
and control which subdirectories are included or excluded.
|
339
|
+
|
340
|
+
* +bytes+
|
341
|
+
rio('afile').bytes(1024)
|
342
|
+
This causes a Rio to read the specified number of bytes at a time as a file is iterated through.
|
343
|
+
|
344
|
+
==== Grande selection methods
|
345
|
+
|
346
|
+
* +lines+, +nolines+
|
347
|
+
rio('afile').lines(0..9)
|
348
|
+
rio('afile').nolines(/^\s*#/)
|
349
|
+
Strictly speaking these are both configuration and selection methods. They configure the Rio to
|
350
|
+
iterate through an input stream as lines. The arguments select which lines are actually returned.
|
351
|
+
Lines are included (+lines+) or excluded (+nolines+) if they match *any* of the arguments as follows.
|
352
|
+
|
353
|
+
If the argument is a:
|
354
|
+
+RegExp+:: the line is matched against it
|
355
|
+
+Range+:: the lineno is matched against it
|
356
|
+
+Integer+:: the lineno is matched against it as if it were a one element range
|
357
|
+
+Symbol+:: the symbol is +sent+ to the string; the line is included unless it returns false
|
358
|
+
+Proc+:: the proc is called with the line as an argument; the line is included unless it returns false
|
359
|
+
|
360
|
+
* +entries+, +files+, +dirs+, +noentries+, +nofiles+, +nodirs+
|
361
|
+
|
362
|
+
rio('adir').files('*.txt')
|
363
|
+
rio('adir').nofiles(/^\./)
|
364
|
+
|
365
|
+
These methods select which entries will be returned when iterating throug directories.
|
366
|
+
Entries are included (+entries+,+files+,+dirs+) or excluded(+noentries+,+nofiles+,+nodirs+) if they
|
367
|
+
match *any* of the arguments as follows.
|
368
|
+
|
369
|
+
If the argument is a:
|
370
|
+
+String+:: the arg is treated as a glob; the filname is matched against it
|
371
|
+
+RegExp+:: the filname is matched against it
|
372
|
+
+Symbol+:: the symbol is +sent+ to the entry (a Rio); the entry is included unless it returns false
|
373
|
+
+Proc+:: the proc is called with the entry (a Rio) as an argument; the entry is included unless it returns false
|
374
|
+
|
375
|
+
* +records+, +rows+, +norecords+, +norows+
|
376
|
+
rio('afile').bytes(1024).records(0...10)
|
377
|
+
These select items from an input stream just as +lines+, but without specifying lines as the input
|
378
|
+
record type. They can be used to select different record types in extension modules. The only
|
379
|
+
such module at this writing is the CSV extension. In that case +records+ causes each line of
|
380
|
+
a CSV file to be parsed into an array while +lines+ causes each line of the file to be returned normally.
|
381
|
+
|
382
|
+
=== Rio I/O
|
383
|
+
|
384
|
+
As stated above the the three steps to using a Rio are:
|
385
|
+
* Creating a Rio
|
386
|
+
* Configuring a Rio
|
387
|
+
* Doing I/O
|
388
|
+
|
389
|
+
This section describes that final step.
|
390
|
+
|
391
|
+
After creating and configuring a Rio, the file-system has not been accessed, no socket has been opened,
|
392
|
+
not so much as a test for a files existance has been done. When an I/O method is called on a Rio, the
|
393
|
+
sequence of events required to complete that operation on the underlying object takes place. Rio takes
|
394
|
+
care of creating the apropriate object (eg IO,Dir), opening the object with the apropriate mode,
|
395
|
+
performing the operation, closing the object if required, and returning the results of the operation.
|
396
|
+
|
397
|
+
Rio's I/O operations can be divide into two catagories:
|
398
|
+
* Proxy operations
|
399
|
+
* Grande operations
|
400
|
+
|
401
|
+
==== Proxy operations
|
402
|
+
|
403
|
+
These are calls which are forwarded to the underlying object (eg IO,Dir,Net::FTP), after apropriately
|
404
|
+
creating and configuring that object. The result produced by the method is returned, and
|
405
|
+
the object is closed.
|
406
|
+
|
407
|
+
In some cases the result is modified before being returned, as when a Rio is configured with +chomp+.
|
408
|
+
|
409
|
+
In all cases, if the result returned by the underlying object, could itself be used for further I/O
|
410
|
+
operations it is returned as a Rio. For example: where File#dirname returns a string, Rio#dirname
|
411
|
+
returns a Rio; where Dir#read returns a string representing a directory entry, Rio#read
|
412
|
+
returns a Rio.
|
413
|
+
|
414
|
+
With some noteable exceptions, most of the operations available if one were using the underlying
|
415
|
+
Ruby I/O class are available to the Rio and will behave identically.
|
416
|
+
|
417
|
+
For things that exist on a file system:
|
418
|
+
* All the methods in FileTest are available as Rio instance methods. For example
|
419
|
+
FileTest.file?('afile')
|
420
|
+
becomes
|
421
|
+
rio('afile').file?
|
422
|
+
* All the instance methods of +File+ except +path+ are available to a rio without change
|
423
|
+
* Most of the class methods of +File+ are available.
|
424
|
+
* For those that take a filename as their only argument the calls are mapped to
|
425
|
+
Rio instance methods as described above for FileTest.
|
426
|
+
* +dirname+, and +readlink+ return Rios instead of strings
|
427
|
+
* Rio has its own Rio#basename, Rio#join and Rio#symlink, which provide similar functionality.
|
428
|
+
* The class methods which take multiple filenames (+chmod+,+chown+,+lchmod+,+lchown+) are available
|
429
|
+
as Rio instance methods. For example
|
430
|
+
File.chmod(0666,'afile')
|
431
|
+
becomes
|
432
|
+
rio('afile').chmod(06660)
|
433
|
+
|
434
|
+
For I/O Streams
|
435
|
+
|
436
|
+
Most of the instance methods of IO are available, and most do the same thing, with some interface changes.
|
437
|
+
<b>The big exception to this is the '<<' operator.</b> This is one of Rio's grande operators. While the symantics
|
438
|
+
one would use to write to an IO object would actually accomplish the same thing with a Rio, It is a
|
439
|
+
very different operator. Read the section on grande operators. The other differences between IO
|
440
|
+
instance methods and the Rio equivelence can be summarized as follows.
|
441
|
+
* The simple instance methods (eg +fcntl+, <tt>eof?</tt>, <tt>tty?</tt> etc.)
|
442
|
+
are forwarded and the result returned as is
|
443
|
+
* Anywhere IO returns an IO, Rio returns a Rio
|
444
|
+
* +close+ and its cousins return the Rio.
|
445
|
+
* +each_byte+ and +each_line+ are forwarded as is.
|
446
|
+
* All methods which read (read*,get*,each*) will cause the file to closed when the end of file is reached.
|
447
|
+
This behavior is configurable, but the default is to close on eof
|
448
|
+
* The methods which write (put*,print*) are forwarded as is; put* and print* return the Rio; write returns
|
449
|
+
the value returned by IO#write; as mentioned above '<<' is a grande operator in Rio.
|
450
|
+
|
451
|
+
For directories:
|
452
|
+
|
453
|
+
* all the instance methods of Dir are available except +each+ which is a grande method.
|
454
|
+
* the class methods +mkdir+, +delete+, +rmdir+ are provided as instance methods.
|
455
|
+
* +chdir+ is provided as an instance method. Rio#chdir returns a Rio and passes a Rio to a block if one is provided.
|
456
|
+
* +glob+ is provided as an instance method, but returns an array of Rios
|
457
|
+
* +foreach+ is not supported
|
458
|
+
* +each+ and <tt>[]</tt> have similar functionality provided by Rio
|
459
|
+
|
460
|
+
|
461
|
+
For other Rios, instance methods are generally forwarded where appropriate. For example
|
462
|
+
|
463
|
+
* Rios that refer to StringIO objects forward 'string' and 'string='
|
464
|
+
* Rios that refer to http URIs support all the Meta methods provided by open-uri
|
465
|
+
|
466
|
+
|
467
|
+
==== Grande operators
|
468
|
+
|
469
|
+
The primary grande operator is Rio#each. +each+ is used to iterate through Rios. When applied
|
470
|
+
to a file it iterates through records in the file. When applied to a directory it iterates through
|
471
|
+
the entries in the directory. Its behavior is modified by configuring the Rio prior to calling it using
|
472
|
+
the configuration methods discussed above. Since iterating through things is ubiquitous in ruby, it is implied
|
473
|
+
by the presence of a block after any of the grande configuration methods and many times does not need to be
|
474
|
+
call explicitly. For example:
|
475
|
+
|
476
|
+
rio('afile.rb').chomp.lines(/^\s*#/) { |line| ... } # iterate through chomped ruby comment lines
|
477
|
+
rio('adir').all.files('*.rb') { |f| ... } # iterate through all .rb files in 'adir' and its subdirectories
|
478
|
+
|
479
|
+
Because a Rio is an Enumerable, it supports +to_a+, which is the basis for the grande subscript operator.
|
480
|
+
Rio#[] with no arguments simply calls to_a. With arguments it behaves as if those arguments had been
|
481
|
+
passed to the most recently called of the grande selection methods listed above, and then calls to_a. For example
|
482
|
+
to get the first ten lines of a file into an array with lines chomped
|
483
|
+
rio('afile').chomp.lines(0...10).to_a
|
484
|
+
can be written as
|
485
|
+
rio('afile.gz').chomp.lines[0...10]
|
486
|
+
or, to create an array of all the .c files in a directory, one could write
|
487
|
+
rio('adir').files['*.c']
|
488
|
+
|
489
|
+
The other grande operators are its copy operators. They are:
|
490
|
+
* <tt><</tt> (copy-from)
|
491
|
+
* <tt><<</tt> (append-from)
|
492
|
+
* <tt>></tt> (copy-to)
|
493
|
+
* <tt>>></tt> (append-to)
|
494
|
+
The only difference between the 'copy' and 'append' versions is how they deal with an unopened resource.
|
495
|
+
In the former the open it with mode 'w' and in the latter, mode 'a'.
|
496
|
+
Beyond that, their behavior can be summarized as:
|
497
|
+
source.each do |entry|
|
498
|
+
destination << entry
|
499
|
+
end
|
500
|
+
Since they are based on the +each+ operator, all of the selection and configuration options are available.
|
501
|
+
And the right-hand-side argument of the operators are not restricted to Rios -- Strings and Arrays are also supported.
|
502
|
+
|
503
|
+
For example:
|
504
|
+
rio('afile') > astring # copy a file into a string
|
505
|
+
|
506
|
+
rio('afile').chomp > anarray # copy the chomped lines of afile into an array
|
507
|
+
|
508
|
+
rio('afile.gz').gzip.lines(0...100) > rio('bfile') # copy 100 lines from a gzipped file into another file
|
509
|
+
|
510
|
+
rio(?-) < rio('http://rubydoc.org/') # copy a web page to stdout
|
511
|
+
|
512
|
+
rio('bdir') < rio('adir') # copy an entire directory structure
|
513
|
+
|
514
|
+
rio('adir').dirs.files('README') > rio('bdir') # same thing, but only README files
|
515
|
+
|
516
|
+
rio(?-,'ps -a').nolines(0,/ps$/) > anarray # copy the output of th ps command into an array, skippying
|
517
|
+
# the header line and the ps command entry
|
518
|
+
|
519
|
+
=== Renaming and Moving
|
520
|
+
|
521
|
+
Rio provides two methods for directly renaming objects on the filesystem:
|
522
|
+
Rio#rename and Rio#rename!. Both of these use File#rename. The difference
|
523
|
+
between them is the returned Rio. Rio#rename leaves the path of the Rio unchanged,
|
524
|
+
while Rio#rename! changes the path of the Rio to refer to the renamed path.
|
525
|
+
ario = rio('a')
|
526
|
+
ario.rename('b') # file 'a' has been renamed to 'b' but 'ario' => rio('a')
|
527
|
+
ario.rename!('b') # file 'a' has been renamed to 'b' and 'ario' => rio('b')
|
528
|
+
|
529
|
+
Rio also has a +rename+ mode, which causes the path manipulation methods Rio#dirname=,
|
530
|
+
Rio#filename=, Rio#basename= and Rio#extname= to rename an object on the filesystem
|
531
|
+
when they are used to change a Rio's path. A Rio is put in +rename+ mode by
|
532
|
+
calling Rio#rename with no arguments.
|
533
|
+
|
534
|
+
rio('adir/afile.txt').rename.filename = 'bfile.rb' # adir/afile.txt => adir/bfile.rb
|
535
|
+
rio('adir/afile.txt').rename.basename = 'bfile' # adir/afile.txt => adir/bfile.txt
|
536
|
+
rio('adir/afile.txt').rename.extname = '.rb' # adir/afile.txt => adir/afile.rb
|
537
|
+
rio('adir/afile.txt').rename.dirname = 'b/c' # adir/afile.txt => b/c/afile.txt
|
538
|
+
|
539
|
+
When +rename+ mode is set for a directory Rio, it is automatically set in the Rios created
|
540
|
+
when iterating through that directory.
|
541
|
+
|
542
|
+
rio('adir').rename.files('*.htm') do |frio|
|
543
|
+
frio.extname = '.html' #=> changes the rio and renames the file
|
544
|
+
end
|
545
|
+
|
546
|
+
=== Deleting
|
547
|
+
|
548
|
+
The Rio methods for deleting filesystem objects are Rio#rm, Rio#rmdir, Rio#rmtree, Rio#delete,
|
549
|
+
and Rio#delete!. +rm+, +rmdir+ and +rmtree+ are passed the like named methods in the FileUtils
|
550
|
+
module. Rio#delete calls +rmdir+ for directories and +rm+ for anything else, while Rio#delete!
|
551
|
+
calls Rio#rmtree for directories.
|
552
|
+
|
553
|
+
* To delete something only if it is not a directory use Rio#rm
|
554
|
+
* To delete an empty directory use Rio#rmdir
|
555
|
+
* To delete an entire directory tree use Rio#rmtree
|
556
|
+
* To delete anything except a populated directory use Rio#delete
|
557
|
+
* To delete anything use Rio#delete!
|
558
|
+
|
559
|
+
It is not an error to call any of the deleting methods on something that does not exist. Rio provides
|
560
|
+
Rio#exist? and Rio#symlink? to check if something exists (<tt>exist?</tt> returns false for
|
561
|
+
symlinks to non-existant object even though the symlink itself exists).
|
562
|
+
The deleting methods' purpose is to make things not exist, so
|
563
|
+
calling one of them on something that already does not exist is considered a success.
|
564
|
+
|
565
|
+
To create a clean copy of a directory whether or not anything with that name exists you might do this
|
566
|
+
rio('adir').delete!.mkpath.chdir do
|
567
|
+
# do something in adir
|
568
|
+
end
|
569
|
+
|
570
|
+
See also:
|
571
|
+
* RIO::Doc::SYNOPSIS
|
572
|
+
* RIO::Doc::HOWTO
|
573
|
+
* RIO::Rio
|
574
|
+
|
575
|
+
=end
|
576
|
+
module INTRO
|
577
|
+
end
|
578
|
+
end
|
579
|
+
end
|