rio 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1273 -1482
- data/README +2 -2
- data/Rakefile +5 -5
- data/VERSION +1 -1
- data/{RUNME.1st.rb → build_doc.rb} +4 -10
- data/doc/ANNOUNCE +33 -80
- data/doc/RELEASE_NOTES +31 -1
- data/doc/generators/template/html/rio.rb +3 -3
- data/lib/rio/abstract_method.rb +2 -2
- data/lib/rio/argv.rb +2 -2
- data/lib/rio/arycopy.rb +2 -2
- data/lib/rio/assert.rb +2 -2
- data/lib/rio/base.rb +2 -2
- data/lib/rio/callstr.rb +47 -0
- data/lib/rio/const.rb +52 -0
- data/lib/rio/construct.rb +6 -24
- data/lib/rio/constructor.rb +12 -2
- data/lib/rio/context/autoclose.rb +73 -0
- data/lib/rio/context/copying.rb +2 -2
- data/lib/rio/context/cxx.rb +2 -2
- data/lib/rio/context/dir.rb +2 -2
- data/lib/rio/context/gzip.rb +2 -2
- data/lib/rio/context/methods.rb +6 -34
- data/lib/rio/context/skip.rb +2 -2
- data/lib/rio/context/stream.rb +2 -2
- data/lib/rio/context.rb +17 -2
- data/lib/rio/cp.rb +35 -9
- data/lib/rio/def.rb +54 -0
- data/lib/rio/dir.rb +19 -20
- data/lib/rio/doc/HOWTO.rb +23 -7
- data/lib/rio/doc/INTRO.rb +57 -23
- data/lib/rio/doc/MISC.rb +2 -2
- data/lib/rio/doc/OPTIONAL.rb +134 -0
- data/lib/rio/doc/SYNOPSIS.rb +11 -4
- data/lib/rio/doc.rb +2 -2
- data/lib/rio/entrysel.rb +25 -6
- data/lib/rio/exception/copy.rb +2 -2
- data/lib/rio/exception/notsupported.rb +47 -0
- data/lib/rio/exception/open.rb +2 -2
- data/lib/rio/exception/state.rb +2 -2
- data/lib/rio/exception.rb +2 -2
- data/lib/rio/ext/csv.rb +56 -11
- data/lib/rio/ext/yaml.rb +2 -2
- data/lib/rio/ext/zipfile.rb +91 -0
- data/lib/rio/ext.rb +38 -3
- data/lib/rio/factory.rb +17 -34
- data/lib/rio/file.rb +48 -8
- data/lib/rio/filter/closeoneof.rb +36 -16
- data/lib/rio/filter/gzip.rb +2 -2
- data/lib/rio/filter.rb +2 -2
- data/lib/rio/fs/base.rb +42 -0
- data/lib/rio/fs/impl.rb +123 -0
- data/lib/rio/fs/native.rb +76 -0
- data/lib/rio/{record.rb → fs/stream.rb} +21 -18
- data/lib/rio/fs/url.rb +64 -0
- data/lib/rio/ftp/{ioh.rb → conncache.rb} +38 -39
- data/lib/rio/ftp/dir.rb +95 -0
- data/lib/rio/ftp/fs.rb +173 -0
- data/lib/rio/ftp/ftpfile.rb +20 -0
- data/lib/rio/grande.rb +2 -2
- data/lib/rio/handle.rb +2 -2
- data/lib/rio/if/basic.rb +2 -2
- data/lib/rio/if/csv.rb +2 -2
- data/lib/rio/if/dir.rb +2 -2
- data/lib/rio/if/file.rb +26 -2
- data/lib/rio/if/fileordir.rb +44 -49
- data/lib/rio/if/grande.rb +32 -10
- data/lib/rio/if/grande_entry.rb +12 -2
- data/lib/rio/if/grande_stream.rb +17 -28
- data/lib/rio/if/internal.rb +2 -2
- data/lib/rio/if/path.rb +7 -6
- data/lib/rio/if/stream.rb +85 -29
- data/lib/rio/if/string.rb +2 -2
- data/lib/rio/if/temp.rb +2 -2
- data/lib/rio/if/test.rb +37 -4
- data/lib/rio/if/yaml.rb +2 -2
- data/lib/rio/if.rb +2 -2
- data/lib/rio/impl/path.rb +2 -2
- data/lib/rio/ioh.rb +17 -6
- data/lib/rio/iomode.rb +4 -3
- data/lib/rio/ios/fail.rb +107 -0
- data/lib/rio/ios/generic.rb +120 -0
- data/lib/rio/ios/mode.rb +61 -0
- data/lib/rio/ios/null.rb +120 -0
- data/lib/rio/iowrap.rb +129 -0
- data/lib/rio/kernel.rb +12 -3
- data/lib/rio/local.rb +2 -2
- data/lib/rio/match.rb +3 -3
- data/lib/rio/matchrecord.rb +2 -2
- data/lib/rio/no_warn.rb +50 -0
- data/lib/rio/{arrayio.rb → nullio.rb} +47 -86
- data/lib/rio/open3.rb +2 -2
- data/lib/rio/ops/construct.rb +20 -13
- data/lib/rio/ops/create.rb +10 -19
- data/lib/rio/ops/dir.rb +60 -54
- data/lib/rio/ops/either.rb +11 -9
- data/lib/rio/ops/file.rb +28 -24
- data/lib/rio/ops/path.rb +45 -43
- data/lib/rio/ops/stream/input.rb +12 -8
- data/lib/rio/ops/stream/output.rb +2 -2
- data/lib/rio/ops/stream/read.rb +35 -32
- data/lib/rio/ops/stream/write.rb +5 -5
- data/lib/rio/ops/stream.rb +7 -3
- data/lib/rio/ops/symlink.rb +12 -10
- data/lib/rio/path/reset.rb +5 -5
- data/lib/rio/path.rb +32 -24
- data/lib/rio/piper/cp.rb +2 -2
- data/lib/rio/piper.rb +2 -2
- data/lib/rio/prompt.rb +2 -2
- data/lib/rio/rectype.rb +9 -7
- data/lib/rio/rl/base.rb +5 -4
- data/lib/rio/rl/builder.rb +17 -5
- data/lib/rio/rl/ioi.rb +14 -4
- data/lib/rio/rl/path.rb +23 -15
- data/lib/rio/rl/pathmethods.rb +12 -2
- data/lib/rio/rl/uri.rb +13 -6
- data/lib/rio/scheme/aryio.rb +3 -3
- data/lib/rio/scheme/cmdio.rb +4 -3
- data/lib/rio/scheme/cmdpipe.rb +3 -35
- data/lib/rio/scheme/fd.rb +4 -3
- data/lib/rio/scheme/ftp.rb +36 -7
- data/lib/rio/scheme/http.rb +2 -2
- data/lib/rio/{context/closeoneof.rb → scheme/null.rb} +17 -11
- data/lib/rio/scheme/path.rb +28 -30
- data/lib/rio/scheme/stderr.rb +4 -4
- data/lib/rio/scheme/stdio.rb +6 -5
- data/lib/rio/scheme/strio.rb +10 -20
- data/lib/rio/scheme/sysio.rb +5 -2
- data/lib/rio/scheme/tcp.rb +4 -3
- data/lib/rio/scheme/temp.rb +14 -1
- data/lib/rio/state/error.rb +2 -2
- data/lib/rio/state.rb +80 -34
- data/lib/rio/stream/base.rb +7 -2
- data/lib/rio/stream/duplex.rb +13 -10
- data/lib/rio/stream/open.rb +74 -79
- data/lib/rio/stream.rb +15 -23
- data/lib/rio/symantics.rb +2 -2
- data/lib/rio/tempdir.rb +132 -132
- data/lib/rio/to_rio/all.rb +40 -0
- data/lib/rio/to_rio/array.rb +40 -0
- data/lib/rio/to_rio/io.rb +41 -0
- data/lib/rio/to_rio/object.rb +43 -0
- data/lib/rio/to_rio/string.rb +41 -0
- data/lib/rio/to_rio.rb +13 -2
- data/lib/rio/uri/file.rb +2 -2
- data/lib/rio/util.rb +2 -2
- data/lib/rio/version.rb +3 -3
- data/lib/rio.rb +16 -25
- 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_misc.rb +112 -0
- data/test/ftp/anon_read.rb +105 -0
- data/test/ftp/anon_special.rb +68 -0
- data/test/ftp/anon_write.rb +63 -0
- data/test/ftp/ftp2ftp.rb +51 -0
- data/test/ftp/initftpfiles.rb +14 -0
- data/test/ftp/testdef.rb +51 -0
- data/test/gem_runtests.rb +15 -15
- data/test/runalltests.rb +15 -0
- data/test/runftptests.rb +14 -0
- data/test/{1.rb → runhttptests.rb} +14 -14
- data/test/runtests.rb +14 -14
- data/test/tc/all.rb +36 -21
- data/test/tc/cmdpipe.rb +18 -15
- data/test/tc/copy-from-http.rb +89 -0
- data/test/tc/copy-from.rb +1 -52
- data/test/tc/copy.rb +19 -17
- data/test/tc/csv2.rb +6 -3
- data/test/tc/empty.rb +47 -0
- data/test/tc/emptyriodir.rb +129 -0
- data/test/tc/entsel.rb +110 -0
- data/test/tc/files_select.rb +92 -0
- data/test/tc/get.rb +7 -6
- data/test/tc/getrec.rb +2 -5
- data/test/tc/gzip.rb +82 -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 +112 -0
- data/test/tc/methods.rb +10 -9
- data/test/tc/misc.rb +1 -37
- data/test/tc/null.rb +45 -0
- data/test/tc/pid.rb +31 -0
- data/test/tc/piper.rb +34 -37
- data/test/tc/programs_util.rb +24 -0
- data/test/tc/readline.rb +30 -0
- data/test/tc/rename.rb +12 -0
- data/test/tc/tempfile.rb +14 -0
- data/test/tc/testcase.rb +6 -0
- data/test/tc/tonl.rb +37 -0
- metadata +181 -144
- data/ex/colx.rb +0 -8
- data/ex/findinruby +0 -16
- data/ex/findruby +0 -15
- data/ex/passwd_report.rb +0 -8
- data/ex/prompt.rb +0 -25
- data/ex/rgb.txt.gz +0 -0
- data/ex/riocat +0 -35
- data/ex/riogunzip +0 -31
- data/ex/riogzip +0 -24
- data/ex/rioprompt.rb +0 -6
- data/ex/targz2zip +0 -17
- data/ex/tolf +0 -11
- data/lib/rio/ftp/conn.rb +0 -167
- data/lib/rio/ftp.rb +0 -275
- data/test/once.rb +0 -7
data/test/runftptests.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
Dir.chdir File.dirname(__FILE__)
|
3
|
+
$devlib=File.expand_path('../lib/')
|
4
|
+
$:.unshift $devlib unless $:[0] == $devlib
|
5
|
+
|
6
|
+
$mswin32 = (RUBY_PLATFORM =~ /mswin32/)
|
7
|
+
|
8
|
+
require 'rio'
|
9
|
+
require 'test/unit'
|
10
|
+
|
11
|
+
require 'ftp/all'
|
12
|
+
$trace_states = false
|
13
|
+
require 'test/unit/ui/console/testrunner'
|
14
|
+
#require 'test/unit/ui/tk/testrunner'
|
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
Dir.chdir File.dirname(__FILE__)
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
$trace_states = false
|
13
|
-
require 'test/unit/ui/console/testrunner'
|
14
|
-
#require 'test/unit/ui/tk/testrunner'
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
Dir.chdir File.dirname(__FILE__)
|
3
|
+
$devlib=File.expand_path('../lib/')
|
4
|
+
$:.unshift $devlib unless $:[0] == $devlib
|
5
|
+
|
6
|
+
$mswin32 = (RUBY_PLATFORM =~ /mswin32/)
|
7
|
+
|
8
|
+
require 'rio'
|
9
|
+
require 'test/unit'
|
10
|
+
|
11
|
+
require 'tc/copy-from-http'
|
12
|
+
$trace_states = false
|
13
|
+
require 'test/unit/ui/console/testrunner'
|
14
|
+
#require 'test/unit/ui/tk/testrunner'
|
data/test/runtests.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
Dir.chdir File.dirname(__FILE__)
|
3
|
-
$devlib=File.expand_path('../lib/')
|
4
|
-
$:.unshift $devlib unless $:[0] == $devlib
|
5
|
-
|
6
|
-
$mswin32 = (RUBY_PLATFORM =~ /mswin32/)
|
7
|
-
|
8
|
-
require 'rio'
|
9
|
-
require 'test/unit'
|
10
|
-
|
11
|
-
require 'tc/all'
|
12
|
-
$trace_states = false
|
13
|
-
require 'test/unit/ui/console/testrunner'
|
14
|
-
#require 'test/unit/ui/tk/testrunner'
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
Dir.chdir File.dirname(__FILE__)
|
3
|
+
$devlib=File.expand_path('../lib/')
|
4
|
+
$:.unshift $devlib unless $:[0] == $devlib
|
5
|
+
|
6
|
+
$mswin32 = (RUBY_PLATFORM =~ /mswin32/)
|
7
|
+
|
8
|
+
require 'rio'
|
9
|
+
require 'test/unit'
|
10
|
+
|
11
|
+
require 'tc/all'
|
12
|
+
$trace_states = false
|
13
|
+
require 'test/unit/ui/console/testrunner'
|
14
|
+
#require 'test/unit/ui/tk/testrunner'
|
data/test/tc/all.rb
CHANGED
@@ -2,59 +2,74 @@ require 'test/unit'
|
|
2
2
|
require 'tc/testcase'
|
3
3
|
|
4
4
|
#require 'tc/yaml'
|
5
|
-
|
6
|
-
require 'tc/piper' unless $mswin32
|
7
|
-
require 'tc/cmdpipe'
|
8
|
-
require 'tc/base'
|
9
|
-
require 'tc/split'
|
10
|
-
require 'tc/route'
|
11
|
-
require 'tc/skip'
|
12
|
-
require 'tc/skiplines'
|
13
|
-
require 'tc/selnosel'
|
14
|
-
require 'tc/csv'
|
15
|
-
require 'tc/csv2'
|
16
|
-
require 'tc/csv_columns'
|
17
|
-
require 'tc/temp'
|
18
|
-
require 'tc/tempfile'
|
19
|
-
require 'tc/tempdir'
|
20
|
-
require 'tc/riorl'
|
5
|
+
|
21
6
|
require 'tc/abs'
|
22
|
-
require 'tc/
|
7
|
+
require 'tc/tonl'
|
8
|
+
require 'tc/files_select'
|
9
|
+
require 'tc/emptyriodir'
|
10
|
+
require 'tc/entsel'
|
11
|
+
require 'tc/base'
|
23
12
|
require 'tc/clearsel'
|
24
13
|
require 'tc/closeoncopy'
|
25
|
-
require 'tc/
|
26
|
-
require 'tc/
|
14
|
+
require 'tc/closeoneof'
|
15
|
+
require 'tc/cmdpipe'
|
27
16
|
require 'tc/copy'
|
17
|
+
require 'tc/copy-from'
|
18
|
+
require 'tc/copy-to'
|
28
19
|
require 'tc/copyarray'
|
20
|
+
require 'tc/copydest'
|
29
21
|
require 'tc/copydir'
|
30
22
|
require 'tc/copydirlines'
|
31
|
-
require 'tc/copydest'
|
32
23
|
require 'tc/copylines'
|
33
24
|
require 'tc/create'
|
25
|
+
require 'tc/csv'
|
26
|
+
require 'tc/csv2'
|
27
|
+
require 'tc/csv_columns'
|
34
28
|
require 'tc/dir'
|
29
|
+
require 'tc/dir_iter'
|
35
30
|
require 'tc/dirent'
|
36
31
|
require 'tc/each'
|
37
32
|
require 'tc/each_break'
|
33
|
+
require 'tc/empty'
|
38
34
|
require 'tc/entary'
|
39
35
|
require 'tc/eq'
|
40
36
|
require 'tc/expand_path'
|
41
37
|
require 'tc/ext'
|
42
|
-
require 'tc/getrec'
|
43
38
|
require 'tc/get'
|
39
|
+
require 'tc/gzip'
|
40
|
+
require 'tc/getrec'
|
41
|
+
require 'tc/io_each_byte'
|
42
|
+
require 'tc/io_read'
|
43
|
+
require 'tc/iometh'
|
44
|
+
require 'tc/likeio'
|
44
45
|
require 'tc/lines'
|
45
46
|
require 'tc/methods'
|
46
47
|
require 'tc/misc'
|
47
48
|
require 'tc/nolines'
|
48
49
|
require 'tc/noqae'
|
50
|
+
require 'tc/null' unless $mswin32
|
49
51
|
require 'tc/overload'
|
50
52
|
require 'tc/pa'
|
51
53
|
require 'tc/paths'
|
54
|
+
require 'tc/pid'
|
55
|
+
require 'tc/pid'
|
56
|
+
require 'tc/piper' unless $mswin32
|
52
57
|
require 'tc/qae'
|
53
58
|
require 'tc/qae_riovar'
|
59
|
+
require 'tc/readline'
|
54
60
|
require 'tc/records'
|
55
61
|
require 'tc/rename'
|
62
|
+
require 'tc/riorl'
|
63
|
+
require 'tc/route'
|
64
|
+
require 'tc/selnosel'
|
65
|
+
require 'tc/skip'
|
66
|
+
require 'tc/skiplines'
|
67
|
+
require 'tc/split'
|
56
68
|
require 'tc/symlink' unless $mswin32
|
57
69
|
require 'tc/symlink0' unless $mswin32
|
58
70
|
require 'tc/symlink1' unless $mswin32
|
71
|
+
require 'tc/temp'
|
72
|
+
require 'tc/tempdir'
|
73
|
+
require 'tc/tempfile'
|
59
74
|
|
60
75
|
|
data/test/tc/cmdpipe.rb
CHANGED
@@ -12,6 +12,9 @@ class TC_cmdpipe < Test::RIO::TestCase
|
|
12
12
|
@@dname = 'd'
|
13
13
|
@@fnames = ['f0','f1','f2','g0','g1']
|
14
14
|
|
15
|
+
require 'tc/programs_util'
|
16
|
+
include Test::RIO::Programs
|
17
|
+
|
15
18
|
def self.once
|
16
19
|
@@once = true
|
17
20
|
rio(@@dname).rmtree.mkpath.chdir {
|
@@ -26,7 +29,7 @@ class TC_cmdpipe < Test::RIO::TestCase
|
|
26
29
|
end
|
27
30
|
|
28
31
|
def test_cmd_out
|
29
|
-
ls = rio(?-,'
|
32
|
+
ls = rio(?-,PROG['list_dir']+' d')
|
30
33
|
out = rio(?").chomp
|
31
34
|
exp = @@fnames
|
32
35
|
rtn = ls | out
|
@@ -35,8 +38,8 @@ class TC_cmdpipe < Test::RIO::TestCase
|
|
35
38
|
end
|
36
39
|
|
37
40
|
def test_cmd_cmd_out
|
38
|
-
ls = rio(?-,'
|
39
|
-
grep = rio(?-,'
|
41
|
+
ls = rio(?-,PROG['list_dir']+' d')
|
42
|
+
grep = rio(?-,PROG['find_lines']+' f')
|
40
43
|
out = rio(?").chomp
|
41
44
|
exp = @@fnames.select { |fn| fn =~ /f/ }
|
42
45
|
rtn = ls | grep | out
|
@@ -45,9 +48,9 @@ class TC_cmdpipe < Test::RIO::TestCase
|
|
45
48
|
end
|
46
49
|
|
47
50
|
def test_cmd_cmd_cmd_out
|
48
|
-
ls = rio(?-,'
|
49
|
-
cmd = rio(?-,'
|
50
|
-
cmd2 = rio(?-,'
|
51
|
+
ls = rio(?-,PROG['list_dir']+' d')
|
52
|
+
cmd = rio(?-,PROG['find_lines']+' f')
|
53
|
+
cmd2 = rio(?-,PROG['find_lines']+' 1')
|
51
54
|
out = rio(?").chomp
|
52
55
|
exp = @@fnames.select { |fn| fn =~ /f1/ }
|
53
56
|
rtn = ls | cmd | cmd2 | out
|
@@ -66,7 +69,7 @@ class TC_cmdpipe < Test::RIO::TestCase
|
|
66
69
|
|
67
70
|
def test_file_cmd_out
|
68
71
|
inp = rio('d/f2')
|
69
|
-
cmd = rio(?-,'
|
72
|
+
cmd = rio(?-,PROG['find_lines']+' 1')
|
70
73
|
out = rio(?")
|
71
74
|
rtn = inp | cmd | out
|
72
75
|
exp = inp[/1/]
|
@@ -76,8 +79,8 @@ class TC_cmdpipe < Test::RIO::TestCase
|
|
76
79
|
|
77
80
|
def test_file_cmd_cmd_out
|
78
81
|
inp = rio('d/f2')
|
79
|
-
cmd = rio(?-,'
|
80
|
-
cmd2 = rio(?-,'
|
82
|
+
cmd = rio(?-,PROG['find_lines']+' 1')
|
83
|
+
cmd2 = rio(?-,PROG['find_lines']+' 0')
|
81
84
|
out = rio(?")
|
82
85
|
rtn = inp | cmd | cmd2 | out
|
83
86
|
exp = inp[/10/]
|
@@ -87,8 +90,8 @@ class TC_cmdpipe < Test::RIO::TestCase
|
|
87
90
|
|
88
91
|
def test_file_cmdpipe_out2
|
89
92
|
inp = rio('d/f2')
|
90
|
-
cmd = rio(?-,'
|
91
|
-
cmd2 = rio(?-,'
|
93
|
+
cmd = rio(?-,PROG['find_lines']+' 1')
|
94
|
+
cmd2 = rio(?-,PROG['find_lines']+' 0')
|
92
95
|
|
93
96
|
cmdpipe = inp | cmd | cmd2
|
94
97
|
assert_equal('cmdpipe',cmdpipe.scheme)
|
@@ -108,8 +111,8 @@ class TC_cmdpipe < Test::RIO::TestCase
|
|
108
111
|
|
109
112
|
def test_file_cmdpipe_out
|
110
113
|
inp = rio('d/f2')
|
111
|
-
cmd = rio(?-,'
|
112
|
-
cmd2 = rio(?-,'
|
114
|
+
cmd = rio(?-,PROG['find_lines']+' 1')
|
115
|
+
cmd2 = rio(?-,PROG['find_lines']+' 0')
|
113
116
|
out = rio(?")
|
114
117
|
|
115
118
|
cmdpipe = cmd | cmd2
|
@@ -122,8 +125,8 @@ class TC_cmdpipe < Test::RIO::TestCase
|
|
122
125
|
end
|
123
126
|
|
124
127
|
def test_cmdpipe_without
|
125
|
-
cmd = rio(?-,'
|
126
|
-
cmd2 = rio(?-,'
|
128
|
+
cmd = rio(?-,PROG['find_lines']+' 1')
|
129
|
+
cmd2 = rio(?-,PROG['find_lines']+' 0')
|
127
130
|
out = rio(?")
|
128
131
|
|
129
132
|
cmdpipe = rio(?|,cmd,cmd2,out)
|
@@ -0,0 +1,89 @@
|
|
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_from_http < Test::RIO::TestCase
|
11
|
+
@@once = false
|
12
|
+
def self.once
|
13
|
+
@@once = true
|
14
|
+
|
15
|
+
rio('d0').rmtree.mkpath
|
16
|
+
rio('d1').rmtree.mkpath
|
17
|
+
rio('d0/d2').rmtree.mkpath
|
18
|
+
make_lines_file(1,'d0/f0')
|
19
|
+
make_lines_file(2,'d0/f1')
|
20
|
+
make_lines_file(3,'d1/f2')
|
21
|
+
make_lines_file(4,'d1/f3')
|
22
|
+
make_lines_file(5,'d0/d2/f4')
|
23
|
+
make_lines_file(6,'d0/d2/f5')
|
24
|
+
end
|
25
|
+
def setup
|
26
|
+
super
|
27
|
+
self.class.once unless @@once
|
28
|
+
|
29
|
+
@d0 = rio('d0')
|
30
|
+
@d2 = rio('d0/d2')
|
31
|
+
end
|
32
|
+
def cptest(src)
|
33
|
+
dst = rio('dst').delete!.mkpath
|
34
|
+
dst < src.clone
|
35
|
+
assert_rios_equal(src.clone,rio(dst,src.filename),"rio copy")
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_uri_rio_to_file
|
39
|
+
ario = rio('out').delete!.touch
|
40
|
+
url = 'http://localhost/riotest/hw.html'
|
41
|
+
urio = rio(url)
|
42
|
+
ario < urio
|
43
|
+
exp = urio.contents
|
44
|
+
assert_equal(exp,ario.contents)
|
45
|
+
end
|
46
|
+
def test_uri_rio_to_dir
|
47
|
+
ario = rio('ud').delete!.mkdir
|
48
|
+
url = 'http://localhost/riotest/hw.html'
|
49
|
+
urio = rio(url)
|
50
|
+
#$trace_states = true
|
51
|
+
ario < urio
|
52
|
+
$trace_states = false
|
53
|
+
drio = rio(ario,urio.filename)
|
54
|
+
assert(drio.file?)
|
55
|
+
assert(urio.contents,drio.contents)
|
56
|
+
end
|
57
|
+
def test_uri_string_to_dir
|
58
|
+
ario = rio('uds').delete!.mkdir
|
59
|
+
url = 'http://localhost/riotest/hw.html'
|
60
|
+
urio = rio(url)
|
61
|
+
#$trace_states = true
|
62
|
+
ario < url
|
63
|
+
$trace_states = false
|
64
|
+
drio = rio(ario,urio.filename)
|
65
|
+
assert(drio.file?)
|
66
|
+
assert(urio.contents,drio.contents)
|
67
|
+
end
|
68
|
+
def test_url_string_to_file
|
69
|
+
ario = rio('out').delete!.touch
|
70
|
+
url = 'http://localhost/riotest/hw.html'
|
71
|
+
ario < url
|
72
|
+
exp = url
|
73
|
+
assert_equal(exp,ario.contents)
|
74
|
+
end
|
75
|
+
def test_url_array_to_file
|
76
|
+
ario = rio('out').delete!.touch
|
77
|
+
url = 'http://localhost/riotest/hw.html'
|
78
|
+
ario < [url]
|
79
|
+
exp = url
|
80
|
+
assert_equal(exp,ario.contents)
|
81
|
+
end
|
82
|
+
def test_url_string_to_nonex
|
83
|
+
ario = rio('outz').delete!
|
84
|
+
url = 'http://localhost/riotest/hw.html'
|
85
|
+
ario < url
|
86
|
+
exp = url
|
87
|
+
assert_equal(exp,ario.contents)
|
88
|
+
end
|
89
|
+
end
|
data/test/tc/copy-from.rb
CHANGED
@@ -7,7 +7,7 @@ end
|
|
7
7
|
require 'rio'
|
8
8
|
require 'tc/testcase'
|
9
9
|
|
10
|
-
class
|
10
|
+
class TC_copy_from < Test::RIO::TestCase
|
11
11
|
@@once = false
|
12
12
|
def self.once
|
13
13
|
@@once = true
|
@@ -121,57 +121,6 @@ class TC_copyfrom < Test::RIO::TestCase
|
|
121
121
|
ans = ario.readlines
|
122
122
|
assert_equal(exp,ans)
|
123
123
|
end
|
124
|
-
def test_uri_rio_to_file
|
125
|
-
ario = rio('out').delete!.touch
|
126
|
-
url = 'http://localhost/rio/hw.html'
|
127
|
-
urio = rio(url)
|
128
|
-
ario < urio
|
129
|
-
exp = urio.contents
|
130
|
-
assert_equal(exp,ario.contents)
|
131
|
-
end
|
132
|
-
def test_uri_rio_to_dir
|
133
|
-
ario = rio('ud').delete!.mkdir
|
134
|
-
url = 'http://localhost/rio/hw.html'
|
135
|
-
urio = rio(url)
|
136
|
-
#$trace_states = true
|
137
|
-
ario < urio
|
138
|
-
$trace_states = false
|
139
|
-
drio = rio(ario,urio.filename)
|
140
|
-
assert(drio.file?)
|
141
|
-
assert(urio.contents,drio.contents)
|
142
|
-
end
|
143
|
-
def test_uri_string_to_dir
|
144
|
-
ario = rio('uds').delete!.mkdir
|
145
|
-
url = 'http://localhost/rio/hw.html'
|
146
|
-
urio = rio(url)
|
147
|
-
#$trace_states = true
|
148
|
-
ario < url
|
149
|
-
$trace_states = false
|
150
|
-
drio = rio(ario,urio.filename)
|
151
|
-
assert(drio.file?)
|
152
|
-
assert(urio.contents,drio.contents)
|
153
|
-
end
|
154
|
-
def test_url_string_to_file
|
155
|
-
ario = rio('out').delete!.touch
|
156
|
-
url = 'http://localhost/rio/hw.html'
|
157
|
-
ario < url
|
158
|
-
exp = url
|
159
|
-
assert_equal(exp,ario.contents)
|
160
|
-
end
|
161
|
-
def test_url_array_to_file
|
162
|
-
ario = rio('out').delete!.touch
|
163
|
-
url = 'http://localhost/rio/hw.html'
|
164
|
-
ario < [url]
|
165
|
-
exp = url
|
166
|
-
assert_equal(exp,ario.contents)
|
167
|
-
end
|
168
|
-
def test_url_string_to_nonex
|
169
|
-
ario = rio('outz').delete!
|
170
|
-
url = 'http://localhost/rio/hw.html'
|
171
|
-
ario < url
|
172
|
-
exp = url
|
173
|
-
assert_equal(exp,ario.contents)
|
174
|
-
end
|
175
124
|
def test_simple_ary
|
176
125
|
dst = rio('dst').delete!.mkpath
|
177
126
|
dst < @d0[]
|
data/test/tc/copy.rb
CHANGED
@@ -27,7 +27,7 @@ class TC_RIO_copy < Test::Unit::TestCase
|
|
27
27
|
sline = rio(datadir,'src').readline
|
28
28
|
l1 = rio(datadir,'dst1').readline
|
29
29
|
l2 = rio(datadir,'dst2/src').readline
|
30
|
-
assert_equal(inline,sline,'a message in
|
30
|
+
assert_equal(inline,sline,'a message in an assertion')
|
31
31
|
assert_equal(inline,l1)
|
32
32
|
assert_equal(inline,l2)
|
33
33
|
|
@@ -37,25 +37,27 @@ class TC_RIO_copy < Test::Unit::TestCase
|
|
37
37
|
sd1.join('f1.txt').puts(txt).close
|
38
38
|
oline = rio(datadir,'dir1/sd1/f1.txt').readline
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
# dir2 = rio(datadir,'dir2').rmtree.mkpath
|
41
|
+
# sd1.copy_to(dir2)
|
42
|
+
# $trace_states = true
|
43
|
+
# nline = rio(datadir,'dir2/sd1/f1.txt').readline
|
44
|
+
# assert_equal(oline,nline)
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
# dir2 = rio(datadir,'dir2').rmtree.mkpath
|
47
|
+
# sd1 > dir2
|
48
|
+
# $trace_states = false
|
49
|
+
# nline = rio(datadir,'dir2/sd1/f1.txt').readline
|
50
|
+
# assert_equal(oline,nline)
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
# dir2 = rio(datadir,'dir2').rmtree.mkpath
|
53
|
+
# dir2 < rio(datadir,'dir1/sd1')
|
54
|
+
# nline = rio(datadir,'dir2/sd1/f1.txt').readline
|
55
|
+
# assert_equal(oline,nline)
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
# dir2 = rio(datadir,'dir2').rmtree.mkpath
|
58
|
+
# sd1 > dir2.to_s
|
59
|
+
# nline = rio(datadir,'dir2/sd1/f1.txt').readline
|
60
|
+
# assert_equal(oline,nline)
|
59
61
|
|
60
62
|
dir2 = rio(datadir,'dir2').rmtree.mkpath
|
61
63
|
dir2 < rio(datadir,'dir1/sd1').to_s
|
data/test/tc/csv2.rb
CHANGED
@@ -115,7 +115,8 @@ class TC_csv2 < Test::RIO::TestCase
|
|
115
115
|
rec_ary = @records[0]
|
116
116
|
rec_rio = rio('src1.csv').csv.getrec
|
117
117
|
assert_kind_of(::Array,rec_rio)
|
118
|
-
|
118
|
+
exp = $EXTEND_CSV_RESULTS ? @strings[0] : @records[0].to_s
|
119
|
+
assert_equal(exp,rec_rio.to_s)
|
119
120
|
|
120
121
|
rec_rio = rio('src1.csv').csv.lines.getrec
|
121
122
|
assert_kind_of(::Array,rec_rio)
|
@@ -123,11 +124,13 @@ class TC_csv2 < Test::RIO::TestCase
|
|
123
124
|
|
124
125
|
ary = rio('src1.csv').csv[]
|
125
126
|
assert_kind_of(::Array,ary[0])
|
126
|
-
|
127
|
+
exp = $EXTEND_CSV_RESULTS ? @strings[0] : @records[0].to_s
|
128
|
+
assert_equal(exp,ary[0].to_s)
|
127
129
|
|
128
130
|
recs = rio('src1.csv').csv.lines[]
|
129
131
|
assert_kind_of(::String,recs[0])
|
130
|
-
|
132
|
+
exp = $EXTEND_CSV_RESULTS ? @records[0] : [@strings[0]+$/]
|
133
|
+
assert_equal(exp,recs[0].to_a)
|
131
134
|
return
|
132
135
|
end
|
133
136
|
|
data/test/tc/empty.rb
ADDED
@@ -0,0 +1,47 @@
|
|
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_empty < Test::RIO::TestCase
|
11
|
+
@@once = false
|
12
|
+
def self.once
|
13
|
+
@@once = true
|
14
|
+
|
15
|
+
rio('d0').rmtree.mkpath
|
16
|
+
rio('d1').rmtree.mkpath.chdir {
|
17
|
+
rio('file').touch
|
18
|
+
}
|
19
|
+
rio('f0').delete!.touch
|
20
|
+
rio('f1').puts!("a nonempty file\n")
|
21
|
+
end
|
22
|
+
def setup
|
23
|
+
super
|
24
|
+
self.class.once unless @@once
|
25
|
+
end
|
26
|
+
def test_file_empty
|
27
|
+
assert(rio('d0').empty?)
|
28
|
+
end
|
29
|
+
def test_file_not_empty
|
30
|
+
assert!(rio('d1').empty?)
|
31
|
+
end
|
32
|
+
def test_dir_empty
|
33
|
+
assert(rio('f0').empty?)
|
34
|
+
end
|
35
|
+
def test_dir_not_empty
|
36
|
+
assert!(rio('f1').empty?)
|
37
|
+
end
|
38
|
+
def test_ps_empty
|
39
|
+
assert(rio(?-,'ls d0').empty?)
|
40
|
+
end
|
41
|
+
def test_ps_not_empty
|
42
|
+
assert!(rio(?-,'ls d1').empty?)
|
43
|
+
end
|
44
|
+
def test_dev_null_empty
|
45
|
+
assert(rio(nil).empty?)
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,129 @@
|
|
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_emptyriodir < Test::RIO::TestCase
|
11
|
+
include RIO_TestCase
|
12
|
+
@@once = false
|
13
|
+
def self.once
|
14
|
+
@@once = true
|
15
|
+
rio('adir').mkdir.chdir {
|
16
|
+
rio('a.rb').touch
|
17
|
+
rio('b.rb').touch
|
18
|
+
rio('c.txt').touch
|
19
|
+
}
|
20
|
+
rio('d.rb').touch
|
21
|
+
rio('e.txt').touch
|
22
|
+
rio('f.d').mkdir
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup
|
26
|
+
super
|
27
|
+
self.class.once unless @@once
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_ss
|
31
|
+
|
32
|
+
dotans = rio('.')[]
|
33
|
+
empans = rio[]
|
34
|
+
assert_array_equal(dotans,empans)
|
35
|
+
|
36
|
+
dotans = rio('.')['*.rb']
|
37
|
+
empans = rio['*.rb']
|
38
|
+
assert_array_equal(dotans,empans)
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_each
|
43
|
+
|
44
|
+
dotans = []
|
45
|
+
empans = []
|
46
|
+
rio('.').each{ |el| dotans << el }
|
47
|
+
rio.each{ |el| empans << el }
|
48
|
+
assert_array_equal(dotans,empans)
|
49
|
+
|
50
|
+
dotans = []
|
51
|
+
empans = []
|
52
|
+
rio('.').entries('*.rb') { |el| dotans << el }
|
53
|
+
rio.entries('*.rb') { |el| empans << el }
|
54
|
+
assert_array_equal(dotans,empans)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_read
|
58
|
+
dotans = []
|
59
|
+
empans = []
|
60
|
+
dotrio = rio('.')
|
61
|
+
emprio = rio
|
62
|
+
while s = dotrio.read do dotans << s end
|
63
|
+
while s = emprio.read do empans << s end
|
64
|
+
assert_array_equal(dotans,empans)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_get
|
68
|
+
dotans = []
|
69
|
+
empans = []
|
70
|
+
dotrio = rio('.')
|
71
|
+
emprio = rio
|
72
|
+
while s = dotrio.get do dotans << s end
|
73
|
+
while s = emprio.get do empans << s end
|
74
|
+
assert_array_equal(dotans,empans)
|
75
|
+
|
76
|
+
dotans = []
|
77
|
+
empans = []
|
78
|
+
dotrio = rio('.').entries('*.d')
|
79
|
+
emprio = rio.entries('*.d')
|
80
|
+
while s = dotrio.get do dotans << s end
|
81
|
+
while s = emprio.get do empans << s end
|
82
|
+
assert_array_equal(dotans,empans)
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_skip
|
87
|
+
|
88
|
+
dotans = rio('.').skip[]
|
89
|
+
empans = rio.skip[]
|
90
|
+
assert_array_equal(dotans,empans)
|
91
|
+
|
92
|
+
dotans = rio('.').skip['*.rb']
|
93
|
+
empans = rio.skip['*.rb']
|
94
|
+
assert_array_equal(dotans,empans)
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_dirs
|
99
|
+
|
100
|
+
dotans = rio('.').dirs[]
|
101
|
+
empans = rio.dirs[]
|
102
|
+
assert_array_equal(dotans,empans)
|
103
|
+
|
104
|
+
dotans = rio('.').dirs['*.d']
|
105
|
+
empans = rio.dirs['*.d']
|
106
|
+
assert_array_equal(dotans,empans)
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
def test_getwd
|
112
|
+
dotans = rio('.').getwd
|
113
|
+
empans = rio.getwd
|
114
|
+
assert_array_equal(dotans,empans)
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_rmdir
|
118
|
+
rio('empty.d').delete!.mkdir.chdir {
|
119
|
+
assert_raise(RIO::Exception::CantHandle) { rio.rmdir }
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_rmtree
|
124
|
+
rio('empty.d').delete!.mkdir.chdir {
|
125
|
+
assert_raise(RIO::Exception::CantHandle) { rio.rmtree }
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|