rio 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. data/ChangeLog +1273 -1482
  2. data/README +2 -2
  3. data/Rakefile +5 -5
  4. data/VERSION +1 -1
  5. data/{RUNME.1st.rb → build_doc.rb} +4 -10
  6. data/doc/ANNOUNCE +33 -80
  7. data/doc/RELEASE_NOTES +31 -1
  8. data/doc/generators/template/html/rio.rb +3 -3
  9. data/lib/rio/abstract_method.rb +2 -2
  10. data/lib/rio/argv.rb +2 -2
  11. data/lib/rio/arycopy.rb +2 -2
  12. data/lib/rio/assert.rb +2 -2
  13. data/lib/rio/base.rb +2 -2
  14. data/lib/rio/callstr.rb +47 -0
  15. data/lib/rio/const.rb +52 -0
  16. data/lib/rio/construct.rb +6 -24
  17. data/lib/rio/constructor.rb +12 -2
  18. data/lib/rio/context/autoclose.rb +73 -0
  19. data/lib/rio/context/copying.rb +2 -2
  20. data/lib/rio/context/cxx.rb +2 -2
  21. data/lib/rio/context/dir.rb +2 -2
  22. data/lib/rio/context/gzip.rb +2 -2
  23. data/lib/rio/context/methods.rb +6 -34
  24. data/lib/rio/context/skip.rb +2 -2
  25. data/lib/rio/context/stream.rb +2 -2
  26. data/lib/rio/context.rb +17 -2
  27. data/lib/rio/cp.rb +35 -9
  28. data/lib/rio/def.rb +54 -0
  29. data/lib/rio/dir.rb +19 -20
  30. data/lib/rio/doc/HOWTO.rb +23 -7
  31. data/lib/rio/doc/INTRO.rb +57 -23
  32. data/lib/rio/doc/MISC.rb +2 -2
  33. data/lib/rio/doc/OPTIONAL.rb +134 -0
  34. data/lib/rio/doc/SYNOPSIS.rb +11 -4
  35. data/lib/rio/doc.rb +2 -2
  36. data/lib/rio/entrysel.rb +25 -6
  37. data/lib/rio/exception/copy.rb +2 -2
  38. data/lib/rio/exception/notsupported.rb +47 -0
  39. data/lib/rio/exception/open.rb +2 -2
  40. data/lib/rio/exception/state.rb +2 -2
  41. data/lib/rio/exception.rb +2 -2
  42. data/lib/rio/ext/csv.rb +56 -11
  43. data/lib/rio/ext/yaml.rb +2 -2
  44. data/lib/rio/ext/zipfile.rb +91 -0
  45. data/lib/rio/ext.rb +38 -3
  46. data/lib/rio/factory.rb +17 -34
  47. data/lib/rio/file.rb +48 -8
  48. data/lib/rio/filter/closeoneof.rb +36 -16
  49. data/lib/rio/filter/gzip.rb +2 -2
  50. data/lib/rio/filter.rb +2 -2
  51. data/lib/rio/fs/base.rb +42 -0
  52. data/lib/rio/fs/impl.rb +123 -0
  53. data/lib/rio/fs/native.rb +76 -0
  54. data/lib/rio/{record.rb → fs/stream.rb} +21 -18
  55. data/lib/rio/fs/url.rb +64 -0
  56. data/lib/rio/ftp/{ioh.rb → conncache.rb} +38 -39
  57. data/lib/rio/ftp/dir.rb +95 -0
  58. data/lib/rio/ftp/fs.rb +173 -0
  59. data/lib/rio/ftp/ftpfile.rb +20 -0
  60. data/lib/rio/grande.rb +2 -2
  61. data/lib/rio/handle.rb +2 -2
  62. data/lib/rio/if/basic.rb +2 -2
  63. data/lib/rio/if/csv.rb +2 -2
  64. data/lib/rio/if/dir.rb +2 -2
  65. data/lib/rio/if/file.rb +26 -2
  66. data/lib/rio/if/fileordir.rb +44 -49
  67. data/lib/rio/if/grande.rb +32 -10
  68. data/lib/rio/if/grande_entry.rb +12 -2
  69. data/lib/rio/if/grande_stream.rb +17 -28
  70. data/lib/rio/if/internal.rb +2 -2
  71. data/lib/rio/if/path.rb +7 -6
  72. data/lib/rio/if/stream.rb +85 -29
  73. data/lib/rio/if/string.rb +2 -2
  74. data/lib/rio/if/temp.rb +2 -2
  75. data/lib/rio/if/test.rb +37 -4
  76. data/lib/rio/if/yaml.rb +2 -2
  77. data/lib/rio/if.rb +2 -2
  78. data/lib/rio/impl/path.rb +2 -2
  79. data/lib/rio/ioh.rb +17 -6
  80. data/lib/rio/iomode.rb +4 -3
  81. data/lib/rio/ios/fail.rb +107 -0
  82. data/lib/rio/ios/generic.rb +120 -0
  83. data/lib/rio/ios/mode.rb +61 -0
  84. data/lib/rio/ios/null.rb +120 -0
  85. data/lib/rio/iowrap.rb +129 -0
  86. data/lib/rio/kernel.rb +12 -3
  87. data/lib/rio/local.rb +2 -2
  88. data/lib/rio/match.rb +3 -3
  89. data/lib/rio/matchrecord.rb +2 -2
  90. data/lib/rio/no_warn.rb +50 -0
  91. data/lib/rio/{arrayio.rb → nullio.rb} +47 -86
  92. data/lib/rio/open3.rb +2 -2
  93. data/lib/rio/ops/construct.rb +20 -13
  94. data/lib/rio/ops/create.rb +10 -19
  95. data/lib/rio/ops/dir.rb +60 -54
  96. data/lib/rio/ops/either.rb +11 -9
  97. data/lib/rio/ops/file.rb +28 -24
  98. data/lib/rio/ops/path.rb +45 -43
  99. data/lib/rio/ops/stream/input.rb +12 -8
  100. data/lib/rio/ops/stream/output.rb +2 -2
  101. data/lib/rio/ops/stream/read.rb +35 -32
  102. data/lib/rio/ops/stream/write.rb +5 -5
  103. data/lib/rio/ops/stream.rb +7 -3
  104. data/lib/rio/ops/symlink.rb +12 -10
  105. data/lib/rio/path/reset.rb +5 -5
  106. data/lib/rio/path.rb +32 -24
  107. data/lib/rio/piper/cp.rb +2 -2
  108. data/lib/rio/piper.rb +2 -2
  109. data/lib/rio/prompt.rb +2 -2
  110. data/lib/rio/rectype.rb +9 -7
  111. data/lib/rio/rl/base.rb +5 -4
  112. data/lib/rio/rl/builder.rb +17 -5
  113. data/lib/rio/rl/ioi.rb +14 -4
  114. data/lib/rio/rl/path.rb +23 -15
  115. data/lib/rio/rl/pathmethods.rb +12 -2
  116. data/lib/rio/rl/uri.rb +13 -6
  117. data/lib/rio/scheme/aryio.rb +3 -3
  118. data/lib/rio/scheme/cmdio.rb +4 -3
  119. data/lib/rio/scheme/cmdpipe.rb +3 -35
  120. data/lib/rio/scheme/fd.rb +4 -3
  121. data/lib/rio/scheme/ftp.rb +36 -7
  122. data/lib/rio/scheme/http.rb +2 -2
  123. data/lib/rio/{context/closeoneof.rb → scheme/null.rb} +17 -11
  124. data/lib/rio/scheme/path.rb +28 -30
  125. data/lib/rio/scheme/stderr.rb +4 -4
  126. data/lib/rio/scheme/stdio.rb +6 -5
  127. data/lib/rio/scheme/strio.rb +10 -20
  128. data/lib/rio/scheme/sysio.rb +5 -2
  129. data/lib/rio/scheme/tcp.rb +4 -3
  130. data/lib/rio/scheme/temp.rb +14 -1
  131. data/lib/rio/state/error.rb +2 -2
  132. data/lib/rio/state.rb +80 -34
  133. data/lib/rio/stream/base.rb +7 -2
  134. data/lib/rio/stream/duplex.rb +13 -10
  135. data/lib/rio/stream/open.rb +74 -79
  136. data/lib/rio/stream.rb +15 -23
  137. data/lib/rio/symantics.rb +2 -2
  138. data/lib/rio/tempdir.rb +132 -132
  139. data/lib/rio/to_rio/all.rb +40 -0
  140. data/lib/rio/to_rio/array.rb +40 -0
  141. data/lib/rio/to_rio/io.rb +41 -0
  142. data/lib/rio/to_rio/object.rb +43 -0
  143. data/lib/rio/to_rio/string.rb +41 -0
  144. data/lib/rio/to_rio.rb +13 -2
  145. data/lib/rio/uri/file.rb +2 -2
  146. data/lib/rio/util.rb +2 -2
  147. data/lib/rio/version.rb +3 -3
  148. data/lib/rio.rb +16 -25
  149. data/test/bin/count_lines.rb +11 -0
  150. data/test/bin/find_lines.rb +13 -0
  151. data/test/bin/list_dir.rb +14 -0
  152. data/test/ftp/all.rb +9 -0
  153. data/test/ftp/anon_misc.rb +112 -0
  154. data/test/ftp/anon_read.rb +105 -0
  155. data/test/ftp/anon_special.rb +68 -0
  156. data/test/ftp/anon_write.rb +63 -0
  157. data/test/ftp/ftp2ftp.rb +51 -0
  158. data/test/ftp/initftpfiles.rb +14 -0
  159. data/test/ftp/testdef.rb +51 -0
  160. data/test/gem_runtests.rb +15 -15
  161. data/test/runalltests.rb +15 -0
  162. data/test/runftptests.rb +14 -0
  163. data/test/{1.rb → runhttptests.rb} +14 -14
  164. data/test/runtests.rb +14 -14
  165. data/test/tc/all.rb +36 -21
  166. data/test/tc/cmdpipe.rb +18 -15
  167. data/test/tc/copy-from-http.rb +89 -0
  168. data/test/tc/copy-from.rb +1 -52
  169. data/test/tc/copy.rb +19 -17
  170. data/test/tc/csv2.rb +6 -3
  171. data/test/tc/empty.rb +47 -0
  172. data/test/tc/emptyriodir.rb +129 -0
  173. data/test/tc/entsel.rb +110 -0
  174. data/test/tc/files_select.rb +92 -0
  175. data/test/tc/get.rb +7 -6
  176. data/test/tc/getrec.rb +2 -5
  177. data/test/tc/gzip.rb +82 -0
  178. data/test/tc/io_each_byte.rb +60 -0
  179. data/test/tc/io_read.rb +80 -0
  180. data/test/tc/iometh.rb +149 -0
  181. data/test/tc/likeio.rb +112 -0
  182. data/test/tc/methods.rb +10 -9
  183. data/test/tc/misc.rb +1 -37
  184. data/test/tc/null.rb +45 -0
  185. data/test/tc/pid.rb +31 -0
  186. data/test/tc/piper.rb +34 -37
  187. data/test/tc/programs_util.rb +24 -0
  188. data/test/tc/readline.rb +30 -0
  189. data/test/tc/rename.rb +12 -0
  190. data/test/tc/tempfile.rb +14 -0
  191. data/test/tc/testcase.rb +6 -0
  192. data/test/tc/tonl.rb +37 -0
  193. metadata +181 -144
  194. data/ex/colx.rb +0 -8
  195. data/ex/findinruby +0 -16
  196. data/ex/findruby +0 -15
  197. data/ex/passwd_report.rb +0 -8
  198. data/ex/prompt.rb +0 -25
  199. data/ex/rgb.txt.gz +0 -0
  200. data/ex/riocat +0 -35
  201. data/ex/riogunzip +0 -31
  202. data/ex/riogzip +0 -24
  203. data/ex/rioprompt.rb +0 -6
  204. data/ex/targz2zip +0 -17
  205. data/ex/tolf +0 -11
  206. data/lib/rio/ftp/conn.rb +0 -167
  207. data/lib/rio/ftp.rb +0 -275
  208. 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
- # rake rdoc
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.7'
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
- # rake rdoc
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
- module RIO
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
- def method_missing(sym,*args,&block) #:nodoc:
121
- #p callstr('method_missing',sym,*args)
122
-
123
- result = target.__send__(sym,*args,&block)
124
- return result unless result.kind_of? State::Base and result.equal? target
125
-
126
- self
127
- end
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,9 @@
1
+ require 'test/unit'
2
+ require 'tc/testcase'
3
+
4
+ #require 'tc/yaml'
5
+ require 'ftp/anon_read'
6
+ require 'ftp/anon_write'
7
+ require 'ftp/anon_misc'
8
+ require 'ftp/anon_special'
9
+ require 'ftp/ftp2ftp'
@@ -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
@@ -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
@@ -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'
@@ -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'