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
@@ -0,0 +1,14 @@
1
+ #!/usr/local/bin/ruby
2
+ Dir.chdir File.dirname(__FILE__)
3
+ $devlib=File.expand_path('../lib/')
4
+ $:.unshift $devlib unless $:[0] == $devlib
5
+
6
+ $mswin32 = (RUBY_PLATFORM =~ /mswin32/)
7
+
8
+ require 'rio'
9
+ require 'test/unit'
10
+
11
+ require 'ftp/all'
12
+ $trace_states = false
13
+ require 'test/unit/ui/console/testrunner'
14
+ #require 'test/unit/ui/tk/testrunner'
@@ -1,14 +1,14 @@
1
- #!/usr/bin/ruby
2
- Dir.chdir File.dirname(__FILE__)
3
- $:.unshift '../lib'
4
-
5
- require 'rio'
6
- require 'test/unit'
7
-
8
- ARGV.each do |el|
9
- puts "Running test '#{el}'"
10
- load 'tc/'+el+'.rb'
11
- end
12
- $trace_states = false
13
- require 'test/unit/ui/console/testrunner'
14
- #require 'test/unit/ui/tk/testrunner'
1
+ #!/usr/bin/ruby
2
+ Dir.chdir File.dirname(__FILE__)
3
+ $devlib=File.expand_path('../lib/')
4
+ $:.unshift $devlib unless $:[0] == $devlib
5
+
6
+ $mswin32 = (RUBY_PLATFORM =~ /mswin32/)
7
+
8
+ require 'rio'
9
+ require 'test/unit'
10
+
11
+ require 'tc/copy-from-http'
12
+ $trace_states = false
13
+ require 'test/unit/ui/console/testrunner'
14
+ #require 'test/unit/ui/tk/testrunner'
data/test/runtests.rb CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/ruby
2
- Dir.chdir File.dirname(__FILE__)
3
- $devlib=File.expand_path('../lib/')
4
- $:.unshift $devlib unless $:[0] == $devlib
5
-
6
- $mswin32 = (RUBY_PLATFORM =~ /mswin32/)
7
-
8
- require 'rio'
9
- require 'test/unit'
10
-
11
- require 'tc/all'
12
- $trace_states = false
13
- require 'test/unit/ui/console/testrunner'
14
- #require 'test/unit/ui/tk/testrunner'
1
+ #!/usr/local/bin/ruby
2
+ Dir.chdir File.dirname(__FILE__)
3
+ $devlib=File.expand_path('../lib/')
4
+ $:.unshift $devlib unless $:[0] == $devlib
5
+
6
+ $mswin32 = (RUBY_PLATFORM =~ /mswin32/)
7
+
8
+ require 'rio'
9
+ require 'test/unit'
10
+
11
+ require 'tc/all'
12
+ $trace_states = false
13
+ require 'test/unit/ui/console/testrunner'
14
+ #require 'test/unit/ui/tk/testrunner'
data/test/tc/all.rb CHANGED
@@ -2,59 +2,74 @@ require 'test/unit'
2
2
  require 'tc/testcase'
3
3
 
4
4
  #require 'tc/yaml'
5
- require 'tc/dir_iter'
6
- require 'tc/piper' unless $mswin32
7
- require 'tc/cmdpipe'
8
- require 'tc/base'
9
- require 'tc/split'
10
- require 'tc/route'
11
- require 'tc/skip'
12
- require 'tc/skiplines'
13
- require 'tc/selnosel'
14
- require 'tc/csv'
15
- require 'tc/csv2'
16
- require 'tc/csv_columns'
17
- require 'tc/temp'
18
- require 'tc/tempfile'
19
- require 'tc/tempdir'
20
- require 'tc/riorl'
5
+
21
6
  require 'tc/abs'
22
- require 'tc/closeoneof'
7
+ require 'tc/tonl'
8
+ require 'tc/files_select'
9
+ require 'tc/emptyriodir'
10
+ require 'tc/entsel'
11
+ require 'tc/base'
23
12
  require 'tc/clearsel'
