rio 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. data/README +18 -12
  2. data/Rakefile +57 -87
  3. data/build_doc.rb +19 -17
  4. data/doc/ANNOUNCE +3 -32
  5. data/doc/RELEASE_NOTES +4 -5
  6. data/doc/RIOIS +215 -0
  7. data/doc/generators/template/html/rio.css +428 -0
  8. data/doc/generators/template/html/rio.rb +18 -389
  9. data/doc/generators/template/html/ugly.rb +130 -0
  10. data/doc/pkg_def.rb +66 -0
  11. data/ex/catcsv.rb +64 -0
  12. data/ex/colx.rb +8 -0
  13. data/ex/findinruby +15 -0
  14. data/ex/findruby +14 -0
  15. data/ex/passwd_report.rb +8 -0
  16. data/ex/prompt.rb +25 -0
  17. data/ex/rgb.txt.gz +0 -0
  18. data/ex/riocat +42 -0
  19. data/ex/riogunzip +31 -0
  20. data/ex/riogzip +24 -0
  21. data/ex/rioprompt.rb +10 -0
  22. data/ex/targz2zip +17 -0
  23. data/ex/tonl +10 -0
  24. data/lib/rio.rb +16 -10
  25. data/lib/rio/abstract_method.rb +3 -4
  26. data/lib/rio/argv.rb +3 -4
  27. data/lib/rio/arycopy.rb +3 -4
  28. data/lib/rio/assert.rb +3 -4
  29. data/lib/rio/base.rb +3 -4
  30. data/lib/rio/callstr.rb +3 -4
  31. data/lib/rio/const.rb +3 -4
  32. data/lib/rio/construct.rb +3 -4
  33. data/lib/rio/constructor.rb +12 -8
  34. data/lib/rio/context.rb +15 -30
  35. data/lib/rio/context/autoclose.rb +3 -4
  36. data/lib/rio/context/copying.rb +3 -4
  37. data/lib/rio/context/cxx.rb +3 -4
  38. data/lib/rio/context/dir.rb +3 -4
  39. data/lib/rio/context/gzip.rb +3 -4
  40. data/lib/rio/context/methods.rb +16 -5
  41. data/lib/rio/context/skip.rb +3 -4
  42. data/lib/rio/context/stream.rb +42 -5
  43. data/lib/rio/cp.rb +7 -7
  44. data/lib/rio/def.rb +3 -4
  45. data/lib/rio/dir.rb +3 -4
  46. data/lib/rio/doc.rb +4 -5
  47. data/lib/rio/doc/EXAMPLES.rb +299 -0
  48. data/lib/rio/doc/HOWTO.rb +3 -4
  49. data/lib/rio/doc/INTRO.rb +86 -105
  50. data/lib/rio/doc/OPTIONAL.rb +4 -5
  51. data/lib/rio/doc/SYNOPSIS.rb +7 -6
  52. data/lib/rio/entrysel.rb +21 -23
  53. data/lib/rio/exception.rb +3 -4
  54. data/lib/rio/exception/copy.rb +3 -4
  55. data/lib/rio/exception/notimplemented.rb +57 -0
  56. data/lib/rio/exception/notsupported.rb +3 -4
  57. data/lib/rio/exception/open.rb +3 -4
  58. data/lib/rio/exception/state.rb +3 -4
  59. data/lib/rio/ext.rb +47 -13
  60. data/lib/rio/ext/csv.rb +4 -5
  61. data/lib/rio/ext/if.rb +45 -0
  62. data/lib/rio/ext/mp3info.rb +80 -0
  63. data/lib/rio/ext/splitlines.rb +253 -0
  64. data/lib/rio/ext/yaml.rb +9 -5
  65. data/lib/rio/ext/yaml/doc.rb +133 -0
  66. data/lib/rio/ext/yaml/tie.rb +149 -0
  67. data/lib/rio/ext/zipfile.rb +23 -4
  68. data/lib/rio/ext/zipfile/fs.rb +116 -0
  69. data/lib/rio/ext/zipfile/rl.rb +251 -0
  70. data/lib/rio/ext/zipfile/rootdir.rb +117 -0
  71. data/lib/rio/ext/zipfile/state.rb +161 -0
  72. data/lib/rio/ext/zipfile/wrap.rb +204 -0
  73. data/lib/rio/factory.rb +235 -27
  74. data/lib/rio/file.rb +4 -4
  75. data/lib/rio/filter.rb +3 -4
  76. data/lib/rio/filter/closeoneof.rb +3 -4
  77. data/lib/rio/filter/gzip.rb +9 -4
  78. data/lib/rio/fs/base.rb +3 -4
  79. data/lib/rio/fs/impl.rb +4 -5
  80. data/lib/rio/fs/native.rb +3 -4
  81. data/lib/rio/fs/stream.rb +3 -4
  82. data/lib/rio/fs/url.rb +3 -4
  83. data/lib/rio/ftp/conncache.rb +19 -5
  84. data/lib/rio/ftp/dir.rb +3 -4
  85. data/lib/rio/ftp/fs.rb +30 -24
  86. data/lib/rio/grande.rb +27 -7
  87. data/lib/rio/handle.rb +3 -4
  88. data/lib/rio/if.rb +19 -15
  89. data/lib/rio/if/basic.rb +7 -7
  90. data/lib/rio/if/csv.rb +5 -6
  91. data/lib/rio/if/dir.rb +120 -114
  92. data/lib/rio/if/file.rb +52 -44
  93. data/lib/rio/if/fileordir.rb +217 -211
  94. data/lib/rio/if/grande.rb +674 -644
  95. data/lib/rio/if/grande_entry.rb +321 -313
  96. data/lib/rio/if/grande_stream.rb +653 -553
  97. data/lib/rio/if/internal.rb +3 -4
  98. data/lib/rio/if/path.rb +425 -426
  99. data/lib/rio/if/rubyio.rb +681 -0
  100. data/lib/rio/if/string.rb +42 -5
  101. data/lib/rio/if/temp.rb +3 -4
  102. data/lib/rio/if/test.rb +245 -238
  103. data/lib/rio/if/yaml.rb +15 -41
  104. data/lib/rio/ioh.rb +7 -5
  105. data/lib/rio/iomode.rb +19 -7
  106. data/lib/rio/ios/fail.rb +4 -5
  107. data/lib/rio/ios/generic.rb +4 -5
  108. data/lib/rio/ios/mode.rb +4 -5
  109. data/lib/rio/ios/null.rb +6 -7
  110. data/lib/rio/iowrap.rb +3 -4
  111. data/lib/rio/kernel.rb +3 -5
  112. data/lib/rio/local.rb +3 -4
  113. data/lib/rio/match.rb +3 -4
  114. data/lib/rio/matchrecord.rb +3 -4
  115. data/lib/rio/no_warn.rb +3 -4
  116. data/lib/rio/nullio.rb +3 -4
  117. data/lib/rio/open3.rb +4 -5
  118. data/lib/rio/ops/construct.rb +3 -4
  119. data/lib/rio/ops/create.rb +11 -6
  120. data/lib/rio/ops/dir.rb +19 -8
  121. data/lib/rio/ops/either.rb +6 -5
  122. data/lib/rio/ops/file.rb +3 -4
  123. data/lib/rio/ops/path.rb +14 -35
  124. data/lib/rio/ops/stream.rb +3 -4
  125. data/lib/rio/ops/stream/input.rb +4 -7
  126. data/lib/rio/ops/stream/output.rb +3 -4
  127. data/lib/rio/ops/stream/read.rb +6 -5
  128. data/lib/rio/ops/stream/write.rb +3 -4
  129. data/lib/rio/ops/symlink.rb +3 -4
  130. data/lib/rio/path.rb +22 -18
  131. data/lib/rio/path/reset.rb +4 -5
  132. data/lib/rio/piper.rb +3 -4
  133. data/lib/rio/piper/cp.rb +3 -4
  134. data/lib/rio/prompt.rb +10 -5
  135. data/lib/rio/rectype.rb +5 -5
  136. data/lib/rio/rl/base.rb +17 -71
  137. data/lib/rio/rl/builder.rb +14 -38
  138. data/lib/rio/rl/chmap.rb +66 -0
  139. data/lib/rio/rl/fs2url.rb +82 -0
  140. data/lib/rio/rl/ioi.rb +4 -4
  141. data/lib/rio/rl/path.rb +44 -122
  142. data/lib/rio/rl/pathmethods.rb +19 -8
  143. data/lib/rio/rl/uri.rb +137 -60
  144. data/lib/rio/rl/withpath.rb +295 -0
  145. data/lib/rio/scheme/aryio.rb +3 -4
  146. data/lib/rio/scheme/cmdio.rb +3 -4
  147. data/lib/rio/scheme/cmdpipe.rb +4 -4
  148. data/lib/rio/scheme/fd.rb +3 -4
  149. data/lib/rio/scheme/ftp.rb +7 -7
  150. data/lib/rio/scheme/http.rb +4 -5
  151. data/lib/rio/scheme/null.rb +3 -4
  152. data/lib/rio/scheme/path.rb +3 -4
  153. data/lib/rio/scheme/stderr.rb +3 -4
  154. data/lib/rio/scheme/stdio.rb +3 -4
  155. data/lib/rio/scheme/strio.rb +3 -4
  156. data/lib/rio/scheme/sysio.rb +3 -4
  157. data/lib/rio/scheme/tcp.rb +3 -4
  158. data/lib/rio/scheme/temp.rb +6 -6
  159. data/lib/rio/state.rb +18 -46
  160. data/lib/rio/state/error.rb +3 -4
  161. data/lib/rio/stream.rb +4 -4
  162. data/lib/rio/stream/base.rb +3 -4
  163. data/lib/rio/stream/duplex.rb +3 -4
  164. data/lib/rio/stream/open.rb +3 -8
  165. data/lib/rio/symantics.rb +3 -4
  166. data/lib/rio/tempdir.rb +2 -2
  167. data/lib/rio/to_rio.rb +3 -4
  168. data/lib/rio/to_rio/all.rb +3 -4
  169. data/lib/rio/to_rio/array.rb +4 -5
  170. data/lib/rio/to_rio/io.rb +4 -5
  171. data/lib/rio/to_rio/object.rb +4 -5
  172. data/lib/rio/to_rio/string.rb +4 -5
  173. data/lib/rio/uri/file.rb +41 -5
  174. data/lib/rio/util.rb +3 -4
  175. data/lib/rio/version.rb +4 -5
  176. data/setup.rb +368 -339
  177. data/test/bin/list_dir.rb +1 -1
  178. data/test/ftp/anon_misc.rb +13 -1
  179. data/test/ftp/anon_special.rb +6 -6
  180. data/test/ftp/anon_write.rb +10 -3
  181. data/test/ftp/ftp2ftp.rb +2 -2
  182. data/test/ftp/testdef.rb +9 -6
  183. data/test/http/all.rb +3 -0
  184. data/test/http/copy-from-http.rb +140 -0
  185. data/test/lib/temp_server.rb +44 -0
  186. data/test/runalltests.rb +3 -1
  187. data/test/runhttp.rb +12 -0
  188. data/test/runhttptests.rb +1 -1
  189. data/test/runtests.rb +41 -3
  190. data/test/tc/abs.rb +9 -5
  191. data/test/tc/all.rb +9 -4
  192. data/test/tc/base.rb +1 -1
  193. data/test/tc/base2.rb +87 -0
  194. data/test/tc/{methods.rb → clone.rb} +72 -50
  195. data/test/tc/closeoncopy.rb +13 -2
  196. data/test/tc/copy-dir-samevar.rb +91 -0
  197. data/test/tc/dir_iter.rb +0 -1
  198. data/test/tc/empty.rb +6 -2
  199. data/test/tc/expand_path.rb +36 -54
  200. data/test/tc/ext.rb +42 -18
  201. data/test/tc/gzip.rb +30 -3
  202. data/test/tc/likeio.rb +5 -1
  203. data/test/tc/line_record_row.rb +51 -0
  204. data/test/tc/noqae.rb +71 -70
  205. data/test/tc/path_parts.rb +175 -0
  206. data/test/tc/programs_util.rb +3 -3
  207. data/test/tc/rename.rb +4 -5
  208. data/test/tc/riorl.rb +9 -7
  209. data/test/tc/skip.rb +35 -6
  210. data/test/tc/skiplines.rb +34 -5
  211. data/test/tc/split.rb +8 -50
  212. data/test/tc/splitlines.rb +65 -0
  213. data/test/tc/splitpath.rb +83 -0
  214. data/test/tc/testcase.rb +1 -1
  215. data/test/tc/truncate.rb +39 -0
  216. data/test/tc/yaml.rb +9 -8
  217. metadata +261 -207
  218. data/ChangeLog +0 -1418
  219. data/VERSION +0 -1
  220. data/lib/rio/doc/MISC.rb +0 -259
  221. data/lib/rio/if/stream.rb +0 -680
  222. data/lib/rio/impl/path.rb +0 -87
  223. data/test/tc/copy-from-http.rb +0 -89
