wishdev-rio 0.4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -0,0 +1,102 @@
|
|
|
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_closeoncopy < Test::RIO::TestCase
|
|
11
|
+
@@once = false
|
|
12
|
+
def self.once
|
|
13
|
+
@@once = true
|
|
14
|
+
|
|
15
|
+
make_lines_file(3,'f0')
|
|
16
|
+
rio('d0').delete!.mkdir.chdir {
|
|
17
|
+
make_lines_file(3,'f1')
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
def setup
|
|
21
|
+
super
|
|
22
|
+
self.class.once unless @@once
|
|
23
|
+
|
|
24
|
+
@f0 = rio('f0')
|
|
25
|
+
end
|
|
26
|
+
def atest_method
|
|
27
|
+
assert(@f1.closeoncopy?)
|
|
28
|
+
assert!(@f2.closeoncopy?)
|
|
29
|
+
end
|
|
30
|
+
def cfrom(dest,src)
|
|
31
|
+
dest < src
|
|
32
|
+
assert(dest.closeoncopy?)
|
|
33
|
+
assert(dest.closed?)
|
|
34
|
+
|
|
35
|
+
dest << src
|
|
36
|
+
assert(dest.closeoncopy?)
|
|
37
|
+
assert(dest.closed?)
|
|
38
|
+
end
|
|
39
|
+
def test_copyfrom
|
|
40
|
+
#$trace_states = true
|
|
41
|
+
cfrom(rio('copyfrom').delete,rio(@f0))
|
|
42
|
+
cfrom(rio('copyfrom'),rio(@f0))
|
|
43
|
+
cfrom(rio('copyfrom').open('w'),rio(@f0))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def orio()
|
|
47
|
+
d = rio('copyfrom')
|
|
48
|
+
d.puts("aline\n")
|
|
49
|
+
assert(d.open?)
|
|
50
|
+
d
|
|
51
|
+
end
|
|
52
|
+
def test_copyfrom_open
|
|
53
|
+
#$trace_states = true
|
|
54
|
+
cfrom(orio,"Zipp\n")
|
|
55
|
+
cfrom(orio,rio(@f0))
|
|
56
|
+
cfrom(orio,["Zipp\n"])
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_copyfrom_array
|
|
60
|
+
#$trace_states = true
|
|
61
|
+
cfrom(rio('copyfrom').delete,["Zipp\n"])
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def cto(src,dest)
|
|
65
|
+
src > dest
|
|
66
|
+
assert(dest.closeoncopy?)
|
|
67
|
+
assert(dest.closed?)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def ato(src,dest)
|
|
71
|
+
src >> dest
|
|
72
|
+
assert(dest.closeoncopy?)
|
|
73
|
+
assert(dest.closed?)
|
|
74
|
+
end
|
|
75
|
+
def test_copyto
|
|
76
|
+
#$trace_states = true
|
|
77
|
+
cto(rio(@f0),rio('copyto').delete!)
|
|
78
|
+
cto(rio(@f0),rio('copyto'))
|
|
79
|
+
cto(rio(@f0),rio('copyto').open('w'))
|
|
80
|
+
cto(rio(@f0),rio('copyto').open('a'))
|
|
81
|
+
cto(rio(@f0),orio)
|
|
82
|
+
end
|
|
83
|
+
def test_appto
|
|
84
|
+
#$trace_states = true
|
|
85
|
+
ato(rio(@f0),rio('copyto').delete!)
|
|
86
|
+
ato(rio(@f0),rio('copyto'))
|
|
87
|
+
ato(rio(@f0),rio('copyto').open('w'))
|
|
88
|
+
ato(rio(@f0),rio('copyto').open('a'))
|
|
89
|
+
ato(rio(@f0),orio)
|
|
90
|
+
end
|
|
91
|
+
def test_cx_set
|
|
92
|
+
rio('d0').files { |f|
|
|
93
|
+
assert(f.closeoncopy?)
|
|
94
|
+
}
|
|
95
|
+
end
|
|
96
|
+
def test_cx_bequeath
|
|
97
|
+
rio('d0').nocloseoncopy.files { |f|
|
|
98
|
+
assert!(f.closeoncopy?)
|
|
99
|
+
}
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
__END__
|
|
@@ -0,0 +1,194 @@
|
|
|
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 'test/unit/testsuite'
|
|
9
|
+
|
|
10
|
+
class TC_RIO_closeoneof < Test::Unit::TestCase
|
|
11
|
+
def test_basic
|
|
12
|
+
qp = rio('qp')
|
|
13
|
+
rio(qp,'test_closeoneof').rmtree.mkpath.chdir {
|
|
14
|
+
exp = []
|
|
15
|
+
f = rio('lines.txt')
|
|
16
|
+
1.upto(3) do |n|
|
|
17
|
+
s = "Line #{n}\n"
|
|
18
|
+
f.print(s)
|
|
19
|
+
exp << s
|
|
20
|
+
end
|
|
21
|
+
f.close
|
|
22
|
+
exp_s = exp.join('')
|
|
23
|
+
|
|
24
|
+
rio('dir').mkdir
|
|
25
|
+
rio('dir/a1.txt') < rio('lines.txt')
|
|
26
|
+
rio('dir/a2.txt') < rio('lines.txt')
|
|
27
|
+
|
|
28
|
+
file = rio('lines.txt')
|
|
29
|
+
lines = file.to_a
|
|
30
|
+
assert_equal(exp,lines)
|
|
31
|
+
assert_equal(true,file.closed?)
|
|
32
|
+
|
|
33
|
+
file = rio('lines.txt')
|
|
34
|
+
lines = file.readlines
|
|
35
|
+
assert_equal(exp,lines)
|
|
36
|
+
assert_equal(true,file.closed?)
|
|
37
|
+
|
|
38
|
+
file = rio('lines.txt')
|
|
39
|
+
str = ""
|
|
40
|
+
file.each_line { |el| str += el }
|
|
41
|
+
assert_equal(exp_s,str)
|
|
42
|
+
assert_equal(true,file.closed?)
|
|
43
|
+
|
|
44
|
+
file = rio('lines.txt')
|
|
45
|
+
str = ""
|
|
46
|
+
file.each_byte { |el| str += el.chr }
|
|
47
|
+
assert_equal(exp_s,str)
|
|
48
|
+
assert_equal(true,file.closed?)
|
|
49
|
+
|
|
50
|
+
file = rio('lines.txt')
|
|
51
|
+
str = ""
|
|
52
|
+
file.bytes.each { |el| str += el }
|
|
53
|
+
assert_equal(exp_s,str)
|
|
54
|
+
assert_equal(true,file.closed?)
|
|
55
|
+
|
|
56
|
+
file = rio('lines.txt')
|
|
57
|
+
str = ""
|
|
58
|
+
file.bytes(3).each { |el| str += el }
|
|
59
|
+
assert_equal(exp_s,str)
|
|
60
|
+
assert_equal(true,file.closed?)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
file = rio('lines.txt').nocloseoneof
|
|
66
|
+
lines = file.to_a
|
|
67
|
+
assert_equal(exp,lines)
|
|
68
|
+
assert_equal(false,file.closed?)
|
|
69
|
+
file.close
|
|
70
|
+
|
|
71
|
+
file = rio('lines.txt').nocloseoneof
|
|
72
|
+
lines = file.readlines
|
|
73
|
+
assert_equal(exp,lines)
|
|
74
|
+
assert_equal(false,file.closed?)
|
|
75
|
+
file.close
|
|
76
|
+
|
|
77
|
+
file = rio('lines.txt').nocloseoneof
|
|
78
|
+
str = ""
|
|
79
|
+
file.each_line { |el| str += el }
|
|
80
|
+
assert_equal(exp_s,str)
|
|
81
|
+
assert_equal(false,file.closed?)
|
|
82
|
+
file.close
|
|
83
|
+
|
|
84
|
+
file = rio('lines.txt').nocloseoneof
|
|
85
|
+
str = ""
|
|
86
|
+
file.each_byte { |el| str += el.chr }
|
|
87
|
+
assert_equal(exp_s,str)
|
|
88
|
+
assert_equal(false,file.closed?)
|
|
89
|
+
file.close
|
|
90
|
+
|
|
91
|
+
file = rio('lines.txt').nocloseoneof
|
|
92
|
+
str = ""
|
|
93
|
+
file.bytes.each { |el| str += el }
|
|
94
|
+
assert_equal(exp_s,str)
|
|
95
|
+
assert_equal(false,file.closed?)
|
|
96
|
+
file.close
|
|
97
|
+
|
|
98
|
+
file = rio('lines.txt').nocloseoneof
|
|
99
|
+
str = ""
|
|
100
|
+
file.bytes(3).each { |el| str += el }
|
|
101
|
+
assert_equal(exp_s,str)
|
|
102
|
+
assert_equal(false,file.closed?)
|
|
103
|
+
file.close
|
|
104
|
+
|
|
105
|
+
file = rio('lines.txt')
|
|
106
|
+
str = ""
|
|
107
|
+
file.each { |el| str += el }
|
|
108
|
+
assert_equal(exp_s,str)
|
|
109
|
+
assert_equal(true,file.closed?)
|
|
110
|
+
|
|
111
|
+
file = rio('lines.txt')
|
|
112
|
+
str = ""
|
|
113
|
+
file.nocloseoneof.each { |el| str += el }
|
|
114
|
+
assert_equal(exp_s,str)
|
|
115
|
+
assert_equal(false,file.closed?)
|
|
116
|
+
file.close
|
|
117
|
+
|
|
118
|
+
file = rio('lines.txt')
|
|
119
|
+
str = ""
|
|
120
|
+
file.nocloseoneof { |el| str += el }
|
|
121
|
+
assert_equal(exp_s,str)
|
|
122
|
+
assert_equal(false,file.closed?)
|
|
123
|
+
file.close
|
|
124
|
+
|
|
125
|
+
file = rio('lines.txt')
|
|
126
|
+
str = ""
|
|
127
|
+
file.closeoneof { |el| str += el }
|
|
128
|
+
assert_equal(exp_s,str)
|
|
129
|
+
assert_equal(true,file.closed?)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
file = rio('lines.txt')
|
|
133
|
+
lines = file.nocloseoneof.readlines
|
|
134
|
+
assert_equal(exp,lines)
|
|
135
|
+
assert_equal(false,file.closed?)
|
|
136
|
+
file.close
|
|
137
|
+
|
|
138
|
+
file = rio('lines.txt').nocloseoneof
|
|
139
|
+
lines = file.to_a
|
|
140
|
+
assert_equal(false,file.closed?)
|
|
141
|
+
file.close
|
|
142
|
+
|
|
143
|
+
rio('dir').each { |en|
|
|
144
|
+
lines = en.to_a
|
|
145
|
+
assert_equal(exp,lines)
|
|
146
|
+
assert_equal(true,en.closed?)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
rio('dir').nocloseoneof.each { |en|
|
|
150
|
+
lines = en.to_a
|
|
151
|
+
assert_equal(exp,lines)
|
|
152
|
+
assert_equal(false,en.closed?)
|
|
153
|
+
en.close
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
rio('dir').nocloseoneof.each { |en|
|
|
157
|
+
lines = en.closeoneof.to_a
|
|
158
|
+
assert_equal(exp,lines)
|
|
159
|
+
assert_equal(true,en.closed?)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
rio('dir').closeoneof.each { |en|
|
|
163
|
+
lines = en.nocloseoneof.to_a
|
|
164
|
+
assert_equal(exp,lines)
|
|
165
|
+
assert_equal(false,en.closed?)
|
|
166
|
+
en.close
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
rio('dir').nocloseoneof { |en|
|
|
171
|
+
lines = en.to_a
|
|
172
|
+
assert_equal(exp,lines)
|
|
173
|
+
assert_equal(false,en.closed?)
|
|
174
|
+
en.close
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
rio('dir').nocloseoneof { |en|
|
|
178
|
+
lines = en.closeoneof.to_a
|
|
179
|
+
assert_equal(exp,lines)
|
|
180
|
+
assert_equal(true,en.closed?)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
rio('dir').closeoneof { |en|
|
|
184
|
+
lines = en.nocloseoneof.to_a
|
|
185
|
+
assert_equal(exp,lines)
|
|
186
|
+
assert_equal(false,en.closed?)
|
|
187
|
+
en.close
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
end
|
data/test/tc/cmdpipe.rb
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
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_cmdpipe < Test::RIO::TestCase
|
|
11
|
+
@@once = false
|
|
12
|
+
@@dname = 'd'
|
|
13
|
+
@@fnames = ['f0','f1','f2','g0','g1']
|
|
14
|
+
|
|
15
|
+
require 'tc/programs_util'
|
|
16
|
+
include Test::RIO::Programs
|
|
17
|
+
|
|
18
|
+
def self.once
|
|
19
|
+
@@once = true
|
|
20
|
+
rio(@@dname).rmtree.mkpath.chdir {
|
|
21
|
+
@@fnames.each { |fn|
|
|
22
|
+
make_lines_file(20,fn)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
def setup
|
|
27
|
+
super
|
|
28
|
+
self.class.once unless @@once
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_cmd_out
|
|
32
|
+
ls = rio(?-,PROG['list_dir']+' d')
|
|
33
|
+
out = rio(?").chomp
|
|
34
|
+
exp = @@fnames
|
|
35
|
+
rtn = ls | out
|
|
36
|
+
assert_equal(exp,out[])
|
|
37
|
+
assert_equal(rtn,out)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_cmd_cmd_out
|
|
41
|
+
ls = rio(?-,PROG['list_dir']+' d')
|
|
42
|
+
grep = rio(?-,PROG['find_lines']+' f')
|
|
43
|
+
out = rio(?").chomp
|
|
44
|
+
exp = @@fnames.select { |fn| fn =~ /f/ }
|
|
45
|
+
rtn = ls | grep | out
|
|
46
|
+
assert_equal(exp,out[])
|
|
47
|
+
assert_equal(rtn,out)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_cmd_cmd_cmd_out
|
|
51
|
+
ls = rio(?-,PROG['list_dir']+' d')
|
|
52
|
+
cmd = rio(?-,PROG['find_lines']+' f')
|
|
53
|
+
cmd2 = rio(?-,PROG['find_lines']+' 1')
|
|
54
|
+
out = rio(?").chomp
|
|
55
|
+
exp = @@fnames.select { |fn| fn =~ /f1/ }
|
|
56
|
+
rtn = ls | cmd | cmd2 | out
|
|
57
|
+
assert_equal(exp,out[])
|
|
58
|
+
assert_equal(rtn,out)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_file_out
|
|
62
|
+
inp = rio('d/f2')
|
|
63
|
+
out = rio(?")
|
|
64
|
+
rtn = inp | out
|
|
65
|
+
exp = inp[]
|
|
66
|
+
assert_equal(exp,out[])
|
|
67
|
+
assert_equal(rtn,out)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_file_cmd_out
|
|
71
|
+
inp = rio('d/f2')
|
|
72
|
+
cmd = rio(?-,PROG['find_lines']+' 1')
|
|
73
|
+
out = rio(?")
|
|
74
|
+
rtn = inp | cmd | out
|
|
75
|
+
exp = inp[/1/]
|
|
76
|
+
assert_equal(exp,out[])
|
|
77
|
+
assert_equal(rtn,out)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_file_cmd_cmd_out
|
|
81
|
+
inp = rio('d/f2')
|
|
82
|
+
cmd = rio(?-,PROG['find_lines']+' 1')
|
|
83
|
+
cmd2 = rio(?-,PROG['find_lines']+' 0')
|
|
84
|
+
out = rio(?")
|
|
85
|
+
rtn = inp | cmd | cmd2 | out
|
|
86
|
+
exp = inp[/10/]
|
|
87
|
+
assert_equal(exp,out[])
|
|
88
|
+
assert_equal(rtn,out)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_file_cmdpipe_out2
|
|
92
|
+
inp = rio('d/f2')
|
|
93
|
+
cmd = rio(?-,PROG['find_lines']+' 1')
|
|
94
|
+
cmd2 = rio(?-,PROG['find_lines']+' 0')
|
|
95
|
+
|
|
96
|
+
cmdpipe = inp | cmd | cmd2
|
|
97
|
+
assert_equal('cmdpipe',cmdpipe.scheme)
|
|
98
|
+
|
|
99
|
+
out = rio(?")
|
|
100
|
+
rtn = cmdpipe | out
|
|
101
|
+
exp = inp[/10/]
|
|
102
|
+
assert_equal(exp,out[])
|
|
103
|
+
assert_equal(rtn,out)
|
|
104
|
+
|
|
105
|
+
out = rio(?")
|
|
106
|
+
rtn = cmdpipe | out
|
|
107
|
+
exp = inp[/10/]
|
|
108
|
+
assert_equal(exp,out[])
|
|
109
|
+
assert_equal(rtn,out)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def test_file_cmdpipe_out
|
|
113
|
+
inp = rio('d/f2')
|
|
114
|
+
cmd = rio(?-,PROG['find_lines']+' 1')
|
|
115
|
+
cmd2 = rio(?-,PROG['find_lines']+' 0')
|
|
116
|
+
out = rio(?")
|
|
117
|
+
|
|
118
|
+
cmdpipe = cmd | cmd2
|
|
119
|
+
assert_equal('cmdpipe',cmdpipe.scheme)
|
|
120
|
+
|
|
121
|
+
rtn = inp | cmdpipe | out
|
|
122
|
+
exp = inp[/10/]
|
|
123
|
+
assert_equal(exp,out[])
|
|
124
|
+
assert_equal(rtn,out)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_cmdpipe_without
|
|
128
|
+
cmd = rio(?-,PROG['find_lines']+' 1')
|
|
129
|
+
cmd2 = rio(?-,PROG['find_lines']+' 0')
|
|
130
|
+
out = rio(?")
|
|
131
|
+
|
|
132
|
+
cmdpipe = rio(?|,cmd,cmd2,out)
|
|
133
|
+
assert_equal('cmdpipe',cmdpipe.scheme)
|
|
134
|
+
|
|
135
|
+
inp = rio('d/f2')
|
|
136
|
+
rtn = inp | cmdpipe
|
|
137
|
+
exp = inp[/10/]
|
|
138
|
+
assert_equal(exp,out[])
|
|
139
|
+
assert_equal(rtn,out)
|
|
140
|
+
|
|
141
|
+
inp = rio('d/f1')
|
|
142
|
+
rtn = inp | cmdpipe
|
|
143
|
+
exp = inp[[/1/,/0/]]
|
|
144
|
+
assert_equal(exp,out[])
|
|
145
|
+
assert_equal(rtn,out)
|
|
146
|
+
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
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_copy_dir_samevar < Test::RIO::TestCase
|
|
11
|
+
@@once = false
|
|
12
|
+
def self.once
|
|
13
|
+
@@once = true
|
|
14
|
+
|
|
15
|
+
rio('d0').rmtree.mkpath
|
|
16
|
+
rio('d0/d1').rmtree.mkpath
|
|
17
|
+
make_lines_file(1,'d0/f0.txt')
|
|
18
|
+
make_lines_file(2,'d0/f1.txt')
|
|
19
|
+
make_lines_file(5,'d0/d1/f2.txt')
|
|
20
|
+
make_lines_file(6,'d0/d1/f3.txt')
|
|
21
|
+
rio('d2').rmtree.mkpath
|
|
22
|
+
make_lines_file(3,'d2/f4.txt')
|
|
23
|
+
end
|
|
24
|
+
def setup
|
|
25
|
+
super
|
|
26
|
+
self.class.once unless @@once
|
|
27
|
+
|
|
28
|
+
@d0 = rio('d0')
|
|
29
|
+
@d1 = rio('d0/d1')
|
|
30
|
+
@f0 = rio('d0/f0.txt')
|
|
31
|
+
@f1 = rio('d0/f1.txt')
|
|
32
|
+
@f2 = rio('d0/d1/f2.txt')
|
|
33
|
+
@f3 = rio('d0/d1/f3.txt')
|
|
34
|
+
@d2 = rio('d2')
|
|
35
|
+
@f4 = rio('d2/f4.txt')
|
|
36
|
+
rio('exp').delete!.mkdir < rio(@d0)
|
|
37
|
+
rio('exp2').delete!.mkdir < rio(@d2)
|
|
38
|
+
end
|
|
39
|
+
def test_copy_files
|
|
40
|
+
rio(@d0).files { |f|
|
|
41
|
+
f < f.contents
|
|
42
|
+
}
|
|
43
|
+
assert_rios_equal(rio('exp',@f0),rio(@f0))
|
|
44
|
+
assert_rios_equal(rio('exp',@f1),rio(@f1))
|
|
45
|
+
end
|
|
46
|
+
def test_copy_files_contents_gsub
|
|
47
|
+
rio(@d0).files { |f|
|
|
48
|
+
f < f.contents.gsub(/^L1/,'Line1')
|
|
49
|
+
}
|
|
50
|
+
assert_rios_equal(rio('exp',@f0),rio(@f0))
|
|
51
|
+
exp = rio('exp',@f1).chomp.lines[].map{|l| l.sub(/^L1/,'Line1')}
|
|
52
|
+
assert_equal(exp,rio(@f1).chomp[])
|
|
53
|
+
end
|
|
54
|
+
def test_copy_files_array
|
|
55
|
+
rio(@d0).files { |f|
|
|
56
|
+
f < f.lines[]
|
|
57
|
+
}
|
|
58
|
+
assert_rios_equal(rio('exp',@f0),rio(@f0))
|
|
59
|
+
assert_rios_equal(rio('exp',@f1),rio(@f1))
|
|
60
|
+
end
|
|
61
|
+
def test_copy_files_array_sel
|
|
62
|
+
rio(@d0).files { |f|
|
|
63
|
+
f < f.lines[/^L0/]
|
|
64
|
+
}
|
|
65
|
+
assert_rios_equal(rio('exp',@f0),rio(@f0))
|
|
66
|
+
exp = rio('exp',@f1).lines[0]
|
|
67
|
+
assert_equal(exp,rio(@f1).lines[])
|
|
68
|
+
end
|
|
69
|
+
def test_copy_all_files_array
|
|
70
|
+
rio(@d0).all.files { |f|
|
|
71
|
+
f < f.lines[]
|
|
72
|
+
}
|
|
73
|
+
assert_rios_equal(rio('exp',@f0),rio(@f0))
|
|
74
|
+
assert_rios_equal(rio('exp',@f1),rio(@f1))
|
|
75
|
+
end
|
|
76
|
+
def test_copy_all_files
|
|
77
|
+
rio(@d0).all.files { |f|
|
|
78
|
+
f < f.contents
|
|
79
|
+
}
|
|
80
|
+
assert_rios_equal(rio('exp',@f0),rio(@f0))
|
|
81
|
+
assert_rios_equal(rio('exp',@f1),rio(@f1))
|
|
82
|
+
assert_rios_equal(rio('exp',@f2),rio(@f2))
|
|
83
|
+
assert_rios_equal(rio('exp',@f3),rio(@f3))
|
|
84
|
+
end
|
|
85
|
+
def cptest(src)
|
|
86
|
+
dst = rio('dst').delete!.mkpath
|
|
87
|
+
dst < src.clone
|
|
88
|
+
assert_rios_equal(src.clone,rio(dst,src.filename),"rio copy")
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|