rio 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README +18 -12
- data/Rakefile +57 -87
- data/build_doc.rb +19 -17
- data/doc/ANNOUNCE +3 -32
- data/doc/RELEASE_NOTES +4 -5
- data/doc/RIOIS +215 -0
- data/doc/generators/template/html/rio.css +428 -0
- data/doc/generators/template/html/rio.rb +18 -389
- data/doc/generators/template/html/ugly.rb +130 -0
- data/doc/pkg_def.rb +66 -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.rb +16 -10
- data/lib/rio/abstract_method.rb +3 -4
- data/lib/rio/argv.rb +3 -4
- data/lib/rio/arycopy.rb +3 -4
- data/lib/rio/assert.rb +3 -4
- data/lib/rio/base.rb +3 -4
- data/lib/rio/callstr.rb +3 -4
- data/lib/rio/const.rb +3 -4
- data/lib/rio/construct.rb +3 -4
- data/lib/rio/constructor.rb +12 -8
- data/lib/rio/context.rb +15 -30
- data/lib/rio/context/autoclose.rb +3 -4
- data/lib/rio/context/copying.rb +3 -4
- data/lib/rio/context/cxx.rb +3 -4
- data/lib/rio/context/dir.rb +3 -4
- data/lib/rio/context/gzip.rb +3 -4
- data/lib/rio/context/methods.rb +16 -5
- data/lib/rio/context/skip.rb +3 -4
- data/lib/rio/context/stream.rb +42 -5
- data/lib/rio/cp.rb +7 -7
- data/lib/rio/def.rb +3 -4
- data/lib/rio/dir.rb +3 -4
- data/lib/rio/doc.rb +4 -5
- data/lib/rio/doc/EXAMPLES.rb +299 -0
- data/lib/rio/doc/HOWTO.rb +3 -4
- data/lib/rio/doc/INTRO.rb +86 -105
- data/lib/rio/doc/OPTIONAL.rb +4 -5
- data/lib/rio/doc/SYNOPSIS.rb +7 -6
- data/lib/rio/entrysel.rb +21 -23
- data/lib/rio/exception.rb +3 -4
- data/lib/rio/exception/copy.rb +3 -4
- data/lib/rio/exception/notimplemented.rb +57 -0
- data/lib/rio/exception/notsupported.rb +3 -4
- data/lib/rio/exception/open.rb +3 -4
- data/lib/rio/exception/state.rb +3 -4
- data/lib/rio/ext.rb +47 -13
- data/lib/rio/ext/csv.rb +4 -5
- 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.rb +9 -5
- data/lib/rio/ext/yaml/doc.rb +133 -0
- data/lib/rio/ext/yaml/tie.rb +149 -0
- data/lib/rio/ext/zipfile.rb +23 -4
- 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/factory.rb +235 -27
- data/lib/rio/file.rb +4 -4
- data/lib/rio/filter.rb +3 -4
- data/lib/rio/filter/closeoneof.rb +3 -4
- data/lib/rio/filter/gzip.rb +9 -4
- data/lib/rio/fs/base.rb +3 -4
- data/lib/rio/fs/impl.rb +4 -5
- data/lib/rio/fs/native.rb +3 -4
- data/lib/rio/fs/stream.rb +3 -4
- data/lib/rio/fs/url.rb +3 -4
- data/lib/rio/ftp/conncache.rb +19 -5
- data/lib/rio/ftp/dir.rb +3 -4
- data/lib/rio/ftp/fs.rb +30 -24
- data/lib/rio/grande.rb +27 -7
- data/lib/rio/handle.rb +3 -4
- data/lib/rio/if.rb +19 -15
- data/lib/rio/if/basic.rb +7 -7
- data/lib/rio/if/csv.rb +5 -6
- data/lib/rio/if/dir.rb +120 -114
- data/lib/rio/if/file.rb +52 -44
- data/lib/rio/if/fileordir.rb +217 -211
- data/lib/rio/if/grande.rb +674 -644
- data/lib/rio/if/grande_entry.rb +321 -313
- data/lib/rio/if/grande_stream.rb +653 -553
- data/lib/rio/if/internal.rb +3 -4
- data/lib/rio/if/path.rb +425 -426
- data/lib/rio/if/rubyio.rb +681 -0
- data/lib/rio/if/string.rb +42 -5
- data/lib/rio/if/temp.rb +3 -4
- data/lib/rio/if/test.rb +245 -238
- data/lib/rio/if/yaml.rb +15 -41
- data/lib/rio/ioh.rb +7 -5
- data/lib/rio/iomode.rb +19 -7
- data/lib/rio/ios/fail.rb +4 -5
- data/lib/rio/ios/generic.rb +4 -5
- data/lib/rio/ios/mode.rb +4 -5
- data/lib/rio/ios/null.rb +6 -7
- data/lib/rio/iowrap.rb +3 -4
- data/lib/rio/kernel.rb +3 -5
- data/lib/rio/local.rb +3 -4
- data/lib/rio/match.rb +3 -4
- data/lib/rio/matchrecord.rb +3 -4
- data/lib/rio/no_warn.rb +3 -4
- data/lib/rio/nullio.rb +3 -4
- data/lib/rio/open3.rb +4 -5
- data/lib/rio/ops/construct.rb +3 -4
- data/lib/rio/ops/create.rb +11 -6
- data/lib/rio/ops/dir.rb +19 -8
- data/lib/rio/ops/either.rb +6 -5
- data/lib/rio/ops/file.rb +3 -4
- data/lib/rio/ops/path.rb +14 -35
- data/lib/rio/ops/stream.rb +3 -4
- data/lib/rio/ops/stream/input.rb +4 -7
- data/lib/rio/ops/stream/output.rb +3 -4
- data/lib/rio/ops/stream/read.rb +6 -5
- data/lib/rio/ops/stream/write.rb +3 -4
- data/lib/rio/ops/symlink.rb +3 -4
- data/lib/rio/path.rb +22 -18
- data/lib/rio/path/reset.rb +4 -5
- data/lib/rio/piper.rb +3 -4
- data/lib/rio/piper/cp.rb +3 -4
- data/lib/rio/prompt.rb +10 -5
- data/lib/rio/rectype.rb +5 -5
- data/lib/rio/rl/base.rb +17 -71
- data/lib/rio/rl/builder.rb +14 -38
- data/lib/rio/rl/chmap.rb +66 -0
- data/lib/rio/rl/fs2url.rb +82 -0
- data/lib/rio/rl/ioi.rb +4 -4
- data/lib/rio/rl/path.rb +44 -122
- data/lib/rio/rl/pathmethods.rb +19 -8
- data/lib/rio/rl/uri.rb +137 -60
- data/lib/rio/rl/withpath.rb +295 -0
- data/lib/rio/scheme/aryio.rb +3 -4
- data/lib/rio/scheme/cmdio.rb +3 -4
- data/lib/rio/scheme/cmdpipe.rb +4 -4
- data/lib/rio/scheme/fd.rb +3 -4
- data/lib/rio/scheme/ftp.rb +7 -7
- data/lib/rio/scheme/http.rb +4 -5
- data/lib/rio/scheme/null.rb +3 -4
- data/lib/rio/scheme/path.rb +3 -4
- data/lib/rio/scheme/stderr.rb +3 -4
- data/lib/rio/scheme/stdio.rb +3 -4
- data/lib/rio/scheme/strio.rb +3 -4
- data/lib/rio/scheme/sysio.rb +3 -4
- data/lib/rio/scheme/tcp.rb +3 -4
- data/lib/rio/scheme/temp.rb +6 -6
- data/lib/rio/state.rb +18 -46
- data/lib/rio/state/error.rb +3 -4
- data/lib/rio/stream.rb +4 -4
- data/lib/rio/stream/base.rb +3 -4
- data/lib/rio/stream/duplex.rb +3 -4
- data/lib/rio/stream/open.rb +3 -8
- data/lib/rio/symantics.rb +3 -4
- data/lib/rio/tempdir.rb +2 -2
- data/lib/rio/to_rio.rb +3 -4
- data/lib/rio/to_rio/all.rb +3 -4
- data/lib/rio/to_rio/array.rb +4 -5
- data/lib/rio/to_rio/io.rb +4 -5
- data/lib/rio/to_rio/object.rb +4 -5
- data/lib/rio/to_rio/string.rb +4 -5
- data/lib/rio/uri/file.rb +41 -5
- data/lib/rio/util.rb +3 -4
- data/lib/rio/version.rb +4 -5
- data/setup.rb +368 -339
- data/test/bin/list_dir.rb +1 -1
- data/test/ftp/anon_misc.rb +13 -1
- data/test/ftp/anon_special.rb +6 -6
- data/test/ftp/anon_write.rb +10 -3
- data/test/ftp/ftp2ftp.rb +2 -2
- data/test/ftp/testdef.rb +9 -6
- data/test/http/all.rb +3 -0
- data/test/http/copy-from-http.rb +140 -0
- data/test/lib/temp_server.rb +44 -0
- data/test/runalltests.rb +3 -1
- data/test/runhttp.rb +12 -0
- data/test/runhttptests.rb +1 -1
- data/test/runtests.rb +41 -3
- data/test/tc/abs.rb +9 -5
- data/test/tc/all.rb +9 -4
- data/test/tc/base.rb +1 -1
- data/test/tc/base2.rb +87 -0
- data/test/tc/{methods.rb → clone.rb} +72 -50
- data/test/tc/closeoncopy.rb +13 -2
- data/test/tc/copy-dir-samevar.rb +91 -0
- data/test/tc/dir_iter.rb +0 -1
- data/test/tc/empty.rb +6 -2
- data/test/tc/expand_path.rb +36 -54
- data/test/tc/ext.rb +42 -18
- data/test/tc/gzip.rb +30 -3
- data/test/tc/likeio.rb +5 -1
- data/test/tc/line_record_row.rb +51 -0
- data/test/tc/noqae.rb +71 -70
- data/test/tc/path_parts.rb +175 -0
- data/test/tc/programs_util.rb +3 -3
- data/test/tc/rename.rb +4 -5
- data/test/tc/riorl.rb +9 -7
- data/test/tc/skip.rb +35 -6
- data/test/tc/skiplines.rb +34 -5
- data/test/tc/split.rb +8 -50
- data/test/tc/splitlines.rb +65 -0
- data/test/tc/splitpath.rb +83 -0
- data/test/tc/testcase.rb +1 -1
- data/test/tc/truncate.rb +39 -0
- data/test/tc/yaml.rb +9 -8
- metadata +261 -207
- data/ChangeLog +0 -1418
- data/VERSION +0 -1
- data/lib/rio/doc/MISC.rb +0 -259
- data/lib/rio/if/stream.rb +0 -680
- data/lib/rio/impl/path.rb +0 -87
- data/test/tc/copy-from-http.rb +0 -89
data/test/bin/list_dir.rb
CHANGED
data/test/ftp/anon_misc.rb
CHANGED
@@ -13,13 +13,21 @@ class TC_ftp_anon_misc < Test::RIO::TestCase
|
|
13
13
|
@@once = false
|
14
14
|
include Test::RIO::FTP::Const
|
15
15
|
|
16
|
+
ALLENTS = [FTP_RWROOT/'f0',d0=FTP_RWROOT/'d0',d0/'f1',d1=d0/'d1',d1/'f2']
|
16
17
|
def self.once
|
17
18
|
@@once = true
|
18
19
|
end
|
19
20
|
def setup
|
20
21
|
super
|
21
22
|
self.class.once unless @@once
|
22
|
-
|
23
|
+
ALLENTS.reverse.each do |ent|
|
24
|
+
if ent.filename =~ /f/
|
25
|
+
ent.rm
|
26
|
+
else
|
27
|
+
ent.rmdir
|
28
|
+
end
|
29
|
+
end
|
30
|
+
#FS_RWROOT.entries { |ent| ent.delete! }
|
23
31
|
end
|
24
32
|
|
25
33
|
def test_dir
|
@@ -33,6 +41,8 @@ class TC_ftp_anon_misc < Test::RIO::TestCase
|
|
33
41
|
end
|
34
42
|
def test_mkdir
|
35
43
|
rwdir = rio(FTP_RWROOT)
|
44
|
+
rio(rwdir,'dir1').rmdir
|
45
|
+
rio(rwdir,'dir0').rmdir
|
36
46
|
rwdir.chdir
|
37
47
|
assert_equal(FTP_RWROOT.to_s,rwdir.cwd.to_s)
|
38
48
|
rio(rwdir,'dir0').mkdir
|
@@ -40,6 +50,8 @@ class TC_ftp_anon_misc < Test::RIO::TestCase
|
|
40
50
|
end
|
41
51
|
def test_rmdir
|
42
52
|
rwdir = rio(FTP_RWROOT)
|
53
|
+
rio(rwdir,'dir1').rmdir
|
54
|
+
rio(rwdir,'dir0').rmdir
|
43
55
|
rio(rwdir,'dir1').mkdir
|
44
56
|
assert_equal(smap([FTP_RWROOT/'dir1']),smap(FTP_RWROOT.entries[/^dir/]))
|
45
57
|
rio(rwdir,'dir1').rmdir
|
data/test/ftp/anon_special.rb
CHANGED
@@ -22,7 +22,7 @@ class TC_ftp_anon_special < Test::RIO::TestCase
|
|
22
22
|
FS_RWROOT.entries { |ent| ent.delete! }
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def atest_mkpath
|
26
26
|
rwdir = rio(FTP_RWROOT)
|
27
27
|
tpath = rwdir/'d0'/'d1'/'d2'
|
28
28
|
tpath.mkpath
|
@@ -37,12 +37,12 @@ class TC_ftp_anon_special < Test::RIO::TestCase
|
|
37
37
|
rwdir/'d0'/'d1'/'f1' < "a file"
|
38
38
|
d0 = rio(rwdir,'d0').rmtree
|
39
39
|
assert!(d0.exist?)
|
40
|
-
tpath.mkpath
|
41
|
-
assert(tpath.dir?)
|
42
|
-
d0 = rio(rwdir,'d0').rmtree
|
43
|
-
assert!(d0.exist?)
|
40
|
+
# tpath.mkpath
|
41
|
+
# assert(tpath.dir?)
|
42
|
+
# d0 = rio(rwdir,'d0').rmtree
|
43
|
+
# assert!(d0.exist?)
|
44
44
|
end
|
45
|
-
def
|
45
|
+
def atest_sel
|
46
46
|
rwdir = rio(FTP_RWROOT)
|
47
47
|
d0 = rwdir/'d0'
|
48
48
|
d1 = d0/'d1'
|
data/test/ftp/anon_write.rb
CHANGED
@@ -27,7 +27,14 @@ class TC_ftp_anon_write < Test::RIO::TestCase
|
|
27
27
|
def setup
|
28
28
|
super
|
29
29
|
self.class.once unless @@once
|
30
|
-
|
30
|
+
ALLENTS.reverse.each do |ent|
|
31
|
+
if ent.filename =~ /f/
|
32
|
+
ent.rm
|
33
|
+
else
|
34
|
+
ent.rmdir
|
35
|
+
end
|
36
|
+
end
|
37
|
+
#FS_RWROOT.entries { |ent| ent.delete! }
|
31
38
|
end
|
32
39
|
def test_cp_file_to_dir
|
33
40
|
fname = 'f0'
|
@@ -35,14 +42,14 @@ class TC_ftp_anon_write < Test::RIO::TestCase
|
|
35
42
|
rem = FTP_RWROOT.dup
|
36
43
|
rem < loc
|
37
44
|
frem = rem/fname
|
38
|
-
assert_equal(loc.
|
45
|
+
assert_equal(loc.chomp[],frem.chomp[])
|
39
46
|
end
|
40
47
|
def test_cp_file_to_file
|
41
48
|
fname = 'f0'
|
42
49
|
loc = SRCDIR/fname
|
43
50
|
rem = FTP_RWROOT.dup/fname
|
44
51
|
rem < loc
|
45
|
-
assert_equal(loc.
|
52
|
+
assert_equal(loc.chomp[],rem.chomp[])
|
46
53
|
end
|
47
54
|
def test_cp_dir_left
|
48
55
|
dname = 'd0'
|
data/test/ftp/ftp2ftp.rb
CHANGED
@@ -26,7 +26,7 @@ class TC_ftp2ftp < Test::RIO::TestCase
|
|
26
26
|
src = FTP_ROROOT/fname
|
27
27
|
dst = FTP_RWROOT/fname
|
28
28
|
dst < src
|
29
|
-
assert_equal(src.
|
29
|
+
assert_equal(src.chomp[],dst.chomp[])
|
30
30
|
end
|
31
31
|
def test_cp_ro2rw_file2
|
32
32
|
fname = 'f0'
|
@@ -34,7 +34,7 @@ class TC_ftp2ftp < Test::RIO::TestCase
|
|
34
34
|
dst = FTP_RWROOT
|
35
35
|
dst < src
|
36
36
|
fdst = dst/fname
|
37
|
-
assert_equal(src.
|
37
|
+
assert_equal(src.chomp[],fdst.chomp[])
|
38
38
|
end
|
39
39
|
def test_cp_ro2rw_dir
|
40
40
|
fname = 'd0'
|
data/test/ftp/testdef.rb
CHANGED
@@ -6,9 +6,11 @@ module Test
|
|
6
6
|
module Const
|
7
7
|
FTPUSER = 'ftp'
|
8
8
|
|
9
|
-
|
10
|
-
#
|
11
|
-
|
9
|
+
#DRV = $mswin32 ? 'x:' : ''
|
10
|
+
#FSROOT = rio("#{DRV}/srv/ftp")
|
11
|
+
FSROOT = rio("../../srv/ftp")
|
12
|
+
FTPHOST = '192.168.1.101'
|
13
|
+
#FTPHOST = 'localhost'
|
12
14
|
FTPROOT = rio("ftp://#{FTPHOST}/")
|
13
15
|
|
14
16
|
TESTDIR = rio('riotest')
|
@@ -19,9 +21,10 @@ module Test
|
|
19
21
|
FTP_ROROOT = FTPROOT/TESTDIR/RODIR
|
20
22
|
FS_RWROOT = FSROOT/TESTDIR/RWDIR
|
21
23
|
FS_ROROOT = FSROOT/TESTDIR/RODIR
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
unless $mswin32
|
25
|
+
PASSWDFILE = '/etc/passwd'
|
26
|
+
UID,GID = rio(PASSWDFILE).lines[/^#{FTPUSER}/][0].split(':')[2..3].map{|strid| strid.to_i}
|
27
|
+
end
|
25
28
|
end
|
26
29
|
include Const
|
27
30
|
def init_test_files
|
data/test/http/all.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
|
+
|
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
|
+
end
|
16
|
+
def setup
|
17
|
+
super
|
18
|
+
self.class.once unless @@once
|
19
|
+
end
|
20
|
+
RTHOST = ENV['RIO_TEST_HOST'] ||= 'localhost'
|
21
|
+
RTPORT = ENV['RIO_TEST_PORT'] || 80
|
22
|
+
RTHOSTPORT = "#{RTHOST}:#{RTPORT}"
|
23
|
+
RTDIR = 'riotest'
|
24
|
+
HWFILENAME = 'hw.html'
|
25
|
+
GZFILENAME = 'lines.txt.gz'
|
26
|
+
HWURL = "http://#{RTHOSTPORT}/#{RTDIR}/#{HWFILENAME}"
|
27
|
+
GZURL = "http://#{RTHOSTPORT}/#{RTDIR}/#{GZFILENAME}"
|
28
|
+
LOCALRTDIR = rio('../../srv/www/htdocs',RTDIR)
|
29
|
+
HWFILE = LOCALRTDIR/HWFILENAME
|
30
|
+
GZFILE = LOCALRTDIR/GZFILENAME
|
31
|
+
|
32
|
+
|
33
|
+
def cptest(src)
|
34
|
+
dst = rio('dst').delete!.mkpath
|
35
|
+
dst < src.clone
|
36
|
+
assert_rios_equal(src.clone,rio(dst,src.filename),"rio copy")
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_gunzip_uri_rio
|
40
|
+
ans = rio(GZURL).gzip.contents
|
41
|
+
exp = rio(GZFILE).gzip.contents
|
42
|
+
|
43
|
+
assert_equal(exp,ans)
|
44
|
+
end
|
45
|
+
def test_gunzip_copy_uri_rio
|
46
|
+
ario = rio('out.txt').delete! < rio(GZURL).gzip
|
47
|
+
ans = rio(ario).contents
|
48
|
+
exp = rio(GZFILE).gzip.contents
|
49
|
+
|
50
|
+
assert_equal(exp,ans)
|
51
|
+
end
|
52
|
+
def test_uri_rio_to_file
|
53
|
+
ario = rio('outf').delete!.touch
|
54
|
+
url = HWURL
|
55
|
+
urio = rio(url)
|
56
|
+
ario < urio
|
57
|
+
exp = urio.contents
|
58
|
+
assert_equal(exp,ario.contents)
|
59
|
+
assert_equal(rio(HWFILE).contents,rio('outf').contents)
|
60
|
+
end
|
61
|
+
def test_uri_rio_to_file2
|
62
|
+
ario = rio('outf2').delete!.touch
|
63
|
+
url = HWURL
|
64
|
+
urio = rio(url)
|
65
|
+
urio > ario
|
66
|
+
exp = urio.contents
|
67
|
+
assert_equal(exp,ario.contents)
|
68
|
+
assert_equal(rio(HWFILE).contents,rio('outf2').contents)
|
69
|
+
end
|
70
|
+
def test_uri_rio_to_filex
|
71
|
+
ario = rio('outx').delete!
|
72
|
+
url = HWURL
|
73
|
+
urio = rio(url)
|
74
|
+
ario < urio
|
75
|
+
exp = urio.contents
|
76
|
+
assert_equal(exp,ario.contents)
|
77
|
+
assert_equal(rio(HWFILE).contents,rio('outx').contents)
|
78
|
+
end
|
79
|
+
def test_uri_rio_to_filex2
|
80
|
+
ario = rio('outx2').delete!
|
81
|
+
url = HWURL
|
82
|
+
urio = rio(url)
|
83
|
+
urio > ario
|
84
|
+
exp = urio.contents
|
85
|
+
assert_equal(exp,ario.contents)
|
86
|
+
assert_equal(rio(HWFILE).contents,rio('outx2').contents)
|
87
|
+
end
|
88
|
+
def test_uri_rio_to_dir
|
89
|
+
ario = rio('ud').delete!.mkdir
|
90
|
+
url = HWURL
|
91
|
+
urio = rio(url)
|
92
|
+
ario < urio
|
93
|
+
drio = rio(ario,urio.filename)
|
94
|
+
assert(drio.file?)
|
95
|
+
assert_equal(urio.contents,drio.contents)
|
96
|
+
assert_equal(rio(HWFILE).contents,drio.contents)
|
97
|
+
end
|
98
|
+
def test_uri_rio_to_dir2
|
99
|
+
ario = rio('ud2').delete!.mkdir
|
100
|
+
url = HWURL
|
101
|
+
urio = rio(url)
|
102
|
+
urio > ario
|
103
|
+
drio = rio(ario,urio.filename)
|
104
|
+
assert(drio.file?)
|
105
|
+
assert_equal(urio.contents,drio.contents)
|
106
|
+
assert_equal(rio(HWFILE).contents,drio.contents)
|
107
|
+
end
|
108
|
+
def test_uri_string_to_dir
|
109
|
+
ario = rio('uds').delete!.mkdir
|
110
|
+
url = HWURL
|
111
|
+
urio = rio(url)
|
112
|
+
#$trace_states = true
|
113
|
+
ario < url
|
114
|
+
$trace_states = false
|
115
|
+
drio = rio(ario,urio.filename)
|
116
|
+
assert(drio.file?)
|
117
|
+
assert(urio.contents,drio.contents)
|
118
|
+
end
|
119
|
+
def test_url_string_to_file
|
120
|
+
ario = rio('out').delete!.touch
|
121
|
+
url = HWURL
|
122
|
+
ario < url
|
123
|
+
exp = url
|
124
|
+
assert_equal(exp,ario.contents)
|
125
|
+
end
|
126
|
+
def test_url_array_to_file
|
127
|
+
ario = rio('out').delete!.touch
|
128
|
+
url = HWURL
|
129
|
+
ario < [url]
|
130
|
+
exp = url
|
131
|
+
assert_equal(exp,ario.contents)
|
132
|
+
end
|
133
|
+
def test_url_string_to_nonex
|
134
|
+
ario = rio('outz').delete!
|
135
|
+
url = HWURL
|
136
|
+
ario < url
|
137
|
+
exp = url
|
138
|
+
assert_equal(exp,ario.contents)
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'webrick'
|
2
|
+
require 'rio'
|
3
|
+
|
4
|
+
|
5
|
+
class TempServer
|
6
|
+
def initialize(server_config = {})
|
7
|
+
@logdir = rio('log').delete!.mkdir
|
8
|
+
@config = { :DocumentRoot => rio('srv/www/htdocs').abs,
|
9
|
+
:Logger => WEBrick::Log.new(@logdir/'server.log'),
|
10
|
+
:AccessLog => [[ @logdir/'access.log', WEBrick::AccessLog::COMBINED_LOG_FORMAT ]],
|
11
|
+
:Port => ENV['RIO_TEST_PORT'] || '8088',
|
12
|
+
}
|
13
|
+
@config.merge!(server_config)
|
14
|
+
ENV['RIO_TEST_PORT'] = @config[:Port]
|
15
|
+
@server = create_server(@config)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_server(config = {})
|
19
|
+
server = WEBrick::HTTPServer.new(config)
|
20
|
+
yield server if block_given?
|
21
|
+
['INT', 'TERM'].each {|signal|
|
22
|
+
trap(signal) {server.shutdown}
|
23
|
+
}
|
24
|
+
server
|
25
|
+
end
|
26
|
+
def run_progs(progs)
|
27
|
+
progs.each do |prog|
|
28
|
+
system("ruby #{prog}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
def run(*programs)
|
32
|
+
Thread.new(@server) { |srv|
|
33
|
+
srv.start
|
34
|
+
}
|
35
|
+
Thread.new(programs) { |progs|
|
36
|
+
#Thread.pass
|
37
|
+
run_progs(progs)
|
38
|
+
}.join()
|
39
|
+
|
40
|
+
Thread.new(@server) { |srv|
|
41
|
+
srv.shutdown
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
data/test/runalltests.rb
CHANGED
@@ -9,7 +9,9 @@ require 'rio'
|
|
9
9
|
require 'test/unit'
|
10
10
|
|
11
11
|
require 'tc/all'
|
12
|
-
require 'ftp/all'
|
12
|
+
#require 'ftp/all'
|
13
13
|
$trace_states = false
|
14
14
|
require 'test/unit/ui/console/testrunner'
|
15
|
+
require 'lib/temp_server.rb'
|
16
|
+
TempServer.new.run('runhttptests.rb')
|
15
17
|
#require 'test/unit/ui/tk/testrunner'
|
data/test/runhttp.rb
ADDED
data/test/runhttptests.rb
CHANGED
data/test/runtests.rb
CHANGED
@@ -6,9 +6,47 @@ $:.unshift $devlib unless $:[0] == $devlib
|
|
6
6
|
$mswin32 = (RUBY_PLATFORM =~ /mswin32/)
|
7
7
|
|
8
8
|
require 'rio'
|
9
|
-
require 'test/unit'
|
10
9
|
|
11
|
-
require 'tc/all'
|
12
10
|
$trace_states = false
|
13
|
-
require '
|
11
|
+
require 'optparse'
|
12
|
+
|
13
|
+
options = {}
|
14
|
+
OptionParser.new do |opts|
|
15
|
+
opts.banner = "Usage: #{$0} [options]"
|
16
|
+
|
17
|
+
opts.on("-f", "--ftp", "Run FTP Tests") do |v|
|
18
|
+
options[:ftp] = v
|
19
|
+
end
|
20
|
+
opts.on("-h", "--http", "Run HTTP Tests") do |v|
|
21
|
+
options[:http] = v
|
22
|
+
end
|
23
|
+
opts.on("-s", "--std", "Run Standard Tests") do |v|
|
24
|
+
options[:std] = v
|
25
|
+
end
|
26
|
+
opts.on("-a", "--all", "Run All Tests") do |v|
|
27
|
+
options[:std] = v
|
28
|
+
options[:ftp] = v
|
29
|
+
options[:http] = v
|
30
|
+
end
|
31
|
+
end.parse!
|
32
|
+
|
33
|
+
options[:std] = true if options.empty?
|
34
|
+
|
35
|
+
options.keys.each do |opt|
|
36
|
+
case opt
|
37
|
+
when :std
|
38
|
+
require 'tc/all'
|
39
|
+
require 'test/unit/ui/console/testrunner'
|
40
|
+
when :http
|
41
|
+
require 'lib/temp_server.rb'
|
42
|
+
TempServer.new.run('runhttptests.rb')
|
43
|
+
when :ftp
|
44
|
+
require 'test/unit'
|
45
|
+
require 'ftp/all'
|
46
|
+
require 'test/unit/ui/console/testrunner'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
14
50
|
#require 'test/unit/ui/tk/testrunner'
|
51
|
+
#require 'test/unit/ui/fox/testrunner'
|
52
|
+
#Test::Unit::UI::Tk::TestRunner.run(TC_MyTest)
|
data/test/tc/abs.rb
CHANGED
@@ -18,7 +18,7 @@ class TC_RIO_abs < Test::Unit::TestCase
|
|
18
18
|
hduri = ::URI.parse(hdurl)
|
19
19
|
hd = rio(hduri)
|
20
20
|
assert_equal('/',hd.path)
|
21
|
-
|
21
|
+
assert_equal('/',hd.fspath)
|
22
22
|
assert_equal('http',hd.scheme)
|
23
23
|
assert_equal('localhost',hd.host)
|
24
24
|
assert_equal(true,hd.abs?)
|
@@ -28,7 +28,7 @@ class TC_RIO_abs < Test::Unit::TestCase
|
|
28
28
|
hdurl = 'http://localhost/'
|
29
29
|
hd = rio(hdurl)
|
30
30
|
assert_equal('/',hd.path)
|
31
|
-
|
31
|
+
assert_equal('/',hd.fspath)
|
32
32
|
assert_equal('http',hd.scheme)
|
33
33
|
assert_equal('localhost',hd.host)
|
34
34
|
assert_equal(true,hd.abs?)
|
@@ -39,7 +39,7 @@ class TC_RIO_abs < Test::Unit::TestCase
|
|
39
39
|
hduri = ::URI.parse(hdurl)
|
40
40
|
hd = rio(hduri)
|
41
41
|
assert_equal('/',hd.path)
|
42
|
-
|
42
|
+
assert_equal('/',hd.fspath)
|
43
43
|
assert_equal('http',hd.scheme)
|
44
44
|
assert_equal('localhost',hd.host)
|
45
45
|
assert_equal(true,hd.abs?)
|
@@ -49,7 +49,7 @@ class TC_RIO_abs < Test::Unit::TestCase
|
|
49
49
|
hdurl = 'http://localhost'
|
50
50
|
hd = rio(hdurl)
|
51
51
|
assert_equal('/',hd.path)
|
52
|
-
|
52
|
+
assert_equal('/',hd.fspath)
|
53
53
|
assert_equal('http',hd.scheme)
|
54
54
|
assert_equal('localhost',hd.host)
|
55
55
|
assert_equal(true,hd.abs?)
|
@@ -59,7 +59,7 @@ class TC_RIO_abs < Test::Unit::TestCase
|
|
59
59
|
hdurl = 'http://localhost/rio/hw.html'
|
60
60
|
hd = rio(hdurl)
|
61
61
|
assert_equal('/rio/hw.html',hd.path)
|
62
|
-
|
62
|
+
assert_equal('/rio/hw.html',hd.fspath)
|
63
63
|
assert_equal('http',hd.scheme)
|
64
64
|
assert_equal('localhost',hd.host)
|
65
65
|
assert_equal(true,hd.abs?)
|
@@ -276,6 +276,10 @@ class TC_RIO_abs < Test::Unit::TestCase
|
|
276
276
|
assert_kind_of(RIO::Rio,tmp)
|
277
277
|
assert_equal('/tmp',tmp.to_s)
|
278
278
|
|
279
|
+
z = tmp.join('zippy')
|
280
|
+
assert_kind_of(RIO::Rio,z)
|
281
|
+
assert_equal('/tmp/zippy',z.to_s)
|
282
|
+
|
279
283
|
z = tmp/'zippy'
|
280
284
|
assert_kind_of(RIO::Rio,z)
|
281
285
|
assert_equal('/tmp/zippy',z.to_s)
|