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/lib/rio/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -39,7 +39,7 @@
|
|
39
39
|
module RIO
|
40
40
|
# :stopdoc:
|
41
41
|
module Version #:nodoc: all
|
42
|
-
VERSION = '0.3.
|
42
|
+
VERSION = '0.3.8'
|
43
43
|
|
44
44
|
N = VERSION.split('.').freeze
|
45
45
|
MAJOR = N[0].freeze
|
data/lib/rio.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -34,37 +34,27 @@
|
|
34
34
|
# <b>Rio is pre-alpha software.
|
35
35
|
# The documented interface and behavior is subject to change without notice.</b>
|
36
36
|
|
37
|
-
#
|
38
|
-
|
39
37
|
|
40
38
|
require 'rio/version'
|
41
39
|
require 'rio/base'
|
40
|
+
require 'rio/def'
|
42
41
|
require 'rio/exception'
|
43
42
|
|
44
43
|
require 'forwardable'
|
44
|
+
|
45
45
|
$trace_states = false
|
46
|
-
module RIO
|
47
|
-
# See also: RIO::Doc::SYNOPSIS; RIO::Doc::INTRO; RIO::Doc::HOWTO.
|
48
|
-
class Rio < Base #:doc:
|
49
|
-
end
|
50
|
-
end
|
51
46
|
|
52
47
|
require 'rio/kernel'
|
53
48
|
require 'rio/constructor'
|
54
49
|
require 'rio/construct'
|
55
50
|
|
56
|
-
|
57
|
-
SEEK_SET = IO::SEEK_SET
|
58
|
-
SEEK_END = IO::SEEK_END
|
59
|
-
SEEK_CUR = IO::SEEK_CUR
|
60
|
-
end
|
51
|
+
require 'rio/const'
|
61
52
|
|
62
53
|
module RIO
|
63
54
|
class Rio #:doc:
|
64
55
|
require 'rio/local'
|
65
56
|
include Local
|
66
57
|
require 'rio/factory'
|
67
|
-
|
68
58
|
protected
|
69
59
|
|
70
60
|
attr_reader :state
|
@@ -116,16 +106,16 @@ module RIO
|
|
116
106
|
#p callstr('dup',self)
|
117
107
|
self.class.new(self.to_rl)
|
118
108
|
end
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
109
|
+
|
110
|
+
def method_missing(sym,*args,&block) #:nodoc:
|
111
|
+
#p callstr('method_missing',sym,*args)
|
112
|
+
|
113
|
+
result = target.__send__(sym,*args,&block)
|
114
|
+
return result unless result.kind_of? State::Base and result.equal? target
|
115
|
+
|
116
|
+
self
|
117
|
+
end
|
118
|
+
|
129
119
|
def inspect()
|
130
120
|
cl = self.class.to_s[5..-1]
|
131
121
|
st = state.target.class.to_s[5..-1]
|
@@ -152,6 +142,7 @@ module RIO
|
|
152
142
|
end # class Rio
|
153
143
|
end # module RIO
|
154
144
|
|
145
|
+
#require 'rio/ext/zipfile.rb'
|
155
146
|
|
156
147
|
if $0 == __FILE__
|
157
148
|
eval DATA.read, nil, $0, __LINE__+4
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
|
3
|
+
# reads from standard input and writes the number
|
4
|
+
# of lines to standard output
|
5
|
+
# used to test cmdpipe Rios
|
6
|
+
|
7
|
+
$:.unshift File.expand_path(File.dirname(__FILE__)+'/../../lib/')
|
8
|
+
|
9
|
+
require 'rio'
|
10
|
+
rio(?-).puts(rio(?-)[].size)
|
11
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
|
3
|
+
# reads from standard input and writes the number
|
4
|
+
# of lines to standard output
|
5
|
+
# used to test cmdpipe Rios
|
6
|
+
|
7
|
+
$:.unshift File.expand_path(File.dirname(__FILE__)+'/../../lib/')
|
8
|
+
require 'rio'
|
9
|
+
|
10
|
+
search_re = ARGV.shift
|
11
|
+
print rio(?-).lines[/#{search_re}/]
|
12
|
+
|
13
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
|
3
|
+
# reads from standard input and writes the number
|
4
|
+
# of lines to standard output
|
5
|
+
# used to test cmdpipe Rios
|
6
|
+
|
7
|
+
$:.unshift File.expand_path(File.dirname(__FILE__)+'/../../lib/')
|
8
|
+
require 'rio'
|
9
|
+
|
10
|
+
dir = ARGV.shift || '.'
|
11
|
+
rio(dir).chdir {
|
12
|
+
puts rio.to_a
|
13
|
+
}
|
14
|
+
|
data/test/ftp/all.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
if $0 == __FILE__
|
3
|
+
Dir.chdir File.dirname(__FILE__)+'/../'
|
4
|
+
$:.unshift File.expand_path('../lib/')
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rio'
|
8
|
+
require 'tc/testcase'
|
9
|
+
require 'open-uri'
|
10
|
+
require 'ftp/testdef'
|
11
|
+
|
12
|
+
class TC_ftp_anon_misc < Test::RIO::TestCase
|
13
|
+
@@once = false
|
14
|
+
include Test::RIO::FTP::Const
|
15
|
+
|
16
|
+
def self.once
|
17
|
+
@@once = true
|
18
|
+
end
|
19
|
+
def setup
|
20
|
+
super
|
21
|
+
self.class.once unless @@once
|
22
|
+
FS_RWROOT.entries { |ent| ent.delete! }
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_dir
|
26
|
+
ftproot = rio(FTPROOT)
|
27
|
+
ftproot.chdir
|
28
|
+
assert_equal('/',ftproot.getwd)
|
29
|
+
assert_equal(ftproot,ftproot.cwd)
|
30
|
+
|
31
|
+
rwdir = rio(FTP_RWROOT).chdir
|
32
|
+
assert_equal(FTP_RWROOT,rwdir.cwd)
|
33
|
+
end
|
34
|
+
def test_mkdir
|
35
|
+
rwdir = rio(FTP_RWROOT)
|
36
|
+
rwdir.chdir
|
37
|
+
assert_equal(FTP_RWROOT.to_s,rwdir.cwd.to_s)
|
38
|
+
rio(rwdir,'dir0').mkdir
|
39
|
+
assert_equal(smap([FTP_RWROOT/'dir0']),smap(FTP_RWROOT.entries[/^dir/]))
|
40
|
+
end
|
41
|
+
def test_rmdir
|
42
|
+
rwdir = rio(FTP_RWROOT)
|
43
|
+
rio(rwdir,'dir1').mkdir
|
44
|
+
assert_equal(smap([FTP_RWROOT/'dir1']),smap(FTP_RWROOT.entries[/^dir/]))
|
45
|
+
rio(rwdir,'dir1').rmdir
|
46
|
+
assert_equal(smap([]),smap(FTP_RWROOT.entries[/^dir/]))
|
47
|
+
end
|
48
|
+
def test_rm
|
49
|
+
rwdir = rio(FTP_RWROOT)
|
50
|
+
locfile = rio('locfile').touch
|
51
|
+
locfile > rwdir
|
52
|
+
remfile = rwdir/locfile
|
53
|
+
assert(remfile.file?)
|
54
|
+
remfile.delete
|
55
|
+
assert!(remfile.exist?)
|
56
|
+
end
|
57
|
+
def test_rename_file
|
58
|
+
rwdir = rio(FTP_RWROOT)
|
59
|
+
locfile = rio('locfile').touch
|
60
|
+
locfile > rwdir
|
61
|
+
remfile = rwdir/locfile
|
62
|
+
assert(remfile.file?)
|
63
|
+
remfile_new = rwdir/'remfile'
|
64
|
+
remfile.rename(remfile_new)
|
65
|
+
assert(remfile_new.file?)
|
66
|
+
assert!(remfile.exist?)
|
67
|
+
end
|
68
|
+
def test_rename_dir
|
69
|
+
rwdir = rio(FTP_RWROOT)
|
70
|
+
locdir = rio('locdir').mkdir
|
71
|
+
locdir > rwdir
|
72
|
+
remdir = rwdir/locdir
|
73
|
+
assert(remdir.dir?)
|
74
|
+
remdir_new = rwdir/'remdir'
|
75
|
+
remdir.rename(remdir_new)
|
76
|
+
assert(remdir_new.dir?)
|
77
|
+
assert!(remdir.exist?)
|
78
|
+
end
|
79
|
+
def test_test
|
80
|
+
file = FTP_ROROOT/'f0'
|
81
|
+
assert(file.file?)
|
82
|
+
assert(file.exist?)
|
83
|
+
assert!(file.dir?)
|
84
|
+
dir = FTP_ROROOT/'d0'
|
85
|
+
assert!(dir.file?)
|
86
|
+
assert(dir.exist?)
|
87
|
+
assert(dir.dir?)
|
88
|
+
nada = FTP_ROROOT/'nada'
|
89
|
+
assert!(nada.file?)
|
90
|
+
assert!(nada.exist?)
|
91
|
+
assert!(nada.dir?)
|
92
|
+
end
|
93
|
+
def test_size
|
94
|
+
file = FTP_ROROOT/'f0'
|
95
|
+
dir = FTP_ROROOT/'d0'
|
96
|
+
nada = FTP_ROROOT/'nada'
|
97
|
+
assert(file.size)
|
98
|
+
assert_raise(::Net::FTPPermError) { dir.size }
|
99
|
+
assert_raise(::Net::FTPPermError) { nada.size }
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_mtime
|
103
|
+
file = FTP_ROROOT/'f0'
|
104
|
+
dir = FTP_ROROOT/'d0'
|
105
|
+
nada = FTP_ROROOT/'nada'
|
106
|
+
assert(file.mtime)
|
107
|
+
assert_raise(::Net::FTPPermError) { dir.mtime }
|
108
|
+
assert_raise(::Net::FTPPermError) { nada.mtime }
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
if $0 == __FILE__
|
3
|
+
Dir.chdir File.dirname(__FILE__)+'/../'
|
4
|
+
$:.unshift File.expand_path('../lib/')
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rio'
|
8
|
+
require 'tc/testcase'
|
9
|
+
require 'open-uri'
|
10
|
+
require 'ftp/testdef'
|
11
|
+
|
12
|
+
class TC_ftp_anon_read < Test::RIO::TestCase
|
13
|
+
@@once = false
|
14
|
+
include Test::RIO::FTP::Const
|
15
|
+
FTPRO = FTPROOT/'riotest/ro'
|
16
|
+
LOCENTS = [rio('f0'),d0=rio('d0'),d0/'f1',d1=d0/'d1',d1/'f2']
|
17
|
+
ALLENTS = [FTP_ROROOT/'f0',d0=FTP_ROROOT/'d0',d0/'f1',d1=d0/'d1',d1/'f2']
|
18
|
+
|
19
|
+
def self.once
|
20
|
+
@@once = true
|
21
|
+
end
|
22
|
+
def setup
|
23
|
+
super
|
24
|
+
self.class.once unless @@once
|
25
|
+
end
|
26
|
+
def test_read_file
|
27
|
+
f0 = FTP_ROROOT/'f0'
|
28
|
+
exp = ""
|
29
|
+
open(f0.to_s) { |fh| exp = fh.gets(nil) }
|
30
|
+
ans = rio(f0).contents
|
31
|
+
assert_equal(exp,ans)
|
32
|
+
end
|
33
|
+
def test_read_dir
|
34
|
+
ro = FTP_ROROOT.dup
|
35
|
+
exp = [ro/'f0',ro/'d0']
|
36
|
+
ans = rio(ro).to_a
|
37
|
+
assert_array_equal(exp,ans)
|
38
|
+
end
|
39
|
+
def test_read_dir_all
|
40
|
+
ro = FTP_ROROOT.dup
|
41
|
+
exp = ALLENTS
|
42
|
+
ans = rio(ro).all[]
|
43
|
+
assert_array_equal(exp,ans)
|
44
|
+
end
|
45
|
+
def test_read_dir_all_selected_by_name
|
46
|
+
ro = FTP_ROROOT.dup
|
47
|
+
exp = ALLENTS.select{ |f| f =~ /1$/ }
|
48
|
+
ans = ro.all['*1']
|
49
|
+
assert_array_equal(exp,ans)
|
50
|
+
end
|
51
|
+
def test_read_dir_all_files
|
52
|
+
ro = FTP_ROROOT.dup
|
53
|
+
exp = ALLENTS.select{ |f| f.file? }
|
54
|
+
ans = ro.all.files
|
55
|
+
assert_array_equal(exp,ans)
|
56
|
+
end
|
57
|
+
def test_read_dir_all_dirs
|
58
|
+
exp = ALLENTS.select{ |f| f.dir? }
|
59
|
+
ans = FTP_ROROOT.dup.all.dirs
|
60
|
+
assert_array_equal(exp,ans)
|
61
|
+
end
|
62
|
+
def test_cpfrom_file
|
63
|
+
rem = FTP_ROROOT/'f0'
|
64
|
+
#$trace_states = true
|
65
|
+
loc = rio('f0').delete
|
66
|
+
#$trace_states = false
|
67
|
+
loc < rem
|
68
|
+
#$trace_states = true
|
69
|
+
assert_equal(loc.contents,rem.contents)
|
70
|
+
#$trace_states = false
|
71
|
+
loc = rio('f0').delete
|
72
|
+
rem > loc
|
73
|
+
assert_equal(loc.contents,rem.contents)
|
74
|
+
end
|
75
|
+
def test_cpfrom_dir
|
76
|
+
rem = FTP_ROROOT/'d0'
|
77
|
+
|
78
|
+
loc = rio('d0').delete!
|
79
|
+
loc < rem
|
80
|
+
exp = LOCENTS.select{ |f| f =~ /d0/ } - [loc]
|
81
|
+
ans = loc.dup.all[]
|
82
|
+
assert_array_equal(exp,ans)
|
83
|
+
|
84
|
+
loc = rio('d0').delete!
|
85
|
+
rem > loc
|
86
|
+
exp = LOCENTS.select{ |f| f =~ /d0/ } - [loc]
|
87
|
+
ans = loc.dup.all[]
|
88
|
+
assert_array_equal(exp,ans)
|
89
|
+
end
|
90
|
+
def test_cpfrom_dir_select
|
91
|
+
rem = FTP_ROROOT/'d0'
|
92
|
+
|
93
|
+
loc = rio('d0').delete!
|
94
|
+
loc < rem.entries('*1')
|
95
|
+
exp = LOCENTS.select{ |f| f =~ /1$/ }
|
96
|
+
ans = loc.dup.all[]
|
97
|
+
assert_array_equal(exp,ans)
|
98
|
+
|
99
|
+
loc = rio('d0').delete!
|
100
|
+
rem.entries('*1') > loc
|
101
|
+
exp = LOCENTS.select{ |f| f =~ /1$/ }
|
102
|
+
ans = loc.dup.all[]
|
103
|
+
assert_array_equal(exp,ans)
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
if $0 == __FILE__
|
3
|
+
Dir.chdir File.dirname(__FILE__)+'/../'
|
4
|
+
$:.unshift File.expand_path('../lib/')
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rio'
|
8
|
+
require 'tc/testcase'
|
9
|
+
require 'open-uri'
|
10
|
+
require 'ftp/testdef'
|
11
|
+
|
12
|
+
class TC_ftp_anon_special < Test::RIO::TestCase
|
13
|
+
@@once = false
|
14
|
+
include Test::RIO::FTP::Const
|
15
|
+
|
16
|
+
def self.once
|
17
|
+
@@once = true
|
18
|
+
end
|
19
|
+
def setup
|
20
|
+
super
|
21
|
+
self.class.once unless @@once
|
22
|
+
FS_RWROOT.entries { |ent| ent.delete! }
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_mkpath
|
26
|
+
rwdir = rio(FTP_RWROOT)
|
27
|
+
tpath = rwdir/'d0'/'d1'/'d2'
|
28
|
+
tpath.mkpath
|
29
|
+
assert(tpath.dir?)
|
30
|
+
end
|
31
|
+
def test_rmtree
|
32
|
+
rwdir = rio(FTP_RWROOT)
|
33
|
+
tpath = rwdir/'d0'/'d1'/'d2'
|
34
|
+
tpath.mkpath
|
35
|
+
assert(tpath.dir?)
|
36
|
+
rwdir/'d0'/'f0' < "a file"
|
37
|
+
rwdir/'d0'/'d1'/'f1' < "a file"
|
38
|
+
d0 = rio(rwdir,'d0').rmtree
|
39
|
+
assert!(d0.exist?)
|
40
|
+
tpath.mkpath
|
41
|
+
assert(tpath.dir?)
|
42
|
+
d0 = rio(rwdir,'d0').rmtree
|
43
|
+
assert!(d0.exist?)
|
44
|
+
end
|
45
|
+
def test_sel
|
46
|
+
rwdir = rio(FTP_RWROOT)
|
47
|
+
d0 = rwdir/'d0'
|
48
|
+
d1 = d0/'d1'
|
49
|
+
d2 = d1/'d2'
|
50
|
+
d2.mkpath
|
51
|
+
assert(d2.dir?)
|
52
|
+
f0 = rwdir/'d0'/'f0' < "a file"
|
53
|
+
f1 = rwdir/'d0'/'d1'/'f1' < "a file"
|
54
|
+
|
55
|
+
ans = rwdir.all['*0']
|
56
|
+
exp = [d0,f0]
|
57
|
+
assert_equal(smap(exp),smap(ans))
|
58
|
+
|
59
|
+
ans = rwdir.files[]
|
60
|
+
exp = [f1,f0]
|
61
|
+
assert_equal(smap(exp),smap(ans))
|
62
|
+
|
63
|
+
ans = rwdir.dirs[]
|
64
|
+
exp = [d0,d1,d2]
|
65
|
+
assert_equal(smap(exp),smap(ans))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
if $0 == __FILE__
|
3
|
+
Dir.chdir File.dirname(__FILE__)+'/../'
|
4
|
+
$:.unshift File.expand_path('../lib/')
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rio'
|
8
|
+
require 'tc/testcase'
|
9
|
+
require 'open-uri'
|
10
|
+
require 'ftp/testdef'
|
11
|
+
|
12
|
+
class TC_ftp_anon_write < Test::RIO::TestCase
|
13
|
+
@@once = false
|
14
|
+
include Test::RIO::FTP::Const
|
15
|
+
#FTPROOT = rio('ftp://localhost/')
|
16
|
+
#FTPRW = FTPROOT/'riotest/rw'
|
17
|
+
|
18
|
+
SRCDIR = rio('src')
|
19
|
+
DSTDIR = rio('dst')
|
20
|
+
LOCENTS = [rio('f0'),d0=rio('d0'),d0/'f1',d1=d0/'d1',d1/'f2']
|
21
|
+
ALLENTS = [FTP_RWROOT/'f0',d0=FTP_RWROOT/'d0',d0/'f1',d1=d0/'d1',d1/'f2']
|
22
|
+
def self.once
|
23
|
+
@@once = true
|
24
|
+
dir = rio(SRCDIR).delete!
|
25
|
+
dir < rio(FS_ROROOT)
|
26
|
+
end
|
27
|
+
def setup
|
28
|
+
super
|
29
|
+
self.class.once unless @@once
|
30
|
+
FS_RWROOT.entries { |ent| ent.delete! }
|
31
|
+
end
|
32
|
+
def test_cp_file_to_dir
|
33
|
+
fname = 'f0'
|
34
|
+
loc = SRCDIR/fname
|
35
|
+
rem = FTP_RWROOT.dup
|
36
|
+
rem < loc
|
37
|
+
frem = rem/fname
|
38
|
+
assert_equal(loc.contents,frem.contents)
|
39
|
+
end
|
40
|
+
def test_cp_file_to_file
|
41
|
+
fname = 'f0'
|
42
|
+
loc = SRCDIR/fname
|
43
|
+
rem = FTP_RWROOT.dup/fname
|
44
|
+
rem < loc
|
45
|
+
assert_equal(loc.contents,rem.contents)
|
46
|
+
end
|
47
|
+
def test_cp_dir_left
|
48
|
+
dname = 'd0'
|
49
|
+
loc = SRCDIR/dname
|
50
|
+
rem = FTP_RWROOT.dup
|
51
|
+
rem < loc
|
52
|
+
assert_rios_equal(FS_RWROOT/dname,loc)
|
53
|
+
end
|
54
|
+
def test_cp_dir_right
|
55
|
+
dname = 'd0'
|
56
|
+
loc = SRCDIR/dname
|
57
|
+
rem = FTP_RWROOT.dup
|
58
|
+
loc > rem
|
59
|
+
assert_rios_equal(FS_RWROOT/dname,loc)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
end
|
data/test/ftp/ftp2ftp.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
if $0 == __FILE__
|
3
|
+
Dir.chdir File.dirname(__FILE__)+'/../'
|
4
|
+
$:.unshift File.expand_path('../lib/')
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rio'
|
8
|
+
require 'tc/testcase'
|
9
|
+
require 'open-uri'
|
10
|
+
require 'ftp/testdef'
|
11
|
+
|
12
|
+
class TC_ftp2ftp < Test::RIO::TestCase
|
13
|
+
@@once = false
|
14
|
+
include Test::RIO::FTP::Const
|
15
|
+
|
16
|
+
def self.once
|
17
|
+
@@once = true
|
18
|
+
end
|
19
|
+
def setup
|
20
|
+
super
|
21
|
+
self.class.once unless @@once
|
22
|
+
FS_RWROOT.entries { |ent| ent.delete! }
|
23
|
+
end
|
24
|
+
def test_cp_ro2rw_file1
|
25
|
+
fname = 'f0'
|
26
|
+
src = FTP_ROROOT/fname
|
27
|
+
dst = FTP_RWROOT/fname
|
28
|
+
dst < src
|
29
|
+
assert_equal(src.contents,dst.contents)
|
30
|
+
end
|
31
|
+
def test_cp_ro2rw_file2
|
32
|
+
fname = 'f0'
|
33
|
+
src = FTP_ROROOT/fname
|
34
|
+
dst = FTP_RWROOT
|
35
|
+
dst < src
|
36
|
+
fdst = dst/fname
|
37
|
+
assert_equal(src.contents,fdst.contents)
|
38
|
+
end
|
39
|
+
def test_cp_ro2rw_dir
|
40
|
+
fname = 'd0'
|
41
|
+
src = FTP_ROROOT/fname
|
42
|
+
dst = FTP_RWROOT
|
43
|
+
dst < src
|
44
|
+
ans = rio(FTP_RWROOT,fname).to_a
|
45
|
+
exp = rio(FTP_ROROOT,fname).to_a.map{ |s| s.sub('ro','rw') }
|
46
|
+
|
47
|
+
assert_equal(smap(exp),smap(ans))
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
@@ -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
|
+
require 'rio'
|
6
|
+
$testlib = rio($devlib)
|
7
|
+
$testlib.filename = 'test'
|
8
|
+
$:.unshift $testlib.to_s
|
9
|
+
|
10
|
+
require 'ftp/testdef'
|
11
|
+
Test::RIO::FTP::init_test_files()
|
12
|
+
|
13
|
+
|
14
|
+
exit
|
data/test/ftp/testdef.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rio'
|
2
|
+
|
3
|
+
module Test
|
4
|
+
module RIO
|
5
|
+
module FTP
|
6
|
+
module Const
|
7
|
+
FTPUSER = 'ftp'
|
8
|
+
|
9
|
+
FSROOT = rio('/home/ftp')
|
10
|
+
#FTPHOST = '192.168.1.101'
|
11
|
+
FTPHOST = 'localhost'
|
12
|
+
FTPROOT = rio("ftp://#{FTPHOST}/")
|
13
|
+
|
14
|
+
TESTDIR = rio('riotest')
|
15
|
+
|
16
|
+
RODIR = rio('ro')
|
17
|
+
RWDIR = rio('rw')
|
18
|
+
FTP_RWROOT = FTPROOT/TESTDIR/RWDIR
|
19
|
+
FTP_ROROOT = FTPROOT/TESTDIR/RODIR
|
20
|
+
FS_RWROOT = FSROOT/TESTDIR/RWDIR
|
21
|
+
FS_ROROOT = FSROOT/TESTDIR/RODIR
|
22
|
+
|
23
|
+
PASSWDFILE = FSROOT/'etc/passwd'
|
24
|
+
UID,GID = rio(PASSWDFILE).lines[/^#{FTPUSER}/][0].split(':')[2..3].map{|strid| strid.to_i}
|
25
|
+
end
|
26
|
+
include Const
|
27
|
+
def init_test_files
|
28
|
+
fsdir = rio(FSROOT,TESTDIR).delete!.mkdir
|
29
|
+
rodir = rio(fsdir,RODIR).mkdir
|
30
|
+
rwdir = rio(fsdir,RWDIR).mkdir
|
31
|
+
f0 = rodir/'f0' < "File0\n"
|
32
|
+
d0 = rio(rodir,'d0').mkdir
|
33
|
+
f1 = rio(d0,'f1') < "File1\n"
|
34
|
+
d1 = rio(d0,'d1').mkdir
|
35
|
+
f2 = rio(d1,'f2') < "File2\n"
|
36
|
+
f0.chown(UID,GID).chmod(0555)
|
37
|
+
f1.chown(UID,GID).chmod(0555)
|
38
|
+
f2.chown(UID,GID).chmod(0555)
|
39
|
+
d1.chown(UID,GID).chmod(0555)
|
40
|
+
d0.chown(UID,GID).chmod(0555)
|
41
|
+
rodir.chown(UID,GID).chmod(0555)
|
42
|
+
rwdir.chown(UID,GID).chmod(0777)
|
43
|
+
fsdir.chown(UID,GID).chmod(0555)
|
44
|
+
|
45
|
+
puts rio(FSROOT,TESTDIR).all[]
|
46
|
+
end
|
47
|
+
module_function :init_test_files
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
data/test/gem_runtests.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
Dir.chdir File.dirname(__FILE__)
|
3
|
-
#$:.unshift File.expand_path('../lib/')
|
4
|
-
|
5
|
-
require 'rubygems'
|
6
|
-
require 'rio'
|
7
|
-
|
8
|
-
|
9
|
-
#require 'rio'
|
10
|
-
require 'test/unit'
|
11
|
-
|
12
|
-
require 'tc/all'
|
13
|
-
$trace_states = false
|
14
|
-
require 'test/unit/ui/console/testrunner'
|
15
|
-
#require 'test/unit/ui/tk/testrunner'
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
Dir.chdir File.dirname(__FILE__)
|
3
|
+
#$:.unshift File.expand_path('../lib/')
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'rio'
|
7
|
+
|
8
|
+
|
9
|
+
#require 'rio'
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
require 'tc/all'
|
13
|
+
$trace_states = false
|
14
|
+
require 'test/unit/ui/console/testrunner'
|
15
|
+
#require 'test/unit/ui/tk/testrunner'
|
data/test/runalltests.rb
ADDED
@@ -0,0 +1,15 @@
|
|
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
|
+
require 'ftp/all'
|
13
|
+
$trace_states = false
|
14
|
+
require 'test/unit/ui/console/testrunner'
|
15
|
+
#require 'test/unit/ui/tk/testrunner'
|