rio 0.4.2 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/Gemfile +4 -0
- data/{COPYING → LICENSE} +3 -0
- data/README +20 -27
- data/Rakefile +48 -277
- data/lib/rio.rb +63 -24
- data/lib/rio/.document +5 -0
- data/lib/rio/abstract_method.rb +3 -14
- data/lib/rio/alturi.rb +507 -0
- data/lib/rio/alturi/algorithm.rb +313 -0
- data/lib/rio/alturi/cached_fields.rb +68 -0
- data/lib/rio/alturi/escape.rb +82 -0
- data/lib/rio/alturi/parse.rb +75 -0
- data/lib/rio/alturi/path_parts.rb +81 -0
- data/lib/rio/alturi/regex.rb +76 -0
- data/lib/rio/alturi/uri_parts.rb +512 -0
- data/lib/rio/argv.rb +3 -14
- data/lib/rio/arraynge.rb +146 -0
- data/lib/rio/arycopy.rb +3 -14
- data/lib/rio/assert.rb +87 -15
- data/lib/rio/base.rb +7 -30
- data/lib/rio/callstr.rb +3 -14
- data/lib/rio/const.rb +3 -14
- data/lib/rio/construct.rb +4 -15
- data/lib/rio/constructor.rb +4 -19
- data/lib/rio/context.rb +17 -14
- data/lib/rio/context/autoclose.rb +3 -14
- data/lib/rio/context/binmode.rb +63 -0
- data/lib/rio/context/copying.rb +3 -14
- data/lib/rio/context/cxx.rb +3 -14
- data/lib/rio/context/dir.rb +5 -15
- data/lib/rio/context/encoding.rb +84 -0
- data/lib/rio/context/gzip.rb +3 -14
- data/lib/rio/context/methods.rb +8 -17
- data/lib/rio/context/skip.rb +3 -14
- data/lib/rio/context/stream.rb +3 -14
- data/lib/rio/cp.rb +5 -20
- data/lib/rio/cxuri.rb +67 -0
- data/lib/rio/dbg/trace_states.rb +18 -0
- data/lib/rio/def.rb +3 -14
- data/lib/rio/dir.rb +9 -18
- data/lib/rio/doc.rb +3 -14
- data/lib/rio/doc/EXAMPLES.rb +256 -269
- data/lib/rio/doc/HOWTO.rb +685 -707
- data/lib/rio/doc/INDEX.rb +261 -282
- data/lib/rio/doc/INTRO.rb +1029 -1040
- data/lib/rio/doc/OPTIONAL.rb +77 -103
- data/lib/rio/doc/SYNOPSIS.rb +122 -143
- data/lib/rio/entrysel.rb +3 -14
- data/lib/rio/exception.rb +4 -14
- data/lib/rio/exception/copy.rb +3 -14
- data/lib/rio/exception/notimplemented.rb +3 -14
- data/lib/rio/exception/notsupported.rb +3 -14
- data/lib/rio/exception/open.rb +3 -14
- data/lib/rio/exception/state.rb +3 -14
- data/lib/rio/ext.rb +14 -17
- data/lib/rio/ext/csv.rb +25 -304
- data/lib/rio/ext/csv/csv-legacy.rb +344 -0
- data/lib/rio/ext/csv/csv.rb +359 -0
- data/lib/rio/ext/csv/filter.rb +209 -0
- data/lib/rio/ext/if.rb +3 -14
- data/lib/rio/ext/mp3info.rb +3 -14
- data/lib/rio/ext/splitlines.rb +3 -14
- data/lib/rio/ext/yaml.rb +3 -14
- data/lib/rio/ext/yaml/doc.rb +3 -14
- data/lib/rio/ext/yaml/tie.rb +3 -14
- data/lib/rio/ext/zipfile.rb +3 -14
- data/lib/rio/ext/zipfile/fs.rb +3 -14
- data/lib/rio/ext/zipfile/rl.rb +3 -14
- data/lib/rio/ext/zipfile/rootdir.rb +3 -14
- data/lib/rio/ext/zipfile/state.rb +3 -14
- data/lib/rio/ext/zipfile/wrap.rb +3 -14
- data/lib/rio/factory.rb +96 -213
- data/lib/rio/fibpipe.rb +373 -0
- data/lib/rio/file.rb +8 -17
- data/lib/rio/filter.rb +4 -15
- data/lib/rio/filter/closeoneof.rb +3 -14
- data/lib/rio/filter/gzip.rb +18 -27
- data/lib/rio/fs.rb +172 -0
- data/lib/rio/fs/base.rb +3 -14
- data/lib/rio/fs/impl.rb +3 -14
- data/lib/rio/fs/native.rb +3 -14
- data/lib/rio/fs/stream.rb +3 -14
- data/lib/rio/fs/url.rb +3 -14
- data/lib/rio/ftp/conncache.rb +16 -18
- data/lib/rio/ftp/dir.rb +4 -15
- data/lib/rio/ftp/fs.rb +62 -42
- data/lib/rio/fwd.rb +15 -0
- data/lib/rio/grande.rb +4 -15
- data/lib/rio/handle.rb +3 -45
- data/lib/rio/if.rb +15 -20
- data/lib/rio/if/basic.rb +3 -36
- data/lib/rio/if/csv.rb +7 -20
- data/lib/rio/if/dir.rb +9 -21
- data/lib/rio/if/file.rb +6 -19
- data/lib/rio/if/fileordir.rb +18 -29
- data/lib/rio/if/grande.rb +109 -120
- data/lib/rio/if/grande_entry.rb +5 -18
- data/lib/rio/if/grande_stream.rb +29 -42
- data/lib/rio/if/internal.rb +15 -16
- data/lib/rio/if/path.rb +35 -47
- data/lib/rio/if/rubyio.rb +35 -47
- data/lib/rio/if/string.rb +3 -16
- data/lib/rio/if/temp.rb +3 -16
- data/lib/rio/if/test.rb +8 -20
- data/lib/rio/if/yaml.rb +16 -29
- data/lib/rio/ioh.rb +35 -34
- data/lib/rio/iomode.rb +3 -14
- data/lib/rio/ios/fail.rb +3 -14
- data/lib/rio/ios/generic.rb +3 -14
- data/lib/rio/ios/mode.rb +3 -14
- data/lib/rio/ios/null.rb +3 -14
- data/lib/rio/iowrap.rb +3 -14
- data/lib/rio/kernel.rb +4 -17
- data/lib/rio/local.rb +3 -14
- data/lib/rio/match.rb +3 -14
- data/lib/rio/matchrecord.rb +8 -17
- data/lib/rio/no_warn.rb +3 -14
- data/lib/rio/nullio.rb +3 -14
- data/lib/rio/open3.rb +3 -16
- data/lib/rio/ops.rb +33 -0
- data/lib/rio/ops/construct.rb +3 -14
- data/lib/rio/ops/create.rb +11 -25
- data/lib/rio/ops/dir.rb +17 -24
- data/lib/rio/ops/either.rb +28 -31
- data/lib/rio/ops/file.rb +29 -26
- data/lib/rio/ops/path.rb +65 -34
- data/lib/rio/ops/stream.rb +13 -15
- data/lib/rio/ops/stream/input.rb +59 -28
- data/lib/rio/ops/stream/output.rb +4 -14
- data/lib/rio/ops/stream/read.rb +4 -15
- data/lib/rio/ops/stream/write.rb +3 -14
- data/lib/rio/ops/symlink.rb +6 -15
- data/lib/rio/path.rb +10 -17
- data/lib/rio/path/reset.rb +3 -14
- data/lib/rio/piper.rb +3 -27
- data/lib/rio/piper/cp.rb +50 -27
- data/lib/rio/prompt.rb +3 -14
- data/lib/rio/rectype.rb +8 -16
- data/lib/rio/rl/base.rb +12 -25
- data/lib/rio/rl/builder.rb +25 -24
- data/lib/rio/rl/chmap.rb +3 -16
- data/lib/rio/rl/fs2url.rb +5 -16
- data/lib/rio/rl/ioi.rb +3 -14
- data/lib/rio/rl/path.rb +14 -25
- data/lib/rio/rl/pathmethods.rb +3 -14
- data/lib/rio/rl/uri.rb +18 -35
- data/lib/rio/rl/withpath.rb +36 -53
- data/lib/rio/rrl/base.rb +75 -0
- data/lib/rio/rrl/builder.rb +122 -0
- data/lib/rio/rrl/chmap.rb +53 -0
- data/lib/rio/rrl/ioi.rb +78 -0
- data/lib/rio/rrl/path.rb +117 -0
- data/lib/rio/rrl/withpath.rb +269 -0
- data/lib/rio/scheme/aryio.rb +3 -14
- data/lib/rio/scheme/cmdio.rb +73 -42
- data/lib/rio/scheme/cmdpipe.rb +122 -59
- data/lib/rio/scheme/fd.rb +19 -33
- data/lib/rio/scheme/ftp.rb +34 -40
- data/lib/rio/scheme/http.rb +13 -22
- data/lib/rio/scheme/null.rb +6 -17
- data/lib/rio/scheme/path.rb +60 -71
- data/lib/rio/scheme/stderr.rb +9 -21
- data/lib/rio/scheme/stdio.rb +14 -26
- data/lib/rio/scheme/strio.rb +37 -38
- data/lib/rio/scheme/sysio.rb +20 -32
- data/lib/rio/scheme/tcp.rb +3 -14
- data/lib/rio/scheme/temp.rb +103 -92
- data/lib/rio/state.rb +85 -67
- data/lib/rio/state/data.rb +55 -0
- data/lib/rio/state/error.rb +7 -27
- data/lib/rio/stream.rb +46 -19
- data/lib/rio/stream/base.rb +14 -14
- data/lib/rio/stream/duplex.rb +64 -26
- data/lib/rio/stream/open.rb +9 -19
- data/lib/rio/symantics.rb +3 -14
- data/lib/rio/tempdir.rb +8 -17
- data/lib/rio/to_rio.rb +3 -16
- data/lib/rio/to_rio/all.rb +3 -14
- data/lib/rio/to_rio/array.rb +3 -14
- data/lib/rio/to_rio/io.rb +3 -14
- data/lib/rio/to_rio/object.rb +3 -14
- data/lib/rio/to_rio/string.rb +3 -14
- data/lib/rio/uri/file.rb +98 -153
- data/lib/rio/uriref.rb +144 -0
- data/lib/rio/util.rb +3 -14
- data/lib/rio/version.rb +4 -15
- data/misc/clean-heading-comments.rb +39 -0
- data/misc/fixdoclinks.rb +36 -0
- data/misc/update-copyright.rb +17 -0
- data/rio.gemspec +31 -0
- data/test/alturi/tc/create.rb +24 -0
- data/test/alturi/tc/empty.rb +13 -0
- data/test/alturi/tc/encoding.rb +73 -0
- data/test/alturi/tc/file_test.rb +335 -0
- data/test/alturi/tc/ftp_alturi.rb +147 -0
- data/test/alturi/tc/generic_test.rb +335 -0
- data/test/alturi/tc/http_test.rb +359 -0
- data/test/alturi/tc/path_parts_test.rb +215 -0
- data/test/alturi/tc/rfc_test.rb +83 -0
- data/test/alturi/tc/uri_parts_authority.rb +129 -0
- data/test/alturi/tc/uri_parts_test.rb +473 -0
- data/test/alturi/tc/uri_parts_userinfo.rb +140 -0
- data/test/alturi/tests.rb +27 -0
- data/test/base_test.rb +18 -0
- data/test/bin/demo_chdir.rb +60 -0
- data/test/bin/elipsis.rb +11 -0
- data/test/env.sh +4 -0
- data/test/ftp/initftpfiles.rb +1 -0
- data/test/ftp/tc/anon_copy_data.rb +31 -0
- data/test/ftp/tc/anon_misc.rb +109 -0
- data/test/ftp/tc/anon_read.rb +99 -0
- data/test/ftp/tc/anon_special.rb +37 -0
- data/test/ftp/tc/anon_write.rb +68 -0
- data/test/ftp/tc/copy.rb +35 -0
- data/test/ftp/tc/empty.rb +16 -0
- data/test/ftp/tc/ftp2ftp.rb +42 -0
- data/test/ftp/tc/ftp_fs.rb +333 -0
- data/test/ftp/testdef.rb +7 -2
- data/test/ftp/tests.rb +24 -0
- data/test/gem_runtests.rb +1 -1
- data/test/http/copy-from-http.rb +0 -1
- data/test/http/def.rb +20 -0
- data/test/http/tc/copy_from_http.rb +128 -0
- data/test/http/tc/empty.rb +14 -0
- data/test/http/tc/uri_meta.rb +52 -0
- data/test/http/tests.rb +19 -0
- data/test/lib/assertions.rb +7 -0
- data/test/lib/run_tests.rb +26 -0
- data/test/lib/temp_server.rb +7 -4
- data/test/methods/test_suite.rb +108 -0
- data/test/platform.rb +5 -0
- data/test/qpdir.rb +2 -0
- data/test/rio/scheme.rb +49 -0
- data/test/rio/tc/pathparts.rb +61 -0
- data/test/riotest/test_suite.rb +33 -0
- data/test/riotest/unit_test.rb +118 -0
- data/test/riotest/util.rb +23 -0
- data/test/runalltests.rb +1 -1
- data/test/runftptests.rb +2 -7
- data/test/runhttp.rb +4 -2
- data/test/runhttptests.rb +6 -5
- data/test/runtests.rb +66 -37
- data/test/srv/www/htdocs/riotest/dir/index.html +11 -0
- data/test/srv/www/htdocs/riotest/hw.html +8 -0
- data/test/srv/www/htdocs/riotest/lines.txt.gz +0 -0
- data/test/tc/abs2.rb +358 -0
- data/test/tc/all.rb +17 -10
- data/test/tc/base2.rb +8 -7
- data/test/tc/clearsel.rb +3 -2
- data/test/tc/closeoneof.rb +14 -15
- data/test/tc/cmdio.rb +193 -0
- data/test/tc/cmdpipe.rb +258 -63
- data/test/tc/copy.rb +3 -2
- data/test/tc/copyarray.rb +0 -4
- data/test/tc/copydest.rb +2 -3
- data/test/tc/copydir.rb +5 -1
- data/test/tc/copydir2.rb +68 -0
- data/test/tc/create.rb +4 -9
- data/test/tc/csv.rb +38 -119
- data/test/tc/csv2.rb +38 -57
- data/test/tc/csv_columns.rb +210 -8
- data/test/tc/csv_gzip.rb +78 -0
- data/test/tc/csv_headers.rb +134 -0
- data/test/tc/csvutil.rb +53 -16
- data/test/tc/dir.rb +3 -4
- data/test/tc/dir_iter.rb +3 -1
- data/test/tc/dirent.rb +8 -7
- data/test/tc/each.rb +62 -47
- data/test/tc/each_break.rb +67 -25
- data/test/tc/edf.rb +3 -2
- data/test/tc/empty.rb +6 -4
- data/test/tc/encoding.rb +30 -0
- data/test/tc/entary.rb +6 -5
- data/test/tc/eq.rb +2 -2
- data/test/tc/expand_path.rb +14 -14
- data/test/tc/ext.rb +7 -7
- data/test/tc/fileno.rb +3 -2
- data/test/tc/files_select.rb +1 -1
- data/test/tc/getrec.rb +2 -3
- data/test/tc/gzip.rb +5 -3
- data/test/tc/likeio.rb +5 -5
- data/test/tc/lineno.rb +1 -1
- data/test/tc/lines.rb +4 -4
- data/test/tc/misc.rb +29 -171
- data/test/tc/nolines.rb +4 -2
- data/test/tc/noqae.rb +12 -10
- data/test/tc/overload.rb +1 -2
- data/test/tc/pa.rb +25 -24
- data/test/tc/path_parts.rb +54 -20
- data/test/tc/paths.rb +3 -2
- data/test/tc/piper.rb +32 -31
- data/test/tc/programs_util.rb +9 -9
- data/test/tc/qae.rb +9 -8
- data/test/tc/qae_riovar.rb +9 -8
- data/test/tc/records.rb +3 -2
- data/test/tc/rename.rb +4 -4
- data/test/tc/riorl.rb +19 -19
- data/test/tc/rlparts.ans.yml +1161 -0
- data/test/tc/splitlines.rb +1 -1
- data/test/tc/splitpath.rb +9 -8
- data/test/tc/strio.rb +73 -0
- data/test/tc/symlink.rb +3 -2
- data/test/tc/symlink0.rb +4 -3
- data/test/tc/symlink1.rb +4 -3
- data/test/tc/temp.rb +40 -26
- data/test/tc/tempdir.rb +12 -12
- data/test/tc/testcase.rb +45 -31
- data/test/tc/tonl.rb +0 -1
- data/test/tc/truncate.rb +111 -13
- data/test/tc/yaml.rb +1 -1
- data/test/test_suite.rb +31 -0
- data/test/tests.rb +35 -0
- data/test/tsuite.rb +19 -0
- data/test/uriref/tc/basic.rb +171 -0
- data/test/uriref/tc/build.rb +30 -0
- data/test/uriref/tc/empty.rb +13 -0
- data/test/uriref/tc/route.rb +72 -0
- data/test/uriref/tests.rb +16 -0
- metadata +356 -424
- data/ChangeLog +0 -3122
- data/VERSION +0 -1
- data/build_doc.rb +0 -94
- data/doc/ANNOUNCE +0 -157
- data/doc/RELEASE_NOTES +0 -308
- data/doc/RIOIS +0 -215
- data/doc/generators/template/html/rio.css +0 -428
- data/doc/generators/template/html/rio.rb +0 -523
- data/doc/generators/template/html/ugly.rb +0 -132
- data/doc/pkg_def.rb +0 -60
- data/doc/rdoc/classes/Kernel.html +0 -133
- data/doc/rdoc/classes/Kernel.src/M000234.html +0 -18
- data/doc/rdoc/classes/RIO.html +0 -625
- data/doc/rdoc/classes/RIO.src/M000001.html +0 -18
- data/doc/rdoc/classes/RIO.src/M000002.html +0 -18
- data/doc/rdoc/classes/RIO.src/M000003.html +0 -18
- data/doc/rdoc/classes/RIO/Doc.html +0 -149
- data/doc/rdoc/classes/RIO/Doc/EXAMPLES.html +0 -432
- data/doc/rdoc/classes/RIO/Doc/HOWTO.html +0 -1084
- data/doc/rdoc/classes/RIO/Doc/INDEX.html +0 -368
- data/doc/rdoc/classes/RIO/Doc/INTRO.html +0 -1529
- data/doc/rdoc/classes/RIO/Doc/OPTIONAL.html +0 -221
- data/doc/rdoc/classes/RIO/Doc/SYNOPSIS.html +0 -336
- data/doc/rdoc/classes/RIO/IF.html +0 -165
- data/doc/rdoc/classes/RIO/IF/CSV.html +0 -203
- data/doc/rdoc/classes/RIO/IF/CSV.src/M000129.html +0 -19
- data/doc/rdoc/classes/RIO/IF/CSV.src/M000130.html +0 -16
- data/doc/rdoc/classes/RIO/IF/CSV.src/M000131.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Dir.html +0 -343
- data/doc/rdoc/classes/RIO/IF/Dir.src/M000045.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Dir.src/M000046.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Dir.src/M000047.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Dir.src/M000048.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Dir.src/M000049.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Dir.src/M000050.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Dir.src/M000051.html +0 -16
- data/doc/rdoc/classes/RIO/IF/File.html +0 -223
- data/doc/rdoc/classes/RIO/IF/File.src/M000216.html +0 -16
- data/doc/rdoc/classes/RIO/IF/File.src/M000217.html +0 -16
- data/doc/rdoc/classes/RIO/IF/File.src/M000218.html +0 -16
- data/doc/rdoc/classes/RIO/IF/File.src/M000219.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.html +0 -572
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000117.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000118.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000119.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000120.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000121.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000122.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000123.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000124.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000125.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000126.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000127.html +0 -16
- data/doc/rdoc/classes/RIO/IF/FileOrDir.src/M000128.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.html +0 -1376
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000052.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000053.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000054.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000055.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000056.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000057.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000058.html +0 -21
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000059.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000060.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000061.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000062.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000063.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000064.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000065.html +0 -21
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000066.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000067.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000068.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000069.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Grande.src/M000070.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeEntry.html +0 -810
- data/doc/rdoc/classes/RIO/IF/GrandeEntry.src/M000107.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeEntry.src/M000108.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeEntry.src/M000109.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeEntry.src/M000110.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeEntry.src/M000111.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeEntry.src/M000112.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeEntry.src/M000113.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeEntry.src/M000114.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeEntry.src/M000115.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeEntry.src/M000116.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.html +0 -1513
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000071.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000072.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000073.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000074.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000075.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000076.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000077.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000078.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000079.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000080.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000081.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000082.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000083.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000084.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000085.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000086.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000087.html +0 -19
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000088.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000089.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000090.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000091.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000092.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000093.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000094.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000095.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000096.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000097.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000098.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000099.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000100.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000101.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000102.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000103.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000104.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000105.html +0 -16
- data/doc/rdoc/classes/RIO/IF/GrandeStream.src/M000106.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.html +0 -999
- data/doc/rdoc/classes/RIO/IF/Path.src/M000132.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000133.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000134.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000135.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000136.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000137.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000138.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000139.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000140.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000141.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000142.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000143.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000144.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000145.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000146.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000147.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000148.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000149.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000150.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000151.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000152.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000153.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000154.html +0 -18
- data/doc/rdoc/classes/RIO/IF/Path.src/M000155.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000156.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000157.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000158.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000159.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000160.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000161.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000162.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Path.src/M000163.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.html +0 -1416
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000004.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000005.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000006.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000007.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000008.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000009.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000010.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000011.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000012.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000013.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000014.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000015.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000016.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000017.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000018.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000019.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000020.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000021.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000022.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000023.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000024.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000025.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000026.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000027.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000028.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000029.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000030.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000031.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000032.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000033.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000034.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000035.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000036.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000037.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000038.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000039.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000040.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000041.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000042.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000043.html +0 -16
- data/doc/rdoc/classes/RIO/IF/RubyIO.src/M000044.html +0 -16
- data/doc/rdoc/classes/RIO/IF/String.html +0 -203
- data/doc/rdoc/classes/RIO/IF/String.src/M000213.html +0 -16
- data/doc/rdoc/classes/RIO/IF/String.src/M000214.html +0 -16
- data/doc/rdoc/classes/RIO/IF/String.src/M000215.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.html +0 -990
- data/doc/rdoc/classes/RIO/IF/Test.src/M000177.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000178.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000179.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000180.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000181.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000182.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000183.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000184.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000185.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000186.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000187.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000188.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000189.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000190.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000191.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000192.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000193.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000194.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000195.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000196.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000197.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000198.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000199.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000200.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000201.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000202.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000203.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000204.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000205.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000206.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000207.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000208.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000209.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000210.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000211.html +0 -16
- data/doc/rdoc/classes/RIO/IF/Test.src/M000212.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.html +0 -517
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000164.html +0 -19
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000165.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000166.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000167.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000168.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000169.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000170.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000171.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000172.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000173.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000174.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000175.html +0 -16
- data/doc/rdoc/classes/RIO/IF/YAML.src/M000176.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.html +0 -508
- data/doc/rdoc/classes/RIO/Rio.src/M000220.html +0 -18
- data/doc/rdoc/classes/RIO/Rio.src/M000221.html +0 -20
- data/doc/rdoc/classes/RIO/Rio.src/M000222.html +0 -27
- data/doc/rdoc/classes/RIO/Rio.src/M000223.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000225.html +0 -19
- data/doc/rdoc/classes/RIO/Rio.src/M000226.html +0 -20
- data/doc/rdoc/classes/RIO/Rio.src/M000227.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000228.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000229.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000230.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000231.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000232.html +0 -16
- data/doc/rdoc/classes/RIO/Rio.src/M000233.html +0 -16
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/README.html +0 -232
- data/doc/rdoc/files/lib/rio/constructor_rb.html +0 -141
- data/doc/rdoc/files/lib/rio/doc/EXAMPLES_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/doc/HOWTO_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/doc/INDEX_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/doc/INTRO_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/doc/OPTIONAL_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/doc/SYNOPSIS_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/basic_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/csv_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/dir_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/file_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/fileordir_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/grande_entry_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/grande_rb.html +0 -141
- data/doc/rdoc/files/lib/rio/if/grande_stream_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/internal_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/path_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/rubyio_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/string_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/temp_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/test_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/if/yaml_rb.html +0 -134
- data/doc/rdoc/files/lib/rio/kernel_rb.html +0 -142
- data/doc/rdoc/files/lib/rio_rb.html +0 -153
- data/doc/rdoc/fr_class_index.html +0 -49
- data/doc/rdoc/fr_file_index.html +0 -51
- data/doc/rdoc/fr_method_index.html +0 -260
- data/doc/rdoc/index.html +0 -30
- data/doc/rdoc/rdoc-style.css +0 -428
- data/doc/rfc1738.txt +0 -1403
- data/doc/rfc959.txt +0 -3933
- data/ex/catcsv.rb +0 -64
- data/ex/colx.rb +0 -8
- data/ex/findinruby +0 -15
- data/ex/findruby +0 -14
- data/ex/passwd_report.rb +0 -8
- data/ex/prompt.rb +0 -25
- data/ex/rgb.txt.gz +0 -0
- data/ex/riocat +0 -42
- data/ex/riogunzip +0 -31
- data/ex/riogzip +0 -24
- data/ex/rioprompt.rb +0 -10
- data/ex/targz2zip +0 -17
- data/ex/tonl +0 -10
- data/setup.rb +0 -1360
- data/test/ftp/all.rb +0 -9
- data/test/ftp/anon_copy_data.rb +0 -36
- data/test/ftp/anon_misc.rb +0 -124
- data/test/ftp/anon_read.rb +0 -105
- data/test/ftp/anon_special.rb +0 -68
- data/test/ftp/anon_write.rb +0 -70
- data/test/ftp/ftp2ftp.rb +0 -51
- data/test/tc/abs.rb +0 -355
data/test/tc/csv_columns.rb
CHANGED
@@ -19,19 +19,221 @@ class TC_csv_columns < Test::RIO::TestCase
|
|
19
19
|
super
|
20
20
|
@src = rio(?")
|
21
21
|
@dst_name = 'dst.csv'
|
22
|
-
@records,@strings,@lines,@string = create_test_csv_data(@src,
|
22
|
+
@records,@strings,@lines,@string = create_test_csv_data(@src,3, 8,',',$/, true)
|
23
|
+
if $USE_FASTER_CSV
|
24
|
+
opts = {:headers => true, :return_headers => true}
|
25
|
+
@rows = []
|
26
|
+
::CSV.parse(@string, opts) do |row|
|
27
|
+
@rows << row
|
28
|
+
end
|
29
|
+
end
|
23
30
|
end
|
24
31
|
|
32
|
+
def col_recs(r,cola)
|
33
|
+
ans = []
|
34
|
+
r.each do |rec|
|
35
|
+
row = []
|
36
|
+
cola.each do |col|
|
37
|
+
row << rec[col]
|
38
|
+
end
|
39
|
+
ans << row.flatten
|
40
|
+
end
|
41
|
+
ans
|
42
|
+
end
|
25
43
|
def test_basic
|
26
44
|
|
27
45
|
rio('src1.csv') < @src
|
28
|
-
r = @records
|
29
|
-
assert_equal(
|
30
|
-
assert_equal(
|
31
|
-
assert_equal(
|
32
|
-
assert_equal(
|
33
|
-
assert_equal([[]],rio('src1.csv').csv.skipcolumns.to_a)
|
34
|
-
assert_equal(
|
46
|
+
r = @records
|
47
|
+
assert_equal(col_recs(r,[1,2,5]),rio('src1.csv').csv.columns(1,2,5).to_a)
|
48
|
+
assert_equal(col_recs(r,(3...6).to_a),rio('src1.csv').csv.columns(3...6).to_a)
|
49
|
+
assert_equal(col_recs(r,[3,5]),rio('src1.csv').csv.columns(3...6).skipcolumns(4).to_a)
|
50
|
+
assert_equal(col_recs(r,[0,7]),rio('src1.csv').csv.skipcolumns(1..6).to_a)
|
51
|
+
assert_equal([[],[],[],[]],rio('src1.csv').csv.skipcolumns.to_a)
|
52
|
+
assert_equal(r,rio('src1.csv').csv.columns.to_a)
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_neg_recs
|
57
|
+
|
58
|
+
rio('src1.csv') < @src
|
59
|
+
r = @records
|
60
|
+
assert_equal(col_recs(r,[7]),rio('src1.csv').csv.columns(-1).to_a)
|
61
|
+
assert_equal(col_recs(r,[6]),rio('src1.csv').csv.columns(-2).to_a)
|
62
|
+
assert_equal(col_recs(r,[0..7]),rio('src1.csv').csv.columns(0..-1).to_a)
|
63
|
+
assert_equal(col_recs(r,[0..6]),rio('src1.csv').csv.columns(0..-2).to_a)
|
64
|
+
assert_equal(col_recs(r,[0...7]),rio('src1.csv').csv.columns(0...-1).to_a)
|
65
|
+
assert_equal(col_recs(r,[0...6]),rio('src1.csv').csv.columns(0...-2).to_a)
|
66
|
+
|
67
|
+
assert_equal(col_recs(r,[3..7]),rio('src1.csv').csv.columns(-5..-1).to_a)
|
68
|
+
assert_equal(col_recs(r,[3..6]),rio('src1.csv').csv.columns(-5..-2).to_a)
|
69
|
+
assert_equal(col_recs(r,[3...7]),rio('src1.csv').csv.columns(-5...-1).to_a)
|
70
|
+
assert_equal(col_recs(r,[3...6]),rio('src1.csv').csv.columns(-5...-2).to_a)
|
71
|
+
|
72
|
+
assert_equal(col_recs(r,[3..6]),rio('src1.csv').csv.columns(-5..6).to_a)
|
73
|
+
assert_equal(col_recs(r,[3..7]),rio('src1.csv').csv.columns(-5..7).to_a)
|
74
|
+
assert_equal(col_recs(r,[3..7]),rio('src1.csv').csv.columns(-5..8).to_a)
|
75
|
+
assert_equal(col_recs(r,[3..7]),rio('src1.csv').csv.columns(-5..9).to_a)
|
76
|
+
|
77
|
+
assert_equal(col_recs(r,[3...6]),rio('src1.csv').csv.columns(-5...6).to_a)
|
78
|
+
assert_equal(col_recs(r,[3...7]),rio('src1.csv').csv.columns(-5...7).to_a)
|
79
|
+
assert_equal(col_recs(r,[3...8]),rio('src1.csv').csv.columns(-5...8).to_a)
|
80
|
+
assert_equal(col_recs(r,[3...8]),rio('src1.csv').csv.columns(-5...9).to_a)
|
81
|
+
|
82
|
+
assert_equal(col_recs(r,[7..6]),rio('src1.csv').csv.columns(-1..6).to_a)
|
83
|
+
assert_equal(col_recs(r,[7..7]),rio('src1.csv').csv.columns(-1..7).to_a)
|
84
|
+
assert_equal(col_recs(r,[7..8]),rio('src1.csv').csv.columns(-1..8).to_a)
|
85
|
+
assert_equal(col_recs(r,[7..9]),rio('src1.csv').csv.columns(-1..9).to_a)
|
86
|
+
|
87
|
+
assert_equal(col_recs(r,[7...6]),rio('src1.csv').csv.columns(-1...6).to_a)
|
88
|
+
assert_equal(col_recs(r,[7...7]),rio('src1.csv').csv.columns(-1...7).to_a)
|
89
|
+
assert_equal(col_recs(r,[7...8]),rio('src1.csv').csv.columns(-1...8).to_a)
|
90
|
+
assert_equal(col_recs(r,[7...9]),rio('src1.csv').csv.columns(-1...9).to_a)
|
91
|
+
|
92
|
+
assert_equal(col_recs(r,[7..2]),rio('src1.csv').csv.columns(-1..-6).to_a)
|
93
|
+
assert_equal(col_recs(r,[7..1]),rio('src1.csv').csv.columns(-1..-7).to_a)
|
94
|
+
assert_equal(col_recs(r,[7..0]),rio('src1.csv').csv.columns(-1..-8).to_a)
|
95
|
+
assert_equal(col_recs(r,[]),rio('src1.csv').csv.columns(-1..-9).to_a)
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
def col_lines(r,cola)
|
100
|
+
ans = []
|
101
|
+
col_recs(r,cola).each do |recs|
|
102
|
+
ans << ::CSV::generate_line(recs)
|
103
|
+
end
|
104
|
+
ans
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_lines
|
108
|
+
if $USE_FASTER_CSV
|
109
|
+
rio('src1.csv') < @src
|
110
|
+
r = @records
|
111
|
+
assert_equal(col_lines(r,[1,2,5]),rio('src1.csv').csv.columns(1,2,5).lines[])
|
112
|
+
assert_equal(col_lines(r,(3...6).to_a),rio('src1.csv').csv.columns(3...6).lines[])
|
113
|
+
assert_equal(col_lines(r,[3,5]),rio('src1.csv').csv.columns(3...6).skipcolumns(4).lines[])
|
114
|
+
assert_equal(col_lines(r,[0,7]),rio('src1.csv').csv.skipcolumns(1..6).lines[])
|
115
|
+
assert_equal(["\n","\n","\n","\n"],rio('src1.csv').csv.skipcolumns.lines[])
|
116
|
+
assert_equal(col_lines(r,(0...r[0].size).to_a),rio('src1.csv').csv.columns.lines[])
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_neg_lines
|
121
|
+
|
122
|
+
rio('src1.csv') < @src
|
123
|
+
r = @records
|
124
|
+
assert_equal(col_lines(r,[7]),rio('src1.csv').csv.columns(-1).lines[])
|
125
|
+
assert_equal(col_lines(r,[6]),rio('src1.csv').csv.columns(-2).lines[])
|
126
|
+
assert_equal(col_lines(r,[0..7]),rio('src1.csv').csv.columns(0..-1).lines[])
|
127
|
+
assert_equal(col_lines(r,[0..6]),rio('src1.csv').csv.columns(0..-2).lines[])
|
128
|
+
assert_equal(col_lines(r,[0...7]),rio('src1.csv').csv.columns(0...-1).lines[])
|
129
|
+
assert_equal(col_lines(r,[0...6]),rio('src1.csv').csv.columns(0...-2).lines[])
|
130
|
+
|
131
|
+
assert_equal(col_lines(r,[3..7]),rio('src1.csv').csv.columns(-5..-1).lines[])
|
132
|
+
assert_equal(col_lines(r,[3..6]),rio('src1.csv').csv.columns(-5..-2).lines[])
|
133
|
+
assert_equal(col_lines(r,[3...7]),rio('src1.csv').csv.columns(-5...-1).lines[])
|
134
|
+
assert_equal(col_lines(r,[3...6]),rio('src1.csv').csv.columns(-5...-2).lines[])
|
135
|
+
|
136
|
+
assert_equal(col_lines(r,[3..6]),rio('src1.csv').csv.columns(-5..6).lines[])
|
137
|
+
assert_equal(col_lines(r,[3..7]),rio('src1.csv').csv.columns(-5..7).lines[])
|
138
|
+
assert_equal(col_lines(r,[3..7]),rio('src1.csv').csv.columns(-5..8).lines[])
|
139
|
+
assert_equal(col_lines(r,[3..7]),rio('src1.csv').csv.columns(-5..9).lines[])
|
140
|
+
|
141
|
+
assert_equal(col_lines(r,[3...6]),rio('src1.csv').csv.columns(-5...6).lines[])
|
142
|
+
assert_equal(col_lines(r,[3...7]),rio('src1.csv').csv.columns(-5...7).lines[])
|
143
|
+
assert_equal(col_lines(r,[3...8]),rio('src1.csv').csv.columns(-5...8).lines[])
|
144
|
+
assert_equal(col_lines(r,[3...8]),rio('src1.csv').csv.columns(-5...9).lines[])
|
145
|
+
|
146
|
+
assert_equal(col_lines(r,[7..6]),rio('src1.csv').csv.columns(-1..6).lines[])
|
147
|
+
assert_equal(col_lines(r,[7..7]),rio('src1.csv').csv.columns(-1..7).lines[])
|
148
|
+
assert_equal(col_lines(r,[7..8]),rio('src1.csv').csv.columns(-1..8).lines[])
|
149
|
+
assert_equal(col_lines(r,[7..9]),rio('src1.csv').csv.columns(-1..9).lines[])
|
150
|
+
|
151
|
+
assert_equal(col_lines(r,[7...6]),rio('src1.csv').csv.columns(-1...6).lines[])
|
152
|
+
assert_equal(col_lines(r,[7...7]),rio('src1.csv').csv.columns(-1...7).lines[])
|
153
|
+
assert_equal(col_lines(r,[7...8]),rio('src1.csv').csv.columns(-1...8).lines[])
|
154
|
+
assert_equal(col_lines(r,[7...9]),rio('src1.csv').csv.columns(-1...9).lines[])
|
155
|
+
|
156
|
+
assert_equal(col_lines(r,[7..2]),rio('src1.csv').csv.columns(-1..-6).lines[])
|
157
|
+
assert_equal(col_lines(r,[7..1]),rio('src1.csv').csv.columns(-1..-7).lines[])
|
158
|
+
assert_equal(col_lines(r,[7..0]),rio('src1.csv').csv.columns(-1..-8).lines[])
|
159
|
+
assert_equal(col_lines(r,[]),rio('src1.csv').csv.columns(-1..-9).lines[])
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
def col_rows(r,cola)
|
164
|
+
ans = []
|
165
|
+
col_recs(r,cola).each_with_index do |recs,i|
|
166
|
+
#p recs
|
167
|
+
if $USE_FASTER_CSV
|
168
|
+
ans << ::CSV::Row.new(cola.map{|n| r[0][n]},recs,i==0)
|
169
|
+
else
|
170
|
+
h = {}
|
171
|
+
recs.each_with_index do |rec,n|
|
172
|
+
#p rec,n
|
173
|
+
h["Col#{cola[n]}"] = rec
|
174
|
+
end
|
175
|
+
ans << h
|
176
|
+
end
|
177
|
+
end
|
178
|
+
first_row = ($USE_FASTER_CSV ? 1 : 0)
|
179
|
+
ans[first_row,r.size-first_row]
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_rows
|
183
|
+
rio('src1.csv') < @src
|
184
|
+
r = @records
|
185
|
+
assert_equal(col_rows(r,[1,2,5]),rio('src1.csv').csv.columns(1,2,5).rows[])
|
186
|
+
assert_equal(col_rows(r,(3...6).to_a),rio('src1.csv').csv.columns(3...6).rows[])
|
187
|
+
assert_equal(col_rows(r,[3,5]),rio('src1.csv').csv.columns(3...6).skipcolumns(4).rows[])
|
188
|
+
assert_equal(col_rows(r,[0,7]),rio('src1.csv').csv.skipcolumns(1..6).rows[])
|
189
|
+
assert_equal(col_rows(r,[]),rio('src1.csv').csv.skipcolumns(3...8,1,0..4).rows[])
|
190
|
+
assert_equal(col_rows(r,[]),rio('src1.csv').csv.skipcolumns.rows[])
|
191
|
+
assert_equal(col_rows(r,(0...r[0].size).to_a),rio('src1.csv').csv.columns.rows[])
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_neg_rows
|
195
|
+
|
196
|
+
rio('src1.csv') < @src
|
197
|
+
r = @records
|
198
|
+
assert_equal(col_rows(r,[7]),rio('src1.csv').csv.columns(-1).rows[])
|
199
|
+
assert_equal(col_rows(r,[6]),rio('src1.csv').csv.columns(-2).rows[])
|
200
|
+
assert_equal(col_rows(r,(0..7).to_a),rio('src1.csv').csv.columns(0..-1).rows[])
|
201
|
+
assert_equal(col_rows(r,(0..6).to_a),rio('src1.csv').csv.columns(0..-2).rows[])
|
202
|
+
assert_equal(col_rows(r,(0...7).to_a),rio('src1.csv').csv.columns(0...-1).rows[])
|
203
|
+
assert_equal(col_rows(r,(0...6).to_a),rio('src1.csv').csv.columns(0...-2).rows[])
|
204
|
+
|
205
|
+
assert_equal(col_rows(r,(3..7).to_a),rio('src1.csv').csv.columns(-5..-1).rows[])
|
206
|
+
assert_equal(col_rows(r,(3..6).to_a),rio('src1.csv').csv.columns(-5..-2).rows[])
|
207
|
+
assert_equal(col_rows(r,(3...7).to_a),rio('src1.csv').csv.columns(-5...-1).rows[])
|
208
|
+
assert_equal(col_rows(r,(3...6).to_a),rio('src1.csv').csv.columns(-5...-2).rows[])
|
209
|
+
|
210
|
+
assert_equal(col_rows(r,(3..6).to_a),rio('src1.csv').csv.columns(-5..6).rows[])
|
211
|
+
assert_equal(col_rows(r,(3..7).to_a),rio('src1.csv').csv.columns(-5..7).rows[])
|
212
|
+
assert_equal(col_rows(r,(3..7).to_a),rio('src1.csv').csv.columns(-5..8).rows[])
|
213
|
+
assert_equal(col_rows(r,(3..7).to_a),rio('src1.csv').csv.columns(-5..9).rows[])
|
214
|
+
|
215
|
+
assert_equal(col_rows(r,(3...6).to_a),rio('src1.csv').csv.columns(-5...6).rows[])
|
216
|
+
assert_equal(col_rows(r,(3...7).to_a),rio('src1.csv').csv.columns(-5...7).rows[])
|
217
|
+
assert_equal(col_rows(r,(3...8).to_a),rio('src1.csv').csv.columns(-5...8).rows[])
|
218
|
+
assert_equal(col_rows(r,(3...8).to_a),rio('src1.csv').csv.columns(-5...9).rows[])
|
219
|
+
|
220
|
+
assert_equal(col_rows(r,(7..6).to_a),rio('src1.csv').csv.columns(-1..6).rows[])
|
221
|
+
assert_equal(col_rows(r,(7..7).to_a),rio('src1.csv').csv.columns(-1..7).rows[])
|
222
|
+
assert_equal(col_rows(r,(7..7).to_a),rio('src1.csv').csv.columns(-1..8).rows[])
|
223
|
+
assert_equal(col_rows(r,(7..7).to_a),rio('src1.csv').csv.columns(-1..9).rows[])
|
224
|
+
|
225
|
+
assert_equal(col_rows(r,(7...6).to_a),rio('src1.csv').csv.columns(-1...6).rows[])
|
226
|
+
assert_equal(col_rows(r,(7...7).to_a),rio('src1.csv').csv.columns(-1...7).rows[])
|
227
|
+
assert_equal(col_rows(r,(7...8).to_a),rio('src1.csv').csv.columns(-1...8).rows[])
|
228
|
+
assert_equal(col_rows(r,(7...8).to_a),rio('src1.csv').csv.columns(-1...9).rows[])
|
229
|
+
|
230
|
+
assert_equal(col_rows(r,(7..2).to_a),rio('src1.csv').csv.columns(-1..-6).rows[])
|
231
|
+
assert_equal(col_rows(r,(7..1).to_a),rio('src1.csv').csv.columns(-1..-7).rows[])
|
232
|
+
assert_equal(col_rows(r,(7..0).to_a),rio('src1.csv').csv.columns(-1..-8).rows[])
|
233
|
+
assert_equal(col_rows(r,[]),rio('src1.csv').csv.columns(-1..-9).rows[])
|
35
234
|
|
36
235
|
end
|
236
|
+
|
237
|
+
|
238
|
+
|
37
239
|
end
|
data/test/tc/csv_gzip.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
if $0 == __FILE__
|
3
|
+
Dir.chdir File.dirname(__FILE__)+'/../'
|
4
|
+
$:.unshift File.expand_path('../lib/')
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rio'
|
8
|
+
require 'tc/testcase'
|
9
|
+
require 'tc/csvutil'
|
10
|
+
|
11
|
+
class TC_csv_gzip < Test::RIO::TestCase
|
12
|
+
include CSV_Util
|
13
|
+
|
14
|
+
@@once = false
|
15
|
+
def self.once
|
16
|
+
@@once = true
|
17
|
+
end
|
18
|
+
def setup()
|
19
|
+
super
|
20
|
+
@src = rio(?")
|
21
|
+
@dst_name = 'dst.csv'
|
22
|
+
@records,@strings,@lines,@string = create_test_csv_data(@src,3, 3, ',', $/, true)
|
23
|
+
if $USE_FASTER_CSV
|
24
|
+
opts = {:headers => true, :return_headers => true}
|
25
|
+
@rows = []
|
26
|
+
::CSV.parse(@string, opts) do |row|
|
27
|
+
@rows << row
|
28
|
+
end
|
29
|
+
else
|
30
|
+
@rows = []
|
31
|
+
@records.each do |rec|
|
32
|
+
h = {}
|
33
|
+
(0...rec.size).each do |n|
|
34
|
+
h["Col#{n}"] = rec[n]
|
35
|
+
end
|
36
|
+
@rows << h
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_basic
|
43
|
+
rio('basic.csv') < @string
|
44
|
+
assert_equal(@string,File.read('basic.csv'))
|
45
|
+
rio('basic.csv').csv > rio('basic.csv.gz').csv.gzip
|
46
|
+
assert_equal(@lines, rio('basic.csv.gz').csv.gzip.lines[])
|
47
|
+
assert_equal(@records, rio('basic.csv.gz').csv.gzip.records[])
|
48
|
+
assert_equal(@rows[1...@rows.size], rio('basic.csv.gz').csv.gzip.rows[])
|
49
|
+
|
50
|
+
rio('basic.csv.gz').csv.gzip < rio('basic.csv').csv
|
51
|
+
assert_equal(@lines, rio('basic.csv.gz').csv.gzip.lines[])
|
52
|
+
assert_equal(@records, rio('basic.csv.gz').csv.gzip.records[])
|
53
|
+
assert_equal(@rows[1...@rows.size], rio('basic.csv.gz').csv.gzip.rows[])
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_copy
|
57
|
+
rio('copy.csv') < @string
|
58
|
+
assert_equal(@string,File.read('copy.csv'))
|
59
|
+
|
60
|
+
rio('copy.csv').csv > rio('copy.csv.gz').csv.gzip
|
61
|
+
rio('copy.csv.gz').csv.gzip > rio('out.csv').csv
|
62
|
+
assert_equal(@lines, rio('out.csv').csv.lines[])
|
63
|
+
|
64
|
+
rio('out1.csv.gz').csv.gzip < rio('copy.csv.gz').csv.gzip
|
65
|
+
assert_equal(@lines, rio('out1.csv.gz').csv.gzip.lines[])
|
66
|
+
rio('copy.csv.gz').csv.gzip > rio('out2.csv.gz').csv.gzip
|
67
|
+
assert_equal(@string, rio('out2.csv.gz').gzip.contents)
|
68
|
+
|
69
|
+
csv_arg = ($USE_FASTER_CSV ? {:col_sep => ';'} : ';')
|
70
|
+
rio('out3.csv.gz').csv(csv_arg).gzip < rio('copy.csv.gz').csv.gzip
|
71
|
+
assert_equal(@string.gsub(',',';'), rio('out3.csv.gz').gzip.contents)
|
72
|
+
rio('copy.csv.gz').csv.gzip > rio('out4.csv.gz').csv(csv_arg).gzip
|
73
|
+
assert_equal(@string.gsub(',',';'), rio('out4.csv.gz').gzip.contents)
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
if $0 == __FILE__
|
3
|
+
Dir.chdir File.dirname(__FILE__)+'/../'
|
4
|
+
$:.unshift File.expand_path('../lib/')
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rio'
|
8
|
+
require 'tc/testcase'
|
9
|
+
require 'tc/csvutil'
|
10
|
+
|
11
|
+
class TC_csv_headers < Test::RIO::TestCase
|
12
|
+
include CSV_Util
|
13
|
+
|
14
|
+
@@once = false
|
15
|
+
def self.once
|
16
|
+
@@once = true
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup()
|
20
|
+
super
|
21
|
+
@src = rio(?")
|
22
|
+
@dst_name = 'dst.csv'
|
23
|
+
@records,@strings,@lines,@string = create_test_csv_data(@src,2, 5,',',$/, true)
|
24
|
+
if $USE_FASTER_CSV
|
25
|
+
opts = {:headers => true, :return_headers => true}
|
26
|
+
@rows = []
|
27
|
+
::CSV.parse(@string, opts) do |row|
|
28
|
+
@rows << row
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def col_recs(r,cola)
|
34
|
+
ans = []
|
35
|
+
r.each do |rec|
|
36
|
+
row = []
|
37
|
+
cola.each do |col|
|
38
|
+
row << rec[col]
|
39
|
+
end
|
40
|
+
ans << row.flatten
|
41
|
+
end
|
42
|
+
ans
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_basic
|
46
|
+
rio('basic.csv') < @src
|
47
|
+
r = @records
|
48
|
+
assert_equal(r[0,3],rio('basic.csv').csv[])
|
49
|
+
assert_equal(r[1,2],rio('basic.csv').csv.headers.records[])
|
50
|
+
assert_equal([r[0]],rio('basic.csv').csv.headers?)
|
51
|
+
|
52
|
+
assert_equal(r[0,3],rio('basic.csv').csv(:return_headers => true).headers.records[])
|
53
|
+
|
54
|
+
heads = (0..2).map{|n| "HEAD#{n}"}
|
55
|
+
assert_equal(r[0,3],rio('basic.csv').csv.headers(heads).records[])
|
56
|
+
assert_equal(heads,rio('basic.csv').csv.headers(heads).headers?)
|
57
|
+
assert_equal([heads] + r[0,3],rio('basic.csv').csv(:return_headers => true).headers(heads).records[])
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_num_columns
|
62
|
+
rio('columns.csv') < @src
|
63
|
+
r = @records
|
64
|
+
exp = r.map{|el| [el[1]]}
|
65
|
+
assert_equal(exp,rio('columns.csv').csv.columns(1)[])
|
66
|
+
exp = r[1,2].map{|el| [el[1]]}
|
67
|
+
assert_equal(exp,rio('columns.csv').csv.headers.columns(1)[])
|
68
|
+
heads = (0..2).map{|n| "HEAD#{n}"}
|
69
|
+
exp = r.map{|el| [el[1]]}
|
70
|
+
assert_equal(exp,rio('columns.csv').csv.headers(heads).columns(1).records[])
|
71
|
+
exp = [["HEAD1"]] + exp
|
72
|
+
assert_equal(exp,rio('basic.csv').csv(:return_headers => true).headers(heads).columns(1).records[])
|
73
|
+
|
74
|
+
# p rio('columns.csv').csv.headers(heads).records[]
|
75
|
+
end
|
76
|
+
def col_rows(r,cola,heads=nil)
|
77
|
+
ans = []
|
78
|
+
col_recs(r,cola).each_with_index do |recs,i|
|
79
|
+
#p recs
|
80
|
+
if $USE_FASTER_CSV
|
81
|
+
heads ||= cola.map{|n| r[0][n]}
|
82
|
+
ans << ::CSV::Row.new(heads,recs,i==0)
|
83
|
+
else
|
84
|
+
h = {}
|
85
|
+
recs.each_with_index do |rec,n|
|
86
|
+
#p rec,n
|
87
|
+
h["Col#{cola[n]}"] = rec
|
88
|
+
end
|
89
|
+
ans << h
|
90
|
+
end
|
91
|
+
end
|
92
|
+
first_row = ($USE_FASTER_CSV ? 1 : 0)
|
93
|
+
ans[first_row,r.size-first_row]
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_named_columns
|
97
|
+
rio('fields.csv') < @src
|
98
|
+
r = @records
|
99
|
+
exp = col_rows(r,[1,2,3,4])
|
100
|
+
#assert_equal(exp,rio('fields.csv').csv.columns(1).rows[])
|
101
|
+
exp = col_rows(r,[1,2,3,4])
|
102
|
+
assert_equal(exp,rio('fields.csv').csv.columns('Head1'..'Head4').rows[])
|
103
|
+
exp = col_rows(r,[1,2,4])
|
104
|
+
assert_equal(exp,rio('fields.csv').csv.columns('Head1'..'Head4').skipcolumns('Head3').rows[])
|
105
|
+
exp = col_rows(r,[3,4])
|
106
|
+
assert_equal(exp,rio('fields.csv').csv.columns('Head1'..'Head4').skipcolumns('Head0'...'Head3').rows[])
|
107
|
+
|
108
|
+
# p rio('fields.csv').csv.headers(heads).records[]
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_mixed_columns
|
112
|
+
rio('mixed.csv') < @src
|
113
|
+
r = @records
|
114
|
+
exp = col_rows(r,[1,2,3])
|
115
|
+
assert_equal(exp,rio('mixed.csv').csv.columns('Head1'..'Head3').rows[])
|
116
|
+
assert_equal(exp,rio('mixed.csv').csv.columns('Head1'...'Head4').rows[])
|
117
|
+
assert_equal(exp,rio('mixed.csv').csv.columns('Head1',2,'Head3'...'Head4').rows[])
|
118
|
+
assert_equal(exp,rio('mixed.csv').csv.columns('Head2',1...4).rows[])
|
119
|
+
assert_equal(exp,rio('mixed.csv').csv.columns('Head0'..'Head4').skipcolumns(0,'Head4').rows[])
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_external_columns
|
124
|
+
rio('external.csv') < @src
|
125
|
+
r = @records
|
126
|
+
heads = (0..4).map{|n| "HEAD#{n}"}
|
127
|
+
exp = col_rows([heads] + r[0,3],[0,1,2,3,4],heads)
|
128
|
+
assert_equal(exp,rio('external.csv').csv.headers(heads).rows[])
|
129
|
+
exp = col_rows([heads[1,3]] + r[0,3],[1,2,3],heads[1,3])
|
130
|
+
assert_equal(exp,rio('external.csv').csv.headers(heads).columns('HEAD1'..'HEAD3').rows[])
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
end
|
data/test/tc/csvutil.rb
CHANGED
@@ -4,8 +4,6 @@ if $0 == __FILE__
|
|
4
4
|
$:.unshift File.expand_path('../lib/')
|
5
5
|
end
|
6
6
|
|
7
|
-
require 'rio'
|
8
|
-
|
9
7
|
module CSV_Util
|
10
8
|
def records_to_rows(records)
|
11
9
|
n_records = records.size
|
@@ -21,34 +19,73 @@ module CSV_Util
|
|
21
19
|
end
|
22
20
|
rows
|
23
21
|
end
|
24
|
-
def records_to_strings(records)
|
25
|
-
records.map { |values| values.join(
|
22
|
+
def records_to_strings(records,fs=',')
|
23
|
+
records.map { |values| values.join(fs) }
|
26
24
|
end
|
27
|
-
def records_to_string(records)
|
28
|
-
records_to_strings(records).join(
|
25
|
+
def records_to_string(records,fs=',',rs=$/)
|
26
|
+
records_to_strings(records,fs).join(rs) + rs
|
29
27
|
end
|
30
|
-
def strings_to_string(strings)
|
31
|
-
strings.join(
|
28
|
+
def strings_to_string(strings,rs=$/)
|
29
|
+
strings.join(rs) + rs
|
32
30
|
end
|
33
|
-
def strings_to_lines(strings)
|
34
|
-
strings.map { |s| s +
|
31
|
+
def strings_to_lines(strings,rs=$/)
|
32
|
+
strings.map { |s| s + rs }
|
35
33
|
end
|
36
34
|
def create_test_csv_records(n_rows,n_cols,header=true)
|
37
35
|
records = []
|
38
36
|
|
39
|
-
records << (0...n_cols).map { |n|
|
37
|
+
records << (0...n_cols).map { |n| %{Head#{n}} } if header
|
40
38
|
|
41
39
|
(0...n_rows).each do |nrow|
|
42
|
-
records << (0...n_cols).map { |n|
|
40
|
+
records << (0...n_cols).map { |n| %{Dat#{nrow}#{n}} }
|
43
41
|
end
|
44
42
|
records
|
45
43
|
end
|
46
44
|
|
47
|
-
def
|
45
|
+
def tcsv_gen_header_fields(n_cols)
|
46
|
+
(0...n_cols).map { |n| %{Head#{n}} }
|
47
|
+
end
|
48
|
+
def tcsv_gen_data_fields(nrow,n_cols)
|
49
|
+
(0...n_cols).map { |n| %{Dat#{nrow}#{n}} }
|
50
|
+
end
|
51
|
+
def tcsv_gen_recs(n_rows,n_cols,header=true)
|
52
|
+
recs = []
|
53
|
+
recs << tcsv_gen_header_fields(n_cols) if header
|
54
|
+
(0...n_rows).each do |nrow|
|
55
|
+
recs << tcsv_gen_data_fields(nrow,n_cols)
|
56
|
+
end
|
57
|
+
recs
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def tcsv_rec_strings(recs,fs,qc)
|
62
|
+
tcsv_rec_lines(recs,fs,"",qc).map{ |s| s.chomp }
|
63
|
+
end
|
64
|
+
|
65
|
+
def tcsv_rec_lines(recs,fs,rs,qc)
|
66
|
+
lines = []
|
67
|
+
recs.each do |rec|
|
68
|
+
lines << ::CSV.generate_line(rec,{:col_sep => fs,
|
69
|
+
:row_sep => $/,
|
70
|
+
:quote_char => qc}).chomp + $/
|
71
|
+
end
|
72
|
+
lines
|
73
|
+
end
|
74
|
+
|
75
|
+
def create_test_csv_file(frio,n_rows,n_cols,fs,rs,qc,header=true)
|
76
|
+
records = tcsv_gen_recs(n_rows,n_cols,header)
|
77
|
+
lines = tcsv_rec_lines(records,fs,rs,qc)
|
78
|
+
strings = tcsv_rec_strings(records,fs,qc)
|
79
|
+
string = strings.join($/) + $/
|
80
|
+
frio < string
|
81
|
+
[records,strings,lines,string]
|
82
|
+
end
|
83
|
+
|
84
|
+
def create_test_csv_data(frio,n_rows,n_cols,fs,rs,header=true)
|
48
85
|
records = create_test_csv_records(n_rows,n_cols,header)
|
49
|
-
strings = records_to_strings(records)
|
50
|
-
lines = strings_to_lines(strings)
|
51
|
-
string = strings_to_string(strings)
|
86
|
+
strings = records_to_strings(records,fs)
|
87
|
+
lines = strings_to_lines(strings,rs)
|
88
|
+
string = strings_to_string(strings,rs)
|
52
89
|
frio < string
|
53
90
|
[records,strings,lines,string]
|
54
91
|
end
|