@@ -9,6 +9,6 @@ require 'rio'
9
9
 
10
10
  dir = ARGV.shift || '.'
11
11
  rio(dir).chdir {
12
- puts rio.to_a
12
+ puts rio[]
13
13
  }
14
14
 
@@ -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
- FS_RWROOT.entries { |ent| ent.delete! }
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
@@ -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 test_mkpath
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 test_sel
45
+ def atest_sel
46
46
  rwdir = rio(FTP_RWROOT)
47
47
  d0 = rwdir/'d0'
48
48
  d1 = d0/'d1'
@@ -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
- FS_RWROOT.entries { |ent| ent.delete! }
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.contents,frem.contents)
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.contents,rem.contents)
52
+ assert_equal(loc.chomp[],rem.chomp[])
46
53
  end
47
54
  def test_cp_dir_left
48
55
  dname = 'd0'
@@ -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.contents,dst.contents)
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.contents,fdst.contents)
37
+ assert_equal(src.chomp[],fdst.chomp[])
38
38
  end
39
39
  def test_cp_ro2rw_dir
40
40
  fname = 'd0'
@@ -6,9 +6,11 @@ module Test
6
6
  module Const
7
7
  FTPUSER = 'ftp'
8
8
 
9
- FSROOT = rio('/home/ftp')
10
- #FTPHOST = '192.168.1.101'
11
- FTPHOST = 'localhost'
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
- PASSWDFILE = FSROOT/'etc/passwd'
24
- UID,GID = rio(PASSWDFILE).lines[/^#{FTPUSER}/][0].split(':')[2..3].map{|strid| strid.to_i}
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
@@ -0,0 +1,3 @@
1
+ require 'tc/testcase'
2
+
3
+ require 'http/copy-from-http'
@@ -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
@@ -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'
@@ -0,0 +1,12 @@
1
+ #!/usr/local/bin/ruby
2
+ Dir.chdir File.dirname(__FILE__)
3
+ $:.unshift File.expand_path('../lib/')
4
+
5
+ require 'webrick'
6
+ require 'rio'
7
+ require 'lib/temp_server'
8
+
9
+
10
+ TempServer.new.run('runhttptests.rb')
11
+
12
+ #threads.each { |aThread| aThread.join }
@@ -8,7 +8,7 @@ $mswin32 = (RUBY_PLATFORM =~ /mswin32/)
8
8
  require 'rio'
9
9
  require 'test/unit'
10
10
 
11
- require 'tc/copy-from-http'
11
+ require 'http/all'
12
12
  $trace_states = false
13
13
  require 'test/unit/ui/console/testrunner'
14
14
  #require 'test/unit/ui/tk/testrunner'
@@ -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 'test/unit/ui/console/testrunner'
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)
@@ -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
- assert_nil(hd.fspath)
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
- assert_nil(hd.fspath)
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
- assert_nil(hd.fspath)
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
- assert_nil(hd.fspath)
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
- assert_nil(hd.fspath)
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)