wishdev-rio 0.4.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +341 -0
- data/README +81 -0
- data/Rakefile +281 -0
- data/build_doc.rb +94 -0
- data/doc/ANNOUNCE +159 -0
- data/doc/RELEASE_NOTES +308 -0
- data/doc/RIOIS +215 -0
- data/doc/generators/template/html/rio.css +428 -0
- data/doc/generators/template/html/rio.rb +523 -0
- data/doc/generators/template/html/ugly.rb +132 -0
- data/doc/pkg_def.rb +60 -0
- data/doc/rfc1738.txt +1403 -0
- data/doc/rfc959.txt +3933 -0
- data/ex/catcsv.rb +64 -0
- data/ex/colx.rb +8 -0
- data/ex/findinruby +15 -0
- data/ex/findruby +14 -0
- data/ex/passwd_report.rb +8 -0
- data/ex/prompt.rb +25 -0
- data/ex/rgb.txt.gz +0 -0
- data/ex/riocat +42 -0
- data/ex/riogunzip +31 -0
- data/ex/riogzip +24 -0
- data/ex/rioprompt.rb +10 -0
- data/ex/targz2zip +17 -0
- data/ex/tonl +10 -0
- data/lib/rio/abstract_method.rb +56 -0
- data/lib/rio/argv.rb +56 -0
- data/lib/rio/arycopy.rb +43 -0
- data/lib/rio/assert.rb +114 -0
- data/lib/rio/base.rb +56 -0
- data/lib/rio/callstr.rb +46 -0
- data/lib/rio/const.rb +51 -0
- data/lib/rio/construct.rb +50 -0
- data/lib/rio/constructor.rb +258 -0
- data/lib/rio/context/autoclose.rb +72 -0
- data/lib/rio/context/copying.rb +55 -0
- data/lib/rio/context/cxx.rb +66 -0
- data/lib/rio/context/dir.rb +120 -0
- data/lib/rio/context/gzip.rb +50 -0
- data/lib/rio/context/methods.rb +182 -0
- data/lib/rio/context/skip.rb +66 -0
- data/lib/rio/context/stream.rb +229 -0
- data/lib/rio/context.rb +117 -0
- data/lib/rio/cp.rb +370 -0
- data/lib/rio/def.rb +53 -0
- data/lib/rio/dir.rb +144 -0
- data/lib/rio/doc/EXAMPLES.rb +299 -0
- data/lib/rio/doc/HOWTO.rb +737 -0
- data/lib/rio/doc/INDEX.rb +311 -0
- data/lib/rio/doc/INTRO.rb +1068 -0
- data/lib/rio/doc/OPTIONAL.rb +130 -0
- data/lib/rio/doc/SYNOPSIS.rb +183 -0
- data/lib/rio/doc.rb +45 -0
- data/lib/rio/entrysel.rb +246 -0
- data/lib/rio/exception/copy.rb +97 -0
- data/lib/rio/exception/notimplemented.rb +57 -0
- data/lib/rio/exception/notsupported.rb +46 -0
- data/lib/rio/exception/open.rb +61 -0
- data/lib/rio/exception/state.rb +73 -0
- data/lib/rio/exception.rb +41 -0
- data/lib/rio/ext/csv.rb +351 -0
- data/lib/rio/ext/if.rb +45 -0
- data/lib/rio/ext/mp3info.rb +80 -0
- data/lib/rio/ext/splitlines.rb +253 -0
- data/lib/rio/ext/yaml/doc.rb +133 -0
- data/lib/rio/ext/yaml/tie.rb +149 -0
- data/lib/rio/ext/yaml.rb +164 -0
- data/lib/rio/ext/zipfile/fs.rb +116 -0
- data/lib/rio/ext/zipfile/rl.rb +251 -0
- data/lib/rio/ext/zipfile/rootdir.rb +117 -0
- data/lib/rio/ext/zipfile/state.rb +161 -0
- data/lib/rio/ext/zipfile/wrap.rb +204 -0
- data/lib/rio/ext/zipfile.rb +110 -0
- data/lib/rio/ext.rb +138 -0
- data/lib/rio/factory.rb +436 -0
- data/lib/rio/file.rb +118 -0
- data/lib/rio/filter/closeoneof.rb +103 -0
- data/lib/rio/filter/gzip.rb +70 -0
- data/lib/rio/filter.rb +94 -0
- data/lib/rio/fs/base.rb +41 -0
- data/lib/rio/fs/impl.rb +122 -0
- data/lib/rio/fs/native.rb +75 -0
- data/lib/rio/fs/stream.rb +61 -0
- data/lib/rio/fs/url.rb +63 -0
- data/lib/rio/ftp/conncache.rb +101 -0
- data/lib/rio/ftp/dir.rb +94 -0
- data/lib/rio/ftp/fs.rb +180 -0
- data/lib/rio/ftp/ftpfile.rb +20 -0
- data/lib/rio/grande.rb +97 -0
- data/lib/rio/handle.rb +100 -0
- data/lib/rio/if/basic.rb +64 -0
- data/lib/rio/if/csv.rb +76 -0
- data/lib/rio/if/dir.rb +157 -0
- data/lib/rio/if/file.rb +89 -0
- data/lib/rio/if/fileordir.rb +268 -0
- data/lib/rio/if/grande.rb +729 -0
- data/lib/rio/if/grande_entry.rb +379 -0
- data/lib/rio/if/grande_stream.rb +693 -0
- data/lib/rio/if/internal.rb +125 -0
- data/lib/rio/if/path.rb +462 -0
- data/lib/rio/if/rubyio.rb +681 -0
- data/lib/rio/if/string.rb +83 -0
- data/lib/rio/if/temp.rb +45 -0
- data/lib/rio/if/test.rb +282 -0
- data/lib/rio/if/yaml.rb +206 -0
- data/lib/rio/if.rb +64 -0
- data/lib/rio/ioh.rb +162 -0
- data/lib/rio/iomode.rb +109 -0
- data/lib/rio/ios/fail.rb +106 -0
- data/lib/rio/ios/generic.rb +119 -0
- data/lib/rio/ios/mode.rb +60 -0
- data/lib/rio/ios/null.rb +119 -0
- data/lib/rio/iowrap.rb +128 -0
- data/lib/rio/kernel.rb +54 -0
- data/lib/rio/local.rb +62 -0
- data/lib/rio/match.rb +53 -0
- data/lib/rio/matchrecord.rb +283 -0
- data/lib/rio/no_warn.rb +49 -0
- data/lib/rio/nullio.rb +159 -0
- data/lib/rio/open3.rb +68 -0
- data/lib/rio/ops/construct.rb +61 -0
- data/lib/rio/ops/create.rb +77 -0
- data/lib/rio/ops/dir.rb +346 -0
- data/lib/rio/ops/either.rb +134 -0
- data/lib/rio/ops/file.rb +102 -0
- data/lib/rio/ops/path.rb +296 -0
- data/lib/rio/ops/stream/input.rb +267 -0
- data/lib/rio/ops/stream/output.rb +100 -0
- data/lib/rio/ops/stream/read.rb +86 -0
- data/lib/rio/ops/stream/write.rb +57 -0
- data/lib/rio/ops/stream.rb +87 -0
- data/lib/rio/ops/symlink.rb +80 -0
- data/lib/rio/path/reset.rb +69 -0
- data/lib/rio/path.rb +129 -0
- data/lib/rio/piper/cp.rb +80 -0
- data/lib/rio/piper.rb +122 -0
- data/lib/rio/prompt.rb +66 -0
- data/lib/rio/rectype.rb +88 -0
- data/lib/rio/rl/base.rb +118 -0
- data/lib/rio/rl/builder.rb +117 -0
- data/lib/rio/rl/chmap.rb +66 -0
- data/lib/rio/rl/fs2url.rb +82 -0
- data/lib/rio/rl/ioi.rb +78 -0
- data/lib/rio/rl/path.rb +110 -0
- data/lib/rio/rl/pathmethods.rb +116 -0
- data/lib/rio/rl/uri.rb +200 -0
- data/lib/rio/rl/withpath.rb +296 -0
- data/lib/rio/scheme/aryio.rb +88 -0
- data/lib/rio/scheme/cmdio.rb +80 -0
- data/lib/rio/scheme/cmdpipe.rb +118 -0
- data/lib/rio/scheme/fd.rb +65 -0
- data/lib/rio/scheme/ftp.rb +141 -0
- data/lib/rio/scheme/http.rb +78 -0
- data/lib/rio/scheme/null.rb +55 -0
- data/lib/rio/scheme/path.rb +98 -0
- data/lib/rio/scheme/stderr.rb +55 -0
- data/lib/rio/scheme/stdio.rb +71 -0
- data/lib/rio/scheme/strio.rb +87 -0
- data/lib/rio/scheme/sysio.rb +63 -0
- data/lib/rio/scheme/tcp.rb +75 -0
- data/lib/rio/scheme/temp.rb +200 -0
- data/lib/rio/state/error.rb +72 -0
- data/lib/rio/state.rb +242 -0
- data/lib/rio/stream/base.rb +54 -0
- data/lib/rio/stream/duplex.rb +79 -0
- data/lib/rio/stream/open.rb +202 -0
- data/lib/rio/stream.rb +181 -0
- data/lib/rio/symantics.rb +45 -0
- data/lib/rio/tempdir.rb +132 -0
- data/lib/rio/to_rio/all.rb +39 -0
- data/lib/rio/to_rio/array.rb +39 -0
- data/lib/rio/to_rio/io.rb +40 -0
- data/lib/rio/to_rio/object.rb +42 -0
- data/lib/rio/to_rio/string.rb +40 -0
- data/lib/rio/to_rio.rb +67 -0
- data/lib/rio/uri/file.rb +198 -0
- data/lib/rio/util.rb +48 -0
- data/lib/rio/version.rb +51 -0
- data/lib/rio.rb +162 -0
- data/setup.rb +1360 -0
- data/test/bin/count_lines.rb +11 -0
- data/test/bin/find_lines.rb +13 -0
- data/test/bin/list_dir.rb +14 -0
- data/test/ftp/all.rb +9 -0
- data/test/ftp/anon_copy_data.rb +36 -0
- data/test/ftp/anon_misc.rb +124 -0
- data/test/ftp/anon_read.rb +105 -0
- data/test/ftp/anon_special.rb +68 -0
- data/test/ftp/anon_write.rb +70 -0
- data/test/ftp/ftp2ftp.rb +51 -0
- data/test/ftp/initftpfiles.rb +14 -0
- data/test/ftp/testdef.rb +55 -0
- data/test/gem_runtests.rb +15 -0
- data/test/http/all.rb +4 -0
- data/test/http/copy-from-http.rb +141 -0
- data/test/http/uri-meta.rb +72 -0
- data/test/lib/temp_server.rb +46 -0
- data/test/runalltests.rb +17 -0
- data/test/runftptests.rb +14 -0
- data/test/runhttp.rb +11 -0
- data/test/runhttptests.rb +14 -0
- data/test/runtests.rb +52 -0
- data/test/tc/abs.rb +355 -0
- data/test/tc/all.rb +80 -0
- data/test/tc/base.rb +31 -0
- data/test/tc/base2.rb +87 -0
- data/test/tc/cd1.rb +113 -0
- data/test/tc/clearsel.rb +68 -0
- data/test/tc/clone.rb +208 -0
- data/test/tc/closeoncopy.rb +102 -0
- data/test/tc/closeoneof.rb +194 -0
- data/test/tc/cmdpipe.rb +149 -0
- data/test/tc/copy-dir-samevar.rb +91 -0
- data/test/tc/copy-from.rb +129 -0
- data/test/tc/copy-to.rb +91 -0
- data/test/tc/copy.rb +74 -0
- data/test/tc/copyarray.rb +188 -0
- data/test/tc/copydest.rb +50 -0
- data/test/tc/copydir.rb +166 -0
- data/test/tc/copydirlines.rb +121 -0
- data/test/tc/copylines.rb +46 -0
- data/test/tc/copynonex.rb +118 -0
- data/test/tc/copysymlink.rb +39 -0
- data/test/tc/create.rb +114 -0
- data/test/tc/csv.rb +226 -0
- data/test/tc/csv2.rb +138 -0
- data/test/tc/csv_columns.rb +37 -0
- data/test/tc/csvutil.rb +56 -0
- data/test/tc/dir.rb +76 -0
- data/test/tc/dir_iter.rb +383 -0
- data/test/tc/dirautoclose.rb +67 -0
- data/test/tc/dirent.rb +178 -0
- data/test/tc/dirss.rb +81 -0
- data/test/tc/each.rb +111 -0
- data/test/tc/each_break.rb +243 -0
- data/test/tc/edf.rb +81 -0
- data/test/tc/empty.rb +51 -0
- data/test/tc/emptyriodir.rb +129 -0
- data/test/tc/entary.rb +227 -0
- data/test/tc/entsel.rb +110 -0
- data/test/tc/eq.rb +101 -0
- data/test/tc/expand_path.rb +69 -0
- data/test/tc/ext.rb +136 -0
- data/test/tc/fileno.rb +94 -0
- data/test/tc/files_select.rb +92 -0
- data/test/tc/get.rb +152 -0
- data/test/tc/getrec.rb +137 -0
- data/test/tc/gzip.rb +109 -0
- data/test/tc/io_each_byte.rb +60 -0
- data/test/tc/io_read.rb +80 -0
- data/test/tc/iometh.rb +149 -0
- data/test/tc/likeio.rb +116 -0
- data/test/tc/line_record_row.rb +51 -0
- data/test/tc/lineno.rb +196 -0
- data/test/tc/lines.rb +66 -0
- data/test/tc/misc.rb +432 -0
- data/test/tc/nolines.rb +204 -0
- data/test/tc/noqae.rb +879 -0
- data/test/tc/null.rb +45 -0
- data/test/tc/once.rb +6 -0
- data/test/tc/overload.rb +140 -0
- data/test/tc/pa.rb +158 -0
- data/test/tc/path_parts.rb +175 -0
- data/test/tc/pathop.rb +60 -0
- data/test/tc/paths.rb +145 -0
- data/test/tc/pid.rb +31 -0
- data/test/tc/piper.rb +143 -0
- data/test/tc/programs_util.rb +24 -0
- data/test/tc/qae.rb +493 -0
- data/test/tc/qae_riovar.rb +499 -0
- data/test/tc/readline.rb +30 -0
- data/test/tc/records.rb +68 -0
- data/test/tc/rename.rb +233 -0
- data/test/tc/rename_assign.rb +45 -0
- data/test/tc/riorl.rb +181 -0
- data/test/tc/route.rb +51 -0
- data/test/tc/selnosel.rb +33 -0
- data/test/tc/skip.rb +89 -0
- data/test/tc/skiplines.rb +71 -0
- data/test/tc/split.rb +28 -0
- data/test/tc/splitlines.rb +65 -0
- data/test/tc/splitpath.rb +83 -0
- data/test/tc/sub.rb +46 -0
- data/test/tc/symlink.rb +176 -0
- data/test/tc/symlink0.rb +348 -0
- data/test/tc/symlink1.rb +114 -0
- data/test/tc/synopsis.rb +75 -0
- data/test/tc/temp.rb +152 -0
- data/test/tc/tempdir.rb +60 -0
- data/test/tc/tempfile.rb +66 -0
- data/test/tc/testcase.rb +170 -0
- data/test/tc/tonl.rb +37 -0
- data/test/tc/truncate.rb +39 -0
- data/test/tc/yaml.rb +275 -0
- metadata +387 -0
data/test/tc/null.rb
ADDED
@@ -0,0 +1,45 @@
|
|
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
|
+
|
10
|
+
class TC_null < Test::RIO::TestCase
|
11
|
+
@@once = false
|
12
|
+
def self.once
|
13
|
+
@@once = true
|
14
|
+
end
|
15
|
+
def setup
|
16
|
+
super
|
17
|
+
self.class.once unless @@once
|
18
|
+
end
|
19
|
+
def compare_rtn(sym,*args)
|
20
|
+
r1 = rio('/dev/null')
|
21
|
+
r2 = rio(nil)
|
22
|
+
rtn1 = r1.__send__(sym,*args)
|
23
|
+
rtn2 = r2.__send__(sym,*args)
|
24
|
+
assert_equal(rtn1,rtn2)
|
25
|
+
end
|
26
|
+
|
27
|
+
def compare_raiseeof(sym,*args)
|
28
|
+
r1 = rio('/dev/null')
|
29
|
+
r2 = rio(nil)
|
30
|
+
assert_raise(EOFError) { r1.__send__(sym,*args) }
|
31
|
+
assert_raise(EOFError) { r2.__send__(sym,*args) }
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_gets() compare_rtn(:gets) end
|
35
|
+
def test_lineno() compare_rtn(:lineno) end
|
36
|
+
def test_lineno_assign() compare_rtn(:lineno=,20) end
|
37
|
+
def test_pos() compare_rtn(:pos) end
|
38
|
+
def test_pos_assign() compare_rtn(:pos=,20) end
|
39
|
+
def test_read() compare_rtn(:read) end
|
40
|
+
def test_readl() compare_rtn(:read,1) end
|
41
|
+
def test_readline() compare_raiseeof(:readline) end
|
42
|
+
def test_readlines() compare_rtn(:readlines) end
|
43
|
+
def test_readchar() compare_raiseeof(:readchar) end
|
44
|
+
|
45
|
+
end
|
data/test/tc/once.rb
ADDED
data/test/tc/overload.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
if $0 == __FILE__
|
3
|
+
Dir.chdir File.dirname(__FILE__)+'/../'
|
4
|
+
$:.unshift File.expand_path('../lib/')
|
5
|
+
end
|
6
|
+
require 'rio'
|
7
|
+
require 'test/unit'
|
8
|
+
require 'tc/testcase'
|
9
|
+
|
10
|
+
class TC_RIO_overload < Test::Unit::TestCase
|
11
|
+
def test_overload
|
12
|
+
qp = RIO.rio('qp')
|
13
|
+
rio(qp,'test_overload').rmtree.mkpath.chdir {
|
14
|
+
line0 = "Line 0\n"
|
15
|
+
src = rio('src').print!(line0)
|
16
|
+
|
17
|
+
rio('src') > rio('dst1')
|
18
|
+
assert_equal(line0,rio('dst1').contents)
|
19
|
+
# $trace_states = true
|
20
|
+
rio('dst2') < rio('src')
|
21
|
+
$trace_states = false
|
22
|
+
assert_equal(line0,rio('dst2').contents)
|
23
|
+
rio('dst2') << rio('src')
|
24
|
+
assert_equal(line0+line0,rio('dst2').contents)
|
25
|
+
|
26
|
+
rio('dst3') << rio('src')
|
27
|
+
assert_equal(line0,rio('dst3').contents)
|
28
|
+
rio('dst3') << rio('src')
|
29
|
+
assert_equal(line0+line0,rio('dst3').contents)
|
30
|
+
|
31
|
+
rio('dst4') < rio('src')
|
32
|
+
assert_equal(line0,rio('dst4').contents)
|
33
|
+
|
34
|
+
rio('dst5') < line0
|
35
|
+
assert_equal(line0,rio('dst5').contents)
|
36
|
+
rio('dst5') << line0
|
37
|
+
assert_equal(line0+line0,rio('dst5').contents)
|
38
|
+
|
39
|
+
rio('dst6') < ::File.new('src','r')
|
40
|
+
assert_equal(line0,rio('dst6').contents)
|
41
|
+
rio('dst6') << ::File.new('src','r')
|
42
|
+
assert_equal(line0+line0,rio('dst6').contents)
|
43
|
+
|
44
|
+
rio('dst7') < "Line 0\n"
|
45
|
+
assert_equal(line0,rio('dst7').contents)
|
46
|
+
rio('dst7') << "Line 0\n"
|
47
|
+
assert_equal(line0+line0,rio('dst7').contents)
|
48
|
+
|
49
|
+
rio('dst8').puts!("Zippy DO\n")
|
50
|
+
rio('dst8') < rio('src')
|
51
|
+
assert_equal(line0,rio('dst8').contents)
|
52
|
+
|
53
|
+
rio('src') > rio('dst10')
|
54
|
+
assert_equal(line0,rio('dst10').contents)
|
55
|
+
rio('src') >> rio('dst10')
|
56
|
+
assert_equal(line0+line0,rio('dst10').contents)
|
57
|
+
|
58
|
+
rio('src') > rio('dst1')
|
59
|
+
assert_equal(line0,rio('dst1').contents)
|
60
|
+
|
61
|
+
rio('src') >> rio('dst1a')
|
62
|
+
rio('src') >> rio('dst1a')
|
63
|
+
assert_equal(line0+line0,rio('dst1a').contents)
|
64
|
+
|
65
|
+
str = 'Hello World'
|
66
|
+
rio('src') > str
|
67
|
+
assert_equal(line0,str)
|
68
|
+
rio('src') >> str
|
69
|
+
assert_equal(line0+line0,str)
|
70
|
+
|
71
|
+
fh = ::File.new('dst2','w')
|
72
|
+
rio('src') > fh
|
73
|
+
fh.close
|
74
|
+
assert_equal(line0,rio('dst2').contents)
|
75
|
+
|
76
|
+
unless $mswin32
|
77
|
+
rio('src.gz').gzip < rio('src')
|
78
|
+
rio('dst3') < rio('src.gz').gzip
|
79
|
+
assert_equal(line0,rio('dst3').contents)
|
80
|
+
|
81
|
+
str = 'Hello World'
|
82
|
+
rio('src.gz').gzip > str
|
83
|
+
assert_equal(line0,str)
|
84
|
+
|
85
|
+
rio('src') > rio('src.gz').gzip
|
86
|
+
rio('src.gz').gzip > str
|
87
|
+
assert_equal(line0,str)
|
88
|
+
rio('src.gz').gzip >> str
|
89
|
+
assert_equal(line0+line0,str)
|
90
|
+
end
|
91
|
+
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
# dst2 = rio(datadir,'dst2').mkdir
|
96
|
+
# src > dst2
|
97
|
+
# sline = rio(datadir,'src').contents
|
98
|
+
# l2 = rio(datadir,'dst2/src').contents
|
99
|
+
# assert_equal(line0,sline,'a message in a assertion')
|
100
|
+
# assert_equal(line0,l2)
|
101
|
+
|
102
|
+
# # copy directories
|
103
|
+
# sd1 = rio(datadir,'dir1/sd1').rmtree.mkpath
|
104
|
+
# txt = "Hello f1.txt"
|
105
|
+
# sd1.catpath('f1.txt').puts(txt).close
|
106
|
+
# oline = rio(datadir,'dir1/sd1/f1.txt').contents
|
107
|
+
|
108
|
+
# dir2 = rio(datadir,'dir2').rmtree.mkpath
|
109
|
+
# sd1.copy_to(dir2)
|
110
|
+
# nline = rio(datadir,'dir2/sd1/f1.txt').contents
|
111
|
+
# assert_equal(oline,nline)
|
112
|
+
|
113
|
+
# dir2 = rio(datadir,'dir2').rmtree.mkpath
|
114
|
+
# sd1 > dir2
|
115
|
+
# nline = rio(datadir,'dir2/sd1/f1.txt').contents
|
116
|
+
# assert_equal(oline,nline)
|
117
|
+
|
118
|
+
# dir2 = rio(datadir,'dir2').rmtree.mkpath
|
119
|
+
# dir2 < rio(datadir,'dir1/sd1')
|
120
|
+
# nline = rio(datadir,'dir2/sd1/f1.txt').contents
|
121
|
+
# assert_equal(oline,nline)
|
122
|
+
|
123
|
+
# dir2 = rio(datadir,'dir2').rmtree.mkpath
|
124
|
+
# sd1 > dir2.to_s
|
125
|
+
# nline = rio(datadir,'dir2/sd1/f1.txt').contents
|
126
|
+
# assert_equal(oline,nline)
|
127
|
+
|
128
|
+
# dir2 = rio(datadir,'dir2').rmtree.mkpath
|
129
|
+
# dir2 < rio(datadir,'dir1/sd1').to_s
|
130
|
+
# nline = rio(datadir,'dir2/sd1/f1.txt').contents
|
131
|
+
# assert_equal(oline,nline)
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
135
|
+
__END__
|
136
|
+
require 'test/unit/ui/console/testrunner'
|
137
|
+
#Test::Unit::UI::Console::TestRunner.run(TC_RIO,Test::Unit::UI::SILENT)
|
138
|
+
#Test::Unit::UI::Console::TestRunner.run(TC_RIO,Test::Unit::UI::PROGRESS_ONLY)
|
139
|
+
#Test::Unit::UI::Console::TestRunner.run(TC_RIO_copy,Test::Unit::UI::NORMAL)
|
140
|
+
Test::Unit::UI::Console::TestRunner.run(TC_RIO_copy,Test::Unit::UI::VERBOSE)
|
data/test/tc/pa.rb
ADDED
@@ -0,0 +1,158 @@
|
|
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 'test/unit'
|
9
|
+
require 'test/unit/testsuite'
|
10
|
+
|
11
|
+
def smap(a) a.map { |el| el.to_s } end
|
12
|
+
|
13
|
+
class TC_RIO_pa < Test::Unit::TestCase
|
14
|
+
def test_pa
|
15
|
+
s_dir = ''
|
16
|
+
#$trace_states = true
|
17
|
+
tdir = rio(%w/qp pa/)
|
18
|
+
tdir.rmtree.mkpath.chdir {
|
19
|
+
rio(%w/d0 d00 d000/).mkpath
|
20
|
+
rio(%w/d1 d10 d000/).mkpath
|
21
|
+
rio(%w/d1 d10 d100/).mkpath
|
22
|
+
rio(%w/d1 d11/).mkpath
|
23
|
+
%w[d1/f0.txt d1/d10/f0.txt d1/d10/f1.txt d1/d10/f2.emp f0.txt d1/d10/d000/f100.txt].each do |e|
|
24
|
+
rio(e) << (0..2).map { |n| "L#{n}:#{e}\n" }
|
25
|
+
end
|
26
|
+
}
|
27
|
+
|
28
|
+
tdir.chdir do
|
29
|
+
ario = rio('d1')
|
30
|
+
exp = ["d1/f0.txt"]
|
31
|
+
assert_equal(exp,smap(ario[/x/]))
|
32
|
+
|
33
|
+
ario = rio('f0.txt')
|
34
|
+
exp = ["L0:f0.txt\n", "L1:f0.txt\n", "L2:f0.txt\n"]
|
35
|
+
assert_equal(exp,smap(ario[/x/]))
|
36
|
+
|
37
|
+
ario = rio('d1')
|
38
|
+
ans = []
|
39
|
+
#$trace_states = true
|
40
|
+
ario.each do |ent|
|
41
|
+
ent.files { |el| ans << el }
|
42
|
+
end
|
43
|
+
exp = ["d1/d10/f0.txt","d1/d10/f1.txt","d1/d10/f2.emp","d1/f0.txt"]
|
44
|
+
assert_equal(exp,smap(ans))
|
45
|
+
ario = rio('d1')
|
46
|
+
ans = []
|
47
|
+
ario.each do |ent|
|
48
|
+
ent.files(/x/) { |el| ans << el }
|
49
|
+
end
|
50
|
+
exp = ["d1/d10/f0.txt", "d1/d10/f1.txt", "d1/f0.txt"]
|
51
|
+
assert_equal(exp,smap(ans))
|
52
|
+
|
53
|
+
ario = rio('d1')
|
54
|
+
ans = ario[/x/]
|
55
|
+
exp = ["d1/f0.txt"]
|
56
|
+
assert_equal(exp,smap(ans))
|
57
|
+
|
58
|
+
ans = []
|
59
|
+
rio('d1').all.files('*.emp').lines(/L2/) { |el| ans << el }
|
60
|
+
exp = ["L2:d1/d10/f2.emp\n"]
|
61
|
+
assert_equal(exp,smap(ans))
|
62
|
+
|
63
|
+
ans = []
|
64
|
+
rio('d1').all.files('*.?x?').lines(/L2/) { |el| ans << el }
|
65
|
+
exp = ["L2:d1/d10/d000/f100.txt\n", "L2:d1/d10/f0.txt\n", "L2:d1/d10/f1.txt\n", "L2:d1/f0.txt\n"]
|
66
|
+
assert_equal(exp,smap(ans))
|
67
|
+
|
68
|
+
ans = []
|
69
|
+
rio('d1').all.files('*.?x?').lines(2) { |el| ans << el }
|
70
|
+
exp = ["L2:d1/d10/d000/f100.txt\n", "L2:d1/d10/f0.txt\n", "L2:d1/d10/f1.txt\n", "L2:d1/f0.txt\n"]
|
71
|
+
assert_equal(exp,smap(ans))
|
72
|
+
|
73
|
+
ans = []
|
74
|
+
|
75
|
+
rio('d1').all.files('*.?x?').lines(2...3) { |el| ans << el }
|
76
|
+
exp = ["L2:d1/d10/d000/f100.txt\n", "L2:d1/d10/f0.txt\n", "L2:d1/d10/f1.txt\n", "L2:d1/f0.txt\n"]
|
77
|
+
assert_equal(exp,smap(ans))
|
78
|
+
|
79
|
+
ans = rio('d1').all.files('*.?x?').lines(/L1/).to_a
|
80
|
+
exp = ["L1:d1/d10/d000/f100.txt\n", "L1:d1/d10/f0.txt\n", "L1:d1/d10/f1.txt\n", "L1:d1/f0.txt\n"]
|
81
|
+
assert_equal(exp,smap(ans))
|
82
|
+
|
83
|
+
ans = rio('d1').all.files('*.?x?').lines[/L1/]
|
84
|
+
exp = ["L1:d1/d10/d000/f100.txt\n", "L1:d1/d10/f0.txt\n", "L1:d1/d10/f1.txt\n", "L1:d1/f0.txt\n"]
|
85
|
+
assert_equal(exp,smap(ans))
|
86
|
+
|
87
|
+
ans = rio('d1').all.lines(/L1/).files['*.?x?']
|
88
|
+
exp = ["L1:d1/d10/d000/f100.txt\n", "L1:d1/d10/f0.txt\n", "L1:d1/d10/f1.txt\n", "L1:d1/f0.txt\n"]
|
89
|
+
assert_equal(exp,smap(ans))
|
90
|
+
|
91
|
+
ans = rio('d1').all.files('*.?x?').lines[1]
|
92
|
+
exp = ["L1:d1/d10/d000/f100.txt\n", "L1:d1/d10/f0.txt\n", "L1:d1/d10/f1.txt\n", "L1:d1/f0.txt\n"]
|
93
|
+
assert_equal(exp,smap(ans))
|
94
|
+
|
95
|
+
ans = rio('d1').all.files('*.?x?').lines[1...2]
|
96
|
+
exp = ["L1:d1/d10/d000/f100.txt\n", "L1:d1/d10/f0.txt\n", "L1:d1/d10/f1.txt\n", "L1:d1/f0.txt\n"]
|
97
|
+
assert_equal(exp,smap(ans))
|
98
|
+
|
99
|
+
ans = rio('d1').all.lines(/L0/).files[/f0/]
|
100
|
+
exp = ["L0:d1/d10/f0.txt\n", "L0:d1/f0.txt\n"]
|
101
|
+
assert_equal(exp,smap(ans))
|
102
|
+
|
103
|
+
ans = rio('d1').all.lines(/L0/).files[]
|
104
|
+
exp = ["L0:d1/d10/d000/f100.txt\n", "L0:d1/d10/f0.txt\n", "L0:d1/d10/f1.txt\n", "L0:d1/d10/f2.emp\n", "L0:d1/f0.txt\n"]
|
105
|
+
assert_equal(exp,smap(ans))
|
106
|
+
|
107
|
+
ans = rio('d1').all.files(/f0/).lines[/L0/]
|
108
|
+
exp = ["L0:d1/d10/f0.txt\n", "L0:d1/f0.txt\n"]
|
109
|
+
assert_equal(exp,smap(ans))
|
110
|
+
|
111
|
+
ans = rio('d1').all.files(/f0/).lines[]
|
112
|
+
exp = ["L0:d1/d10/f0.txt\n", "L1:d1/d10/f0.txt\n", "L2:d1/d10/f0.txt\n", "L0:d1/f0.txt\n", "L1:d1/f0.txt\n", "L2:d1/f0.txt\n"]
|
113
|
+
assert_equal(exp,smap(ans))
|
114
|
+
|
115
|
+
ans = rio('d1').all.bytes(8).records(0..1).files[/f0/]
|
116
|
+
exp = ["L0:d1/d10/f0.txt\nL1:d1/d10/f0.txt\nL2:d1/d10/f0.txt\n", "L0:d1/f0.txt\nL1:d1/f0.txt\nL2:d1/f0.txt\n"]
|
117
|
+
assert_equal(exp,smap(ans))
|
118
|
+
|
119
|
+
ans = rio('d1').all.bytes(8).files(/f0/).records[0..1]
|
120
|
+
exp = ["L0:d1/d10/f0.txt\nL1:d1/d10/f0.txt\nL2:d1/d10/f0.txt\n", "L0:d1/f0.txt\nL1:d1/f0.txt\nL2:d1/f0.txt\n"]
|
121
|
+
assert_equal(exp,smap(ans))
|
122
|
+
|
123
|
+
|
124
|
+
ans = rio('d1').all.bytes(32).files(/f0/).records[]
|
125
|
+
exp = ["L0:d1/d10/f0.txt\nL1:d1/d10/f0.txt\nL2:d1/d10/f0.txt\n", "L0:d1/f0.txt\nL1:d1/f0.txt\nL2:d1/f0.txt\n"]
|
126
|
+
assert_equal(exp,smap(ans))
|
127
|
+
|
128
|
+
ans = rio('d1').all.bytes(32).files[/f0/]
|
129
|
+
exp = ["L0:d1/d10/f0.txt\nL1:d1/d10/f0.txt\nL2:d1/d10/f0.txt\n", "L0:d1/f0.txt\nL1:d1/f0.txt\nL2:d1/f0.txt\n"]
|
130
|
+
assert_equal(exp,smap(ans))
|
131
|
+
|
132
|
+
ans = rio('d1').all.bytes.files['*.emp']
|
133
|
+
exp = ["L0:d1/d10/f2.emp\nL1:d1/d10/f2.emp\nL2:d1/d10/f2.emp\n"]
|
134
|
+
assert_equal(exp,smap(ans))
|
135
|
+
|
136
|
+
ans = rio('d1').all.files('*.emp').bytes[]
|
137
|
+
exp = ["L0:d1/d10/f2.emp\nL1:d1/d10/f2.emp\nL2:d1/d10/f2.emp\n"]
|
138
|
+
assert_equal(exp,smap(ans))
|
139
|
+
|
140
|
+
ans = rio('d1').all.lines[]
|
141
|
+
exp = ["L0:d1/d10/d000/f100.txt\n", "L1:d1/d10/d000/f100.txt\n", "L2:d1/d10/d000/f100.txt\n",
|
142
|
+
"L0:d1/d10/f0.txt\n", "L1:d1/d10/f0.txt\n", "L2:d1/d10/f0.txt\n",
|
143
|
+
"L0:d1/d10/f1.txt\n", "L1:d1/d10/f1.txt\n", "L2:d1/d10/f1.txt\n",
|
144
|
+
"L0:d1/d10/f2.emp\n", "L1:d1/d10/f2.emp\n", "L2:d1/d10/f2.emp\n",
|
145
|
+
"L0:d1/f0.txt\n", "L1:d1/f0.txt\n", "L2:d1/f0.txt\n"]
|
146
|
+
assert_equal(exp,smap(ans))
|
147
|
+
|
148
|
+
ans = rio('d1').all[]
|
149
|
+
exp = ["d1/d10", "d1/d10/d000", "d1/d10/d000/f100.txt", "d1/d10/d100",
|
150
|
+
"d1/d10/f0.txt", "d1/d10/f1.txt", "d1/d10/f2.emp", "d1/d11", "d1/f0.txt"]
|
151
|
+
assert_equal(exp,smap(ans))
|
152
|
+
|
153
|
+
ans = rio('d1').all.files('*.emp').lines[]
|
154
|
+
exp = ["L0:d1/d10/f2.emp\n", "L1:d1/d10/f2.emp\n", "L2:d1/d10/f2.emp\n"]
|
155
|
+
assert_equal(exp,smap(ans))
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
if $0 == __FILE__
|
3
|
+
Dir.chdir File.dirname(__FILE__)+'/../'
|
4
|
+
$:.unshift File.expand_path('../lib/')
|
5
|
+
end
|
6
|
+
require 'rio'
|
7
|
+
require 'tc/testcase'
|
8
|
+
require 'pp'
|
9
|
+
|
10
|
+
class PathGenerator
|
11
|
+
ROOTS = ['r1','r 1']
|
12
|
+
DIRS = ['d1','d 1']
|
13
|
+
FILES = ['f1','f 1','f1.txt','f 1.txt']
|
14
|
+
UROOTS = ROOTS.map{|z| z.gsub(/ /,'%20')}
|
15
|
+
UDIRS = DIRS.map{|z| z.gsub(/ /,'%20')}
|
16
|
+
UFILES = FILES.map{|z| z.gsub(/ /,'%20')}
|
17
|
+
|
18
|
+
attr_reader :fs_basic_paths,:fs_url_paths,:fs_drive_paths,
|
19
|
+
:fs_unc_paths,:fs_paths,:http_paths,:ftp_paths, :uri_paths,:all_paths
|
20
|
+
|
21
|
+
def initialize()
|
22
|
+
@fs_basic_paths = self.class.fs_basic_paths()
|
23
|
+
@fs_url_paths = self.class.fs_url_paths()
|
24
|
+
@fs_drive_paths = self.class.fs_drive_paths()
|
25
|
+
@fs_unc_paths = self.class.fs_unc_paths()
|
26
|
+
@fs_paths = @fs_basic_paths + @fs_url_paths + @fs_drive_paths + @fs_unc_paths
|
27
|
+
@http_paths = self.class.http_paths()
|
28
|
+
@ftp_paths = self.class.ftp_paths()
|
29
|
+
@uri_paths = @http_paths + @ftp_paths
|
30
|
+
|
31
|
+
@all_paths = @fs_paths + @uri_paths
|
32
|
+
end
|
33
|
+
def self.fs_basic_paths()
|
34
|
+
tops = %w{/}
|
35
|
+
build_paths(tops,ROOTS,DIRS,FILES)
|
36
|
+
end
|
37
|
+
def self.fs_url_paths()
|
38
|
+
#tops = %w{file:/// file:///x:/ file://h/}
|
39
|
+
# tops = %w{file:/// file:///x:/ file://h/}
|
40
|
+
tops = %w{file:/// file://h/}
|
41
|
+
tops << 'file:///x:/' if $mswin32
|
42
|
+
build_paths(tops,ROOTS,DIRS,FILES)
|
43
|
+
end
|
44
|
+
def self.fs_drive_paths()
|
45
|
+
return [] unless $mswin32
|
46
|
+
tops = %w{x:/}
|
47
|
+
build_paths(tops,ROOTS,DIRS,FILES)
|
48
|
+
end
|
49
|
+
def self.fs_unc_paths()
|
50
|
+
tops = %w{//h/}
|
51
|
+
build_paths(tops,ROOTS,DIRS,FILES)
|
52
|
+
end
|
53
|
+
def self.http_paths()
|
54
|
+
htops = %w{http://h/}
|
55
|
+
build_paths(htops,UROOTS,UDIRS,UFILES)
|
56
|
+
end
|
57
|
+
def self.ftp_paths()
|
58
|
+
ftops = %w{ftp://h/}
|
59
|
+
build_paths(ftops,UROOTS,UDIRS,UFILES)
|
60
|
+
end
|
61
|
+
def self.build_paths(tops,roots,dirs,files)
|
62
|
+
paths = []
|
63
|
+
tops.each { |t|
|
64
|
+
paths << t
|
65
|
+
roots.each{|r| paths << t+r }
|
66
|
+
roots.map{|r| t + r + '/'}.each { |r|
|
67
|
+
paths << r
|
68
|
+
dirs.each{|d| paths << r+d}
|
69
|
+
dirs.map{|d| r+d+'/'}.each{|d|
|
70
|
+
paths << d
|
71
|
+
files.each{|f| paths << d+f}
|
72
|
+
files.map{|f| d+f}.each{|f|
|
73
|
+
paths << f
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
paths
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
class TC_path_parts < Test::RIO::TestCase
|
84
|
+
@@once = false
|
85
|
+
@@exp = nil
|
86
|
+
@@gen = PathGenerator.new
|
87
|
+
|
88
|
+
def self.once
|
89
|
+
@@once = true
|
90
|
+
expfile = RIO.cwd('../../tc/rlparts.ans.yml')
|
91
|
+
@@exp = expfile.yaml.get
|
92
|
+
end
|
93
|
+
|
94
|
+
def setup
|
95
|
+
super
|
96
|
+
self.class.once unless @@once
|
97
|
+
end
|
98
|
+
|
99
|
+
def run_path_tests_exp(paths,sym)
|
100
|
+
paths.each do |pstr|
|
101
|
+
#p pstr
|
102
|
+
r = rio(pstr)
|
103
|
+
assert_equal(@@exp[r.to_s][sym],r.__send__(sym).to_s,"rio('#{pstr}').#{sym} failed")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
def run_path_tests_native(paths,sym,*args)
|
107
|
+
paths.each do |pstr|
|
108
|
+
r = rio(pstr)
|
109
|
+
exp = File.__send__(sym,pstr,*args)
|
110
|
+
ans = r.__send__(sym,*args).to_s
|
111
|
+
#puts "#{sym}[#{r}]: #{exp} <=> #{ans}"
|
112
|
+
assert_equal(exp,ans,"rio('#{pstr}').#{sym} failed")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
def run_path_tests_native_fspath(paths,sym,*args)
|
116
|
+
paths.each do |pstr|
|
117
|
+
r = rio(pstr)
|
118
|
+
fpth = r.fspath
|
119
|
+
assert_equal(File.__send__(sym,fpth,*args),r.__send__(sym,*args).to_s,"rio('#{pstr}').#{sym} failed")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
def test_filename()
|
123
|
+
@@gen.all_paths.each do |pstr|
|
124
|
+
assert_equal(rio(pstr).basename(''),rio(pstr).filename)
|
125
|
+
assert_equal(rio(pstr).noext.basename,rio(pstr).filename)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
def test_uri_dirname
|
129
|
+
run_path_tests_exp(@@gen.uri_paths,:dirname)
|
130
|
+
end
|
131
|
+
def test_uri_basename
|
132
|
+
run_path_tests_exp(@@gen.uri_paths,:basename)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_fs_dirname
|
136
|
+
run_path_tests_native(@@gen.fs_basic_paths,:dirname)
|
137
|
+
run_path_tests_native(@@gen.fs_drive_paths,:dirname)
|
138
|
+
run_path_tests_exp(@@gen.fs_unc_paths,:dirname)
|
139
|
+
end
|
140
|
+
def test_fs_url_dirname
|
141
|
+
run_path_tests_exp(@@gen.fs_url_paths,:dirname)
|
142
|
+
end
|
143
|
+
def test_fs_url_basename
|
144
|
+
run_path_tests_native_fspath(@@gen.fs_url_paths,:basename,'')
|
145
|
+
run_path_tests_native_fspath(@@gen.fs_url_paths,:basename,'.txt')
|
146
|
+
end
|
147
|
+
def test_fs_basename
|
148
|
+
run_path_tests_native(@@gen.fs_basic_paths,:basename,'')
|
149
|
+
run_path_tests_native(@@gen.fs_drive_paths,:basename,'')
|
150
|
+
run_path_tests_native(@@gen.fs_unc_paths,:basename,'')
|
151
|
+
run_path_tests_native(@@gen.fs_basic_paths,:basename,'.txt')
|
152
|
+
run_path_tests_native(@@gen.fs_drive_paths,:basename,'.txt')
|
153
|
+
run_path_tests_native(@@gen.fs_unc_paths,:basename,'.txt')
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_fs_path
|
157
|
+
run_path_tests_exp(@@gen.fs_paths,:path)
|
158
|
+
end
|
159
|
+
def test_uri_path
|
160
|
+
run_path_tests_exp(@@gen.uri_paths,:path)
|
161
|
+
end
|
162
|
+
def test_fs_fspath
|
163
|
+
run_path_tests_exp(@@gen.fs_paths,:fspath)
|
164
|
+
end
|
165
|
+
def test_uri_fspath
|
166
|
+
run_path_tests_exp(@@gen.uri_paths,:fspath)
|
167
|
+
end
|
168
|
+
def test_fs_urlpath
|
169
|
+
run_path_tests_exp(@@gen.fs_paths,:urlpath)
|
170
|
+
end
|
171
|
+
def test_uri_urlpath
|
172
|
+
run_path_tests_exp(@@gen.uri_paths,:urlpath)
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|