24
13
  require 'tc/closeoncopy'
25
- require 'tc/copy-to'
26
- require 'tc/copy-from'
14
+ require 'tc/closeoneof'
15
+ require 'tc/cmdpipe'
27
16
  require 'tc/copy'
17
+ require 'tc/copy-from'
18
+ require 'tc/copy-to'
28
19
  require 'tc/copyarray'
20
+ require 'tc/copydest'
29
21
  require 'tc/copydir'
30
22
  require 'tc/copydirlines'
31
- require 'tc/copydest'
32
23
  require 'tc/copylines'
33
24
  require 'tc/create'
25
+ require 'tc/csv'
26
+ require 'tc/csv2'
27
+ require 'tc/csv_columns'
34
28
  require 'tc/dir'
29
+ require 'tc/dir_iter'
35
30
  require 'tc/dirent'
36
31
  require 'tc/each'
37
32
  require 'tc/each_break'
33
+ require 'tc/empty'
38
34
  require 'tc/entary'
39
35
  require 'tc/eq'
40
36
  require 'tc/expand_path'
41
37
  require 'tc/ext'
42
- require 'tc/getrec'
43
38
  require 'tc/get'
39
+ require 'tc/gzip'
40
+ require 'tc/getrec'
41
+ require 'tc/io_each_byte'
42
+ require 'tc/io_read'
43
+ require 'tc/iometh'
44
+ require 'tc/likeio'
44
45
  require 'tc/lines'
45
46
  require 'tc/methods'
46
47
  require 'tc/misc'
47
48
  require 'tc/nolines'
48
49
  require 'tc/noqae'
50
+ require 'tc/null' unless $mswin32
49
51
  require 'tc/overload'
50
52
  require 'tc/pa'
51
53
  require 'tc/paths'
54
+ require 'tc/pid'
55
+ require 'tc/pid'
56
+ require 'tc/piper' unless $mswin32
52
57
  require 'tc/qae'
53
58
  require 'tc/qae_riovar'
59
+ require 'tc/readline'
54
60
  require 'tc/records'
55
61
  require 'tc/rename'
62
+ require 'tc/riorl'
63
+ require 'tc/route'
64
+ require 'tc/selnosel'
65
+ require 'tc/skip'
66
+ require 'tc/skiplines'
67
+ require 'tc/split'
56
68
  require 'tc/symlink' unless $mswin32
57
69
  require 'tc/symlink0' unless $mswin32
58
70
  require 'tc/symlink1' unless $mswin32
71
+ require 'tc/temp'
72
+ require 'tc/tempdir'
73
+ require 'tc/tempfile'
59
74
 
60
75
 
data/test/tc/cmdpipe.rb CHANGED
@@ -12,6 +12,9 @@ class TC_cmdpipe < Test::RIO::TestCase
12
12
  @@dname = 'd'
13
13
  @@fnames = ['f0','f1','f2','g0','g1']
14
14
 
15
+ require 'tc/programs_util'
16
+ include Test::RIO::Programs
17
+
15
18
  def self.once
16
19
  @@once = true
17
20
  rio(@@dname).rmtree.mkpath.chdir {
@@ -26,7 +29,7 @@ class TC_cmdpipe < Test::RIO::TestCase
26
29
  end
27
30
 
28
31
  def test_cmd_out
29
- ls = rio(?-,'ls d')
32
+ ls = rio(?-,PROG['list_dir']+' d')
30
33
  out = rio(?").chomp
31
34
  exp = @@fnames
32
35
  rtn = ls | out
@@ -35,8 +38,8 @@ class TC_cmdpipe < Test::RIO::TestCase
35
38
  end
36
39
 
37
40
  def test_cmd_cmd_out
38
- ls = rio(?-,'ls d')
39
- grep = rio(?-,'grep f')
41
+ ls = rio(?-,PROG['list_dir']+' d')
42
+ grep = rio(?-,PROG['find_lines']+' f')
40
43
  out = rio(?").chomp
41
44
  exp = @@fnames.select { |fn| fn =~ /f/ }
42
45
  rtn = ls | grep | out
@@ -45,9 +48,9 @@ class TC_cmdpipe < Test::RIO::TestCase
45
48
  end
46
49
 
47
50
  def test_cmd_cmd_cmd_out
48
- ls = rio(?-,'ls d')
49
- cmd = rio(?-,'grep f')
50
- cmd2 = rio(?-,'grep 1')
51
+ ls = rio(?-,PROG['list_dir']+' d')
52
+ cmd = rio(?-,PROG['find_lines']+' f')
53
+ cmd2 = rio(?-,PROG['find_lines']+' 1')
51
54
  out = rio(?").chomp
52
55
  exp = @@fnames.select { |fn| fn =~ /f1/ }
53
56
  rtn = ls | cmd | cmd2 | out
@@ -66,7 +69,7 @@ class TC_cmdpipe < Test::RIO::TestCase
66
69
 
67
70
  def test_file_cmd_out
68
71
  inp = rio('d/f2')
69
- cmd = rio(?-,'grep 1')
72
+ cmd = rio(?-,PROG['find_lines']+' 1')
70
73
  out = rio(?")
71
74
  rtn = inp | cmd | out
72
75
  exp = inp[/1/]
@@ -76,8 +79,8 @@ class TC_cmdpipe < Test::RIO::TestCase
76
79
 
77
80
  def test_file_cmd_cmd_out
78
81
  inp = rio('d/f2')
79
- cmd = rio(?-,'grep 1')
80
- cmd2 = rio(?-,'grep 0')
82
+ cmd = rio(?-,PROG['find_lines']+' 1')
83
+ cmd2 = rio(?-,PROG['find_lines']+' 0')
81
84
  out = rio(?")
82
85
  rtn = inp | cmd | cmd2 | out
83
86
  exp = inp[/10/]
@@ -87,8 +90,8 @@ class TC_cmdpipe < Test::RIO::TestCase
87
90
 
88
91
  def test_file_cmdpipe_out2
89
92
  inp = rio('d/f2')
90
- cmd = rio(?-,'grep 1')
91
- cmd2 = rio(?-,'grep 0')
93
+ cmd = rio(?-,PROG['find_lines']+' 1')
94
+ cmd2 = rio(?-,PROG['find_lines']+' 0')
92
95
 
93
96
  cmdpipe = inp | cmd | cmd2
94
97
  assert_equal('cmdpipe',cmdpipe.scheme)
@@ -108,8 +111,8 @@ class TC_cmdpipe < Test::RIO::TestCase
108
111
 
109
112
  def test_file_cmdpipe_out
110
113
  inp = rio('d/f2')
111
- cmd = rio(?-,'grep 1')
112
- cmd2 = rio(?-,'grep 0')
114
+ cmd = rio(?-,PROG['find_lines']+' 1')
115
+ cmd2 = rio(?-,PROG['find_lines']+' 0')
113
116
  out = rio(?")
114
117
 
115
118
  cmdpipe = cmd | cmd2
@@ -122,8 +125,8 @@ class TC_cmdpipe < Test::RIO::TestCase
122
125
  end
123
126
 
124
127
  def test_cmdpipe_without
125
- cmd = rio(?-,'grep 1')
126
- cmd2 = rio(?-,'grep 0')
128
+ cmd = rio(?-,PROG['find_lines']+' 1')
129
+ cmd2 = rio(?-,PROG['find_lines']+' 0')
127
130
  out = rio(?")
128
131
 
129
132
  cmdpipe = rio(?|,cmd,cmd2,out)
@@ -0,0 +1,89 @@
1
+ #!/usr/local/bin/ruby
2
+ if $0 == __FILE__
3
+ Dir.chdir File.dirname(__FILE__)+'/../'
4
+ $:.unshift File.expand_path('../lib/')
5
+ end
6
+
7
+ require 'rio'
8
+ require 'tc/testcase'
9
+
10
+ class TC_copy_from_http < Test::RIO::TestCase
11
+ @@once = false
12
+ def self.once
13
+ @@once = true
14
+
15
+ rio('d0').rmtree.mkpath
16
+ rio('d1').rmtree.mkpath
17
+ rio('d0/d2').rmtree.mkpath
18
+ make_lines_file(1,'d0/f0')
19
+ make_lines_file(2,'d0/f1')
20
+ make_lines_file(3,'d1/f2')
21
+ make_lines_file(4,'d1/f3')
22
+ make_lines_file(5,'d0/d2/f4')
23
+ make_lines_file(6,'d0/d2/f5')
24
+ end
25
+ def setup
26
+ super
27
+ self.class.once unless @@once
28
+
29
+ @d0 = rio('d0')
30
+ @d2 = rio('d0/d2')
31
+ end
32
+ def cptest(src)
33
+ dst = rio('dst').delete!.mkpath
34
+ dst < src.clone
35
+ assert_rios_equal(src.clone,rio(dst,src.filename),"rio copy")
36
+ end
37
+
38
+ def test_uri_rio_to_file
39
+ ario = rio('out').delete!.touch
40
+ url = 'http://localhost/riotest/hw.html'
41
+ urio = rio(url)
42
+ ario < urio
43
+ exp = urio.contents
44
+ assert_equal(exp,ario.contents)
45
+ end
46
+ def test_uri_rio_to_dir
47
+ ario = rio('ud').delete!.mkdir
48
+ url = 'http://localhost/riotest/hw.html'
49
+ urio = rio(url)
50
+ #$trace_states = true
51
+ ario < urio
52
+ $trace_states = false
53
+ drio = rio(ario,urio.filename)
54
+ assert(drio.file?)
55
+ assert(urio.contents,drio.contents)
56
+ end
57
+ def test_uri_string_to_dir
58
+ ario = rio('uds').delete!.mkdir
59
+ url = 'http://localhost/riotest/hw.html'
60
+ urio = rio(url)
61
+ #$trace_states = true
62
+ ario < url
63
+ $trace_states = false
64
+ drio = rio(ario,urio.filename)
65
+ assert(drio.file?)
66
+ assert(urio.contents,drio.contents)
67
+ end
68
+ def test_url_string_to_file
69
+ ario = rio('out').delete!.touch
70
+ url = 'http://localhost/riotest/hw.html'
71
+ ario < url
72
+ exp = url
73
+ assert_equal(exp,ario.contents)
74
+ end
75
+ def test_url_array_to_file
76
+ ario = rio('out').delete!.touch
77
+ url = 'http://localhost/riotest/hw.html'
78
+ ario < [url]
79
+ exp = url
80
+ assert_equal(exp,ario.contents)
81
+ end
82
+ def test_url_string_to_nonex
83
+ ario = rio('outz').delete!
84
+ url = 'http://localhost/riotest/hw.html'
85
+ ario < url
86
+ exp = url
87
+ assert_equal(exp,ario.contents)
88
+ end
89
+ end
data/test/tc/copy-from.rb CHANGED
@@ -7,7 +7,7 @@ end
7
7
  require 'rio'
8
8
  require 'tc/testcase'
9
9
 
10
- class TC_copyfrom < Test::RIO::TestCase
10
+ class TC_copy_from < Test::RIO::TestCase
11
11
  @@once = false
12
12
  def self.once
13
13
  @@once = true
@@ -121,57 +121,6 @@ class TC_copyfrom < Test::RIO::TestCase
121
121
  ans = ario.readlines
122
122
  assert_equal(exp,ans)
123
123
  end
124
- def test_uri_rio_to_file
125
- ario = rio('out').delete!.touch
126
- url = 'http://localhost/rio/hw.html'
127
- urio = rio(url)
128
- ario < urio
129
- exp = urio.contents
130
- assert_equal(exp,ario.contents)
131
- end
132
- def test_uri_rio_to_dir
133
- ario = rio('ud').delete!.mkdir
134
- url = 'http://localhost/rio/hw.html'
135
- urio = rio(url)
136
- #$trace_states = true
137
- ario < urio
138
- $trace_states = false
139
- drio = rio(ario,urio.filename)
140
- assert(drio.file?)
141
- assert(urio.contents,drio.contents)
142
- end
143
- def test_uri_string_to_dir
144
- ario = rio('uds').delete!.mkdir
145
- url = 'http://localhost/rio/hw.html'
146
- urio = rio(url)
147
- #$trace_states = true
148
- ario < url
149
- $trace_states = false
150
- drio = rio(ario,urio.filename)
151
- assert(drio.file?)
152
- assert(urio.contents,drio.contents)
153
- end
154
- def test_url_string_to_file
155
- ario = rio('out').delete!.touch
156
- url = 'http://localhost/rio/hw.html'
157
- ario < url
158
- exp = url
159
- assert_equal(exp,ario.contents)
160
- end
161
- def test_url_array_to_file
162
- ario = rio('out').delete!.touch
163
- url = 'http://localhost/rio/hw.html'
164
- ario < [url]
165
- exp = url
166
- assert_equal(exp,ario.contents)
167
- end
168
- def test_url_string_to_nonex
169
- ario = rio('outz').delete!
170
- url = 'http://localhost/rio/hw.html'
171
- ario < url
172
- exp = url
173
- assert_equal(exp,ario.contents)
174
- end
175
124
  def test_simple_ary
176
125
  dst = rio('dst').delete!.mkpath
177
126
  dst < @d0[]
data/test/tc/copy.rb CHANGED
@@ -27,7 +27,7 @@ class TC_RIO_copy < Test::Unit::TestCase
27
27
  sline = rio(datadir,'src').readline
28
28
  l1 = rio(datadir,'dst1').readline
29
29
  l2 = rio(datadir,'dst2/src').readline
30
- assert_equal(inline,sline,'a message in a assertion')
30
+ assert_equal(inline,sline,'a message in an assertion')
31
31
  assert_equal(inline,l1)
32
32
  assert_equal(inline,l2)
33
33
 
@@ -37,25 +37,27 @@ class TC_RIO_copy < Test::Unit::TestCase
37
37
  sd1.join('f1.txt').puts(txt).close
38
38
  oline = rio(datadir,'dir1/sd1/f1.txt').readline
39
39
 
40
- dir2 = rio(datadir,'dir2').rmtree.mkpath
41
- sd1.copy_to(dir2)
42
- nline = rio(datadir,'dir2/sd1/f1.txt').readline
43
- assert_equal(oline,nline)
40
+ # dir2 = rio(datadir,'dir2').rmtree.mkpath
41
+ # sd1.copy_to(dir2)
42
+ # $trace_states = true
43
+ # nline = rio(datadir,'dir2/sd1/f1.txt').readline
44
+ # assert_equal(oline,nline)
44
45
 
45
- dir2 = rio(datadir,'dir2').rmtree.mkpath
46
- sd1 > dir2
47
- nline = rio(datadir,'dir2/sd1/f1.txt').readline
48
- assert_equal(oline,nline)
46
+ # dir2 = rio(datadir,'dir2').rmtree.mkpath
47
+ # sd1 > dir2
48
+ # $trace_states = false
49
+ # nline = rio(datadir,'dir2/sd1/f1.txt').readline
50
+ # assert_equal(oline,nline)
49
51
 
50
- dir2 = rio(datadir,'dir2').rmtree.mkpath
51
- dir2 < rio(datadir,'dir1/sd1')
52
- nline = rio(datadir,'dir2/sd1/f1.txt').readline
53
- assert_equal(oline,nline)
52
+ # dir2 = rio(datadir,'dir2').rmtree.mkpath
53
+ # dir2 < rio(datadir,'dir1/sd1')
54
+ # nline = rio(datadir,'dir2/sd1/f1.txt').readline
55
+ # assert_equal(oline,nline)
54
56
 
55
- dir2 = rio(datadir,'dir2').rmtree.mkpath
56
- sd1 > dir2.to_s
57
- nline = rio(datadir,'dir2/sd1/f1.txt').readline
58
- assert_equal(oline,nline)
57
+ # dir2 = rio(datadir,'dir2').rmtree.mkpath
58
+ # sd1 > dir2.to_s
59
+ # nline = rio(datadir,'dir2/sd1/f1.txt').readline
60
+ # assert_equal(oline,nline)
59
61
 
60
62
  dir2 = rio(datadir,'dir2').rmtree.mkpath
61
63
  dir2 < rio(datadir,'dir1/sd1').to_s
data/test/tc/csv2.rb CHANGED
@@ -115,7 +115,8 @@ class TC_csv2 < Test::RIO::TestCase
115
115
  rec_ary = @records[0]
116
116
  rec_rio = rio('src1.csv').csv.getrec
117
117
  assert_kind_of(::Array,rec_rio)
118
- assert_equal(@strings[0],rec_rio.to_s)
118
+ exp = $EXTEND_CSV_RESULTS ? @strings[0] : @records[0].to_s
119
+ assert_equal(exp,rec_rio.to_s)
119
120
 
120
121
  rec_rio = rio('src1.csv').csv.lines.getrec
121
122
  assert_kind_of(::Array,rec_rio)
@@ -123,11 +124,13 @@ class TC_csv2 < Test::RIO::TestCase
123
124
 
124
125
  ary = rio('src1.csv').csv[]
125
126
  assert_kind_of(::Array,ary[0])
126
- assert_equal(@strings[0],ary[0].to_s)
127
+ exp = $EXTEND_CSV_RESULTS ? @strings[0] : @records[0].to_s
128
+ assert_equal(exp,ary[0].to_s)
127
129
 
128
130
  recs = rio('src1.csv').csv.lines[]
129
131
  assert_kind_of(::String,recs[0])
130
- assert_equal(@records[0],recs[0].to_a)
132
+ exp = $EXTEND_CSV_RESULTS ? @records[0] : [@strings[0]+$/]
133
+ assert_equal(exp,recs[0].to_a)
131
134
  return
132
135
  end
133
136
 
data/test/tc/empty.rb ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/local/bin/ruby
2
+ if $0 == __FILE__
3
+ Dir.chdir File.dirname(__FILE__)+'/../'
4
+ $:.unshift File.expand_path('../lib/')
5
+ end
6
+
7
+ require 'rio'
8
+ require 'tc/testcase'
9
+
10
+ class TC_empty < Test::RIO::TestCase
11
+ @@once = false
12
+ def self.once
13
+ @@once = true
14
+
15
+ rio('d0').rmtree.mkpath
16
+ rio('d1').rmtree.mkpath.chdir {
17
+ rio('file').touch
18
+ }
19
+ rio('f0').delete!.touch
20
+ rio('f1').puts!("a nonempty file\n")
21
+ end
22
+ def setup
23
+ super
24
+ self.class.once unless @@once
25
+ end
26
+ def test_file_empty
27
+ assert(rio('d0').empty?)
28
+ end
29
+ def test_file_not_empty
30
+ assert!(rio('d1').empty?)
31
+ end
32
+ def test_dir_empty
33
+ assert(rio('f0').empty?)
34
+ end
35
+ def test_dir_not_empty
36
+ assert!(rio('f1').empty?)
37
+ end
38
+ def test_ps_empty
39
+ assert(rio(?-,'ls d0').empty?)
40
+ end
41
+ def test_ps_not_empty
42
+ assert!(rio(?-,'ls d1').empty?)
43
+ end
44
+ def test_dev_null_empty
45
+ assert(rio(nil).empty?)
46
+ end
47
+ end
@@ -0,0 +1,129 @@
1
+ #!/usr/local/bin/ruby
2
+ if $0 == __FILE__
3
+ Dir.chdir File.dirname(__FILE__)+'/../'
4
+ $:.unshift File.expand_path('../lib/')
5
+ end
6
+
7
+ require 'rio'
8
+ require 'tc/testcase'
9
+
10
+ class TC_emptyriodir < Test::RIO::TestCase
11
+ include RIO_TestCase
12
+ @@once = false
13
+ def self.once
14
+ @@once = true
15
+ rio('adir').mkdir.chdir {
16
+ rio('a.rb').touch
17
+ rio('b.rb').touch
18
+ rio('c.txt').touch
19
+ }
20
+ rio('d.rb').touch
21
+ rio('e.txt').touch
22
+ rio('f.d').mkdir
23
+ end
24
+
25
+ def setup
26
+ super
27
+ self.class.once unless @@once
28
+ end
29
+
30
+ def test_ss
31
+
32
+ dotans = rio('.')[]
33
+ empans = rio[]
34
+ assert_array_equal(dotans,empans)
35
+
36
+ dotans = rio('.')['*.rb']
37
+ empans = rio['*.rb']
38
+ assert_array_equal(dotans,empans)
39
+
40
+ end
41
+
42
+ def test_each
43
+
44
+ dotans = []
45
+ empans = []
46
+ rio('.').each{ |el| dotans << el }
47
+ rio.each{ |el| empans << el }
48
+ assert_array_equal(dotans,empans)
49
+
50
+ dotans = []
51
+ empans = []
52
+ rio('.').entries('*.rb') { |el| dotans << el }
53
+ rio.entries('*.rb') { |el| empans << el }
54
+ assert_array_equal(dotans,empans)
55
+ end
56
+
57
+ def test_read
58
+ dotans = []
59
+ empans = []
60
+ dotrio = rio('.')
61
+ emprio = rio
62
+ while s = dotrio.read do dotans << s end
63
+ while s = emprio.read do empans << s end
64
+ assert_array_equal(dotans,empans)
65
+ end
66
+
67
+ def test_get
68
+ dotans = []
69
+ empans = []
70
+ dotrio = rio('.')
71
+ emprio = rio
72
+ while s = dotrio.get do dotans << s end
73
+ while s = emprio.get do empans << s end
74
+ assert_array_equal(dotans,empans)
75
+
76
+ dotans = []
77
+ empans = []
78
+ dotrio = rio('.').entries('*.d')
79
+ emprio = rio.entries('*.d')
80
+ while s = dotrio.get do dotans << s end
81
+ while s = emprio.get do empans << s end
82
+ assert_array_equal(dotans,empans)
83
+
84
+ end
85
+
86
+ def test_skip
87
+
88
+ dotans = rio('.').skip[]
89
+ empans = rio.skip[]
90
+ assert_array_equal(dotans,empans)
91
+
92
+ dotans = rio('.').skip['*.rb']
93
+ empans = rio.skip['*.rb']
94
+ assert_array_equal(dotans,empans)
95
+
96
+ end
97
+
98
+ def test_dirs
99
+
100
+ dotans = rio('.').dirs[]
101
+ empans = rio.dirs[]
102
+ assert_array_equal(dotans,empans)
103
+
104
+ dotans = rio('.').dirs['*.d']
105
+ empans = rio.dirs['*.d']
106
+ assert_array_equal(dotans,empans)
107
+
108
+ end
109
+
110
+
111
+ def test_getwd
112
+ dotans = rio('.').getwd
113
+ empans = rio.getwd
114
+ assert_array_equal(dotans,empans)
115
+ end
116
+
117
+ def test_rmdir
118
+ rio('empty.d').delete!.mkdir.chdir {
119
+ assert_raise(RIO::Exception::CantHandle) { rio.rmdir }
120
+ }
121
+ end
122
+
123
+ def test_rmtree
124
+ rio('empty.d').delete!.mkdir.chdir {
125
+ assert_raise(RIO::Exception::CantHandle) { rio.rmtree }
126
+ }
127
+ end
128
+
129
+ end