rio 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. data/ChangeLog +140 -0
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/doc/ANNOUNCE +87 -0
  5. data/doc/RELEASE_NOTES +7 -0
  6. data/doc/rdoc/classes/Kernel.html +9 -9
  7. data/doc/rdoc/classes/Kernel.src/{M000183.html → M000182.html} +0 -0
  8. data/doc/rdoc/classes/RIO.html +35 -0
  9. data/doc/rdoc/classes/RIO.src/M000001.html +4 -4
  10. data/doc/rdoc/classes/RIO.src/M000002.html +4 -4
  11. data/doc/rdoc/classes/RIO.src/M000003.html +4 -4
  12. data/doc/rdoc/classes/RIO/Doc/HOWTO.html +11 -7
  13. data/doc/rdoc/classes/RIO/Doc/INTRO.html +255 -36
  14. data/doc/rdoc/classes/RIO/Doc/SYNOPSIS.html +47 -17
  15. data/doc/rdoc/classes/RIO/Rio.html +1032 -1007
  16. data/doc/rdoc/classes/RIO/Rio.src/M000011.html +3 -3
  17. data/doc/rdoc/classes/RIO/Rio.src/M000012.html +3 -3
  18. data/doc/rdoc/classes/RIO/Rio.src/M000013.html +3 -3
  19. data/doc/rdoc/classes/RIO/Rio.src/M000014.html +3 -3
  20. data/doc/rdoc/classes/RIO/Rio.src/M000015.html +3 -3
  21. data/doc/rdoc/classes/RIO/Rio.src/M000016.html +3 -3
  22. data/doc/rdoc/classes/RIO/Rio.src/M000017.html +3 -3
  23. data/doc/rdoc/classes/RIO/Rio.src/M000018.html +3 -3
  24. data/doc/rdoc/classes/RIO/Rio.src/M000019.html +3 -3
  25. data/doc/rdoc/classes/RIO/Rio.src/M000020.html +3 -3
  26. data/doc/rdoc/classes/RIO/Rio.src/M000021.html +3 -3
  27. data/doc/rdoc/classes/RIO/Rio.src/M000022.html +3 -3
  28. data/doc/rdoc/classes/RIO/Rio.src/M000023.html +3 -3
  29. data/doc/rdoc/classes/RIO/Rio.src/M000024.html +3 -3
  30. data/doc/rdoc/classes/RIO/Rio.src/M000025.html +3 -3
  31. data/doc/rdoc/classes/RIO/Rio.src/M000026.html +3 -3
  32. data/doc/rdoc/classes/RIO/Rio.src/M000027.html +3 -3
  33. data/doc/rdoc/classes/RIO/Rio.src/M000028.html +3 -3
  34. data/doc/rdoc/classes/RIO/Rio.src/M000029.html +3 -3
  35. data/doc/rdoc/classes/RIO/Rio.src/M000030.html +3 -3
  36. data/doc/rdoc/classes/RIO/Rio.src/M000031.html +3 -3
  37. data/doc/rdoc/classes/RIO/Rio.src/M000032.html +3 -3
  38. data/doc/rdoc/classes/RIO/Rio.src/M000033.html +3 -3
  39. data/doc/rdoc/classes/RIO/Rio.src/M000034.html +3 -3
  40. data/doc/rdoc/classes/RIO/Rio.src/M000035.html +3 -3
  41. data/doc/rdoc/classes/RIO/Rio.src/M000036.html +3 -3
  42. data/doc/rdoc/classes/RIO/Rio.src/M000037.html +3 -3
  43. data/doc/rdoc/classes/RIO/Rio.src/M000038.html +3 -3
  44. data/doc/rdoc/classes/RIO/Rio.src/M000039.html +3 -3
  45. data/doc/rdoc/classes/RIO/Rio.src/M000040.html +3 -3
  46. data/doc/rdoc/classes/RIO/Rio.src/M000041.html +3 -3
  47. data/doc/rdoc/classes/RIO/Rio.src/M000042.html +3 -3
  48. data/doc/rdoc/classes/RIO/Rio.src/M000043.html +3 -3
  49. data/doc/rdoc/classes/RIO/Rio.src/M000044.html +3 -3
  50. data/doc/rdoc/classes/RIO/Rio.src/M000045.html +3 -3
  51. data/doc/rdoc/classes/RIO/Rio.src/M000046.html +3 -3
  52. data/doc/rdoc/classes/RIO/Rio.src/M000047.html +3 -3
  53. data/doc/rdoc/classes/RIO/Rio.src/M000048.html +3 -3
  54. data/doc/rdoc/classes/RIO/Rio.src/M000049.html +3 -3
  55. data/doc/rdoc/classes/RIO/Rio.src/M000050.html +3 -3
  56. data/doc/rdoc/classes/RIO/Rio.src/M000051.html +3 -3
  57. data/doc/rdoc/classes/RIO/Rio.src/M000052.html +3 -3
  58. data/doc/rdoc/classes/RIO/Rio.src/M000053.html +3 -3
  59. data/doc/rdoc/classes/RIO/Rio.src/M000054.html +3 -3
  60. data/doc/rdoc/classes/RIO/Rio.src/M000055.html +3 -3
  61. data/doc/rdoc/classes/RIO/Rio.src/M000056.html +3 -3
  62. data/doc/rdoc/classes/RIO/Rio.src/M000057.html +3 -3
  63. data/doc/rdoc/classes/RIO/Rio.src/M000058.html +3 -3
  64. data/doc/rdoc/classes/RIO/Rio.src/M000059.html +3 -3
  65. data/doc/rdoc/classes/RIO/Rio.src/M000060.html +3 -3
  66. data/doc/rdoc/classes/RIO/Rio.src/M000061.html +3 -3
  67. data/doc/rdoc/classes/RIO/Rio.src/M000062.html +3 -3
  68. data/doc/rdoc/classes/RIO/Rio.src/M000063.html +3 -3
  69. data/doc/rdoc/classes/RIO/Rio.src/M000064.html +3 -3
  70. data/doc/rdoc/classes/RIO/Rio.src/M000065.html +3 -3
  71. data/doc/rdoc/classes/RIO/Rio.src/M000066.html +3 -3
  72. data/doc/rdoc/classes/RIO/Rio.src/M000067.html +3 -3
  73. data/doc/rdoc/classes/RIO/Rio.src/M000068.html +3 -3
  74. data/doc/rdoc/classes/RIO/Rio.src/M000069.html +3 -3
  75. data/doc/rdoc/classes/RIO/Rio.src/M000070.html +3 -3
  76. data/doc/rdoc/classes/RIO/Rio.src/M000071.html +3 -3
  77. data/doc/rdoc/classes/RIO/Rio.src/M000072.html +3 -3
  78. data/doc/rdoc/classes/RIO/Rio.src/M000073.html +3 -3
  79. data/doc/rdoc/classes/RIO/Rio.src/M000074.html +3 -3
  80. data/doc/rdoc/classes/RIO/Rio.src/M000075.html +3 -3
  81. data/doc/rdoc/classes/RIO/Rio.src/M000076.html +3 -3
  82. data/doc/rdoc/classes/RIO/Rio.src/M000077.html +3 -3
  83. data/doc/rdoc/classes/RIO/Rio.src/M000078.html +3 -3
  84. data/doc/rdoc/classes/RIO/Rio.src/M000079.html +3 -3
  85. data/doc/rdoc/classes/RIO/Rio.src/M000080.html +3 -3
  86. data/doc/rdoc/classes/RIO/Rio.src/M000081.html +3 -3
  87. data/doc/rdoc/classes/RIO/Rio.src/M000082.html +3 -3
  88. data/doc/rdoc/classes/RIO/Rio.src/M000083.html +3 -3
  89. data/doc/rdoc/classes/RIO/Rio.src/M000084.html +3 -3
  90. data/doc/rdoc/classes/RIO/Rio.src/M000085.html +3 -3
  91. data/doc/rdoc/classes/RIO/Rio.src/M000086.html +3 -3
  92. data/doc/rdoc/classes/RIO/Rio.src/M000087.html +3 -3
  93. data/doc/rdoc/classes/RIO/Rio.src/M000088.html +3 -3
  94. data/doc/rdoc/classes/RIO/Rio.src/M000089.html +2 -2
  95. data/doc/rdoc/classes/RIO/Rio.src/M000090.html +2 -2
  96. data/doc/rdoc/classes/RIO/Rio.src/M000091.html +2 -2
  97. data/doc/rdoc/classes/RIO/Rio.src/M000092.html +2 -2
  98. data/doc/rdoc/classes/RIO/Rio.src/M000093.html +2 -2
  99. data/doc/rdoc/classes/RIO/Rio.src/M000094.html +2 -2
  100. data/doc/rdoc/classes/RIO/Rio.src/M000095.html +2 -2
  101. data/doc/rdoc/classes/RIO/Rio.src/M000096.html +2 -2
  102. data/doc/rdoc/classes/RIO/Rio.src/M000097.html +2 -2
  103. data/doc/rdoc/classes/RIO/Rio.src/M000098.html +2 -2
  104. data/doc/rdoc/classes/RIO/Rio.src/M000099.html +2 -2
  105. data/doc/rdoc/classes/RIO/Rio.src/M000100.html +2 -2
  106. data/doc/rdoc/classes/RIO/Rio.src/M000101.html +2 -2
  107. data/doc/rdoc/classes/RIO/Rio.src/M000102.html +2 -2
  108. data/doc/rdoc/classes/RIO/Rio.src/M000103.html +2 -2
  109. data/doc/rdoc/classes/RIO/Rio.src/M000104.html +2 -2
  110. data/doc/rdoc/classes/RIO/Rio.src/M000105.html +2 -2
  111. data/doc/rdoc/classes/RIO/Rio.src/M000106.html +2 -2
  112. data/doc/rdoc/classes/RIO/Rio.src/M000107.html +2 -2
  113. data/doc/rdoc/classes/RIO/Rio.src/M000108.html +3 -3
  114. data/doc/rdoc/classes/RIO/Rio.src/M000109.html +3 -3
  115. data/doc/rdoc/classes/RIO/Rio.src/M000110.html +3 -3
  116. data/doc/rdoc/classes/RIO/Rio.src/M000111.html +3 -3
  117. data/doc/rdoc/classes/RIO/Rio.src/M000112.html +3 -3
  118. data/doc/rdoc/classes/RIO/Rio.src/M000113.html +3 -3
  119. data/doc/rdoc/classes/RIO/Rio.src/M000114.html +3 -3
  120. data/doc/rdoc/classes/RIO/Rio.src/M000115.html +3 -3
  121. data/doc/rdoc/classes/RIO/Rio.src/M000116.html +3 -3
  122. data/doc/rdoc/classes/RIO/Rio.src/M000117.html +3 -3
  123. data/doc/rdoc/classes/RIO/Rio.src/M000118.html +3 -3
  124. data/doc/rdoc/classes/RIO/Rio.src/M000119.html +3 -3
  125. data/doc/rdoc/classes/RIO/Rio.src/M000120.html +3 -3
  126. data/doc/rdoc/classes/RIO/Rio.src/M000121.html +3 -3
  127. data/doc/rdoc/classes/RIO/Rio.src/M000122.html +3 -3
  128. data/doc/rdoc/classes/RIO/Rio.src/M000123.html +3 -3
  129. data/doc/rdoc/classes/RIO/Rio.src/M000124.html +3 -3
  130. data/doc/rdoc/classes/RIO/Rio.src/M000125.html +3 -3
  131. data/doc/rdoc/classes/RIO/Rio.src/M000126.html +3 -3
  132. data/doc/rdoc/classes/RIO/Rio.src/M000127.html +3 -3
  133. data/doc/rdoc/classes/RIO/Rio.src/M000128.html +3 -3
  134. data/doc/rdoc/classes/RIO/Rio.src/M000129.html +3 -3
  135. data/doc/rdoc/classes/RIO/Rio.src/M000130.html +3 -3
  136. data/doc/rdoc/classes/RIO/Rio.src/M000131.html +3 -3
  137. data/doc/rdoc/classes/RIO/Rio.src/M000132.html +3 -3
  138. data/doc/rdoc/classes/RIO/Rio.src/M000133.html +3 -3
  139. data/doc/rdoc/classes/RIO/Rio.src/M000134.html +3 -3
  140. data/doc/rdoc/classes/RIO/Rio.src/M000135.html +3 -3
  141. data/doc/rdoc/classes/RIO/Rio.src/M000136.html +3 -3
  142. data/doc/rdoc/classes/RIO/Rio.src/M000137.html +3 -3
  143. data/doc/rdoc/classes/RIO/Rio.src/M000138.html +3 -3
  144. data/doc/rdoc/classes/RIO/Rio.src/M000139.html +3 -3
  145. data/doc/rdoc/classes/RIO/Rio.src/M000140.html +3 -3
  146. data/doc/rdoc/classes/RIO/Rio.src/M000141.html +3 -3
  147. data/doc/rdoc/classes/RIO/Rio.src/M000142.html +3 -3
  148. data/doc/rdoc/classes/RIO/Rio.src/M000143.html +3 -3
  149. data/doc/rdoc/classes/RIO/Rio.src/M000144.html +3 -3
  150. data/doc/rdoc/classes/RIO/Rio.src/M000145.html +3 -3
  151. data/doc/rdoc/classes/RIO/Rio.src/M000146.html +3 -3
  152. data/doc/rdoc/classes/RIO/Rio.src/M000147.html +3 -3
  153. data/doc/rdoc/classes/RIO/Rio.src/M000148.html +3 -3
  154. data/doc/rdoc/classes/RIO/Rio.src/M000149.html +3 -3
  155. data/doc/rdoc/classes/RIO/Rio.src/M000150.html +3 -3
  156. data/doc/rdoc/classes/RIO/Rio.src/M000151.html +3 -3
  157. data/doc/rdoc/classes/RIO/Rio.src/M000152.html +3 -3
  158. data/doc/rdoc/classes/RIO/Rio.src/M000153.html +3 -3
  159. data/doc/rdoc/classes/RIO/Rio.src/M000154.html +3 -3
  160. data/doc/rdoc/classes/RIO/Rio.src/M000155.html +3 -3
  161. data/doc/rdoc/classes/RIO/Rio.src/M000156.html +3 -3
  162. data/doc/rdoc/classes/RIO/Rio.src/M000157.html +3 -3
  163. data/doc/rdoc/classes/RIO/Rio.src/M000158.html +3 -3
  164. data/doc/rdoc/classes/RIO/Rio.src/M000159.html +3 -3
  165. data/doc/rdoc/classes/RIO/Rio.src/M000160.html +3 -3
  166. data/doc/rdoc/classes/RIO/Rio.src/M000161.html +3 -3
  167. data/doc/rdoc/classes/RIO/Rio.src/M000162.html +3 -3
  168. data/doc/rdoc/classes/RIO/Rio.src/M000163.html +3 -3
  169. data/doc/rdoc/classes/RIO/Rio.src/M000164.html +3 -3
  170. data/doc/rdoc/classes/RIO/Rio.src/M000165.html +3 -3
  171. data/doc/rdoc/classes/RIO/Rio.src/M000166.html +3 -3
  172. data/doc/rdoc/classes/RIO/Rio.src/M000167.html +3 -3
  173. data/doc/rdoc/classes/RIO/Rio.src/M000168.html +3 -3
  174. data/doc/rdoc/classes/RIO/Rio.src/M000169.html +3 -3
  175. data/doc/rdoc/classes/RIO/Rio.src/M000170.html +3 -3
  176. data/doc/rdoc/classes/RIO/Rio.src/M000171.html +3 -3
  177. data/doc/rdoc/classes/RIO/Rio.src/M000172.html +3 -3
  178. data/doc/rdoc/classes/RIO/Rio.src/M000173.html +3 -3
  179. data/doc/rdoc/classes/RIO/Rio.src/M000174.html +3 -3
  180. data/doc/rdoc/classes/RIO/Rio.src/M000175.html +3 -3
  181. data/doc/rdoc/classes/RIO/Rio.src/M000176.html +3 -3
  182. data/doc/rdoc/classes/RIO/Rio.src/M000177.html +3 -3
  183. data/doc/rdoc/classes/RIO/Rio.src/M000178.html +3 -3
  184. data/doc/rdoc/classes/RIO/Rio.src/M000179.html +3 -3
  185. data/doc/rdoc/classes/RIO/Rio.src/M000180.html +3 -3
  186. data/doc/rdoc/classes/RIO/Rio.src/M000181.html +3 -3
  187. data/doc/rdoc/created.rid +1 -1
  188. data/doc/rdoc/files/lib/rio/constructor_rb.html +1 -1
  189. data/doc/rdoc/files/lib/rio/doc/HOWTO_rb.html +1 -1
  190. data/doc/rdoc/files/lib/rio/doc/INTRO_rb.html +1 -1
  191. data/doc/rdoc/files/lib/rio/doc/SYNOPSIS_rb.html +1 -1
  192. data/doc/rdoc/files/lib/rio/if/basic_rb.html +1 -1
  193. data/doc/rdoc/files/lib/rio/if/path_rb.html +1 -1
  194. data/doc/rdoc/files/lib/rio_rb.html +1 -1
  195. data/doc/rdoc/fr_method_index.html +154 -155
  196. data/ex/findinruby +7 -3
  197. data/ex/findruby +6 -2
  198. data/lib/rio.rb +1 -1
  199. data/lib/rio/argv.rb +4 -0
  200. data/lib/rio/constructor.rb +17 -0
  201. data/lib/rio/context.rb +1 -1
  202. data/lib/rio/context/dir.rb +1 -0
  203. data/lib/rio/context/methods.rb +3 -3
  204. data/lib/rio/dir.rb +2 -2
  205. data/lib/rio/doc/HOWTO.rb +11 -6
  206. data/lib/rio/doc/INTRO.rb +149 -12
  207. data/lib/rio/doc/SYNOPSIS.rb +26 -13
  208. data/lib/rio/factory.rb +13 -2
  209. data/lib/rio/grande.rb +25 -0
  210. data/lib/rio/if/basic.rb +1 -1
  211. data/lib/rio/if/path.rb +61 -35
  212. data/lib/rio/matchrecord.rb +20 -1
  213. data/lib/rio/ops/dir.rb +2 -3
  214. data/lib/rio/ops/path.rb +25 -11
  215. data/lib/rio/ops/stream/input.rb +6 -3
  216. data/lib/rio/rl/base.rb +3 -2
  217. data/lib/rio/rl/ioi.rb +2 -1
  218. data/lib/rio/rl/path.rb +18 -3
  219. data/lib/rio/rl/uri.rb +8 -4
  220. data/lib/rio/scheme/cmdio.rb +1 -1
  221. data/lib/rio/scheme/path.rb +1 -0
  222. data/lib/rio/scheme/stdio.rb +1 -1
  223. data/lib/rio/scheme/strio.rb +1 -1
  224. data/lib/rio/scheme/sysio.rb +1 -1
  225. data/lib/rio/scheme/tcp.rb +1 -0
  226. data/lib/rio/scheme/temp.rb +184 -0
  227. data/lib/rio/state.rb +17 -6
  228. data/lib/rio/stream.rb +1 -1
  229. data/lib/rio/stream/open.rb +1 -1
  230. data/lib/rio/tempdir.rb +132 -0
  231. data/lib/rio/version.rb +1 -1
  232. data/test/tc/all.rb +4 -0
  233. data/test/tc/copylines.rb +38 -32
  234. data/test/tc/riorl.rb +104 -0
  235. data/test/tc/temp.rb +155 -0
  236. data/test/tc/tempdir.rb +63 -0
  237. data/test/tc/tempfile.rb +38 -0
  238. metadata +10 -5
  239. data/doc/rdoc/classes/RIO/Rio.src/M000182.html +0 -16
  240. data/lib/rio/scheme/tempfile.rb +0 -104
data/lib/rio/version.rb CHANGED
@@ -39,7 +39,7 @@
39
39
  module RIO
40
40
  # :stopdoc:
41
41
  module Version #:nodoc: all
42
- VERSION = '0.3.1'
42
+ VERSION = '0.3.2'
43
43
 
44
44
  N = VERSION.split('.').freeze
45
45
  MAJOR = N[0].freeze
data/test/tc/all.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  require 'test/unit'
2
2
  require 'tc/testcase'
3
+ require 'tc/temp'
4
+ require 'tc/tempfile'
5
+ require 'tc/tempdir'
6
+ require 'tc/riorl'
3
7
  require 'tc/abs'
4
8
  require 'tc/closeoneof'
5
9
  require 'tc/clearsel'
data/test/tc/copylines.rb CHANGED
@@ -3,38 +3,44 @@ if $0 == __FILE__
3
3
  Dir.chdir File.dirname(__FILE__)+'/../'
4
4
  $:.unshift File.expand_path('../lib/')
5
5
  end
6
+
6
7
  require 'rio'
7
- require 'test/unit'
8
- class TC_RIO_copylines < Test::Unit::TestCase
9
- def test_copylines
10
- qp = RIO.rio('qp')
11
- rio(qp,'test_copylines').rmtree.mkpath.chdir {
12
- str = 'peter piper picked a peck of pickled peppers'
13
- words = str.split(/\s+/)
14
- line = words.map { |w| w+"\n" }.join('')
15
- src = rio('src').print!(line)
16
-
17
- #$trace_states = true
18
- out = rio('$')
19
- rio('src').chomp.lines(/^[^p]/) > out
20
- out.close
21
- $trace_states = false
22
- assert_equal('aof',out.contents)
23
-
24
- out < rio('src').lines(/^[^p]/)
25
- assert_equal("a\nof\n",out.contents)
26
-
27
- aout = Array.new
28
- rio('src').chomp.lines(1,4..6) > aout
29
- assert_equal(%w{piper peck of pickled},aout)
30
-
31
- out < rio('src').chomp.lines(0..1)
32
- assert_equal("peterpiper",out.contents)
33
-
34
- rio('src').chomp.lines(0..1) > aout
35
- assert_equal(%w{peter piper},aout)
36
- rio('src').chomp.lines(0..1) >> aout
37
- assert_equal(%w{peter piper peter piper},aout)
38
- }
8
+ require 'tc/testcase'
9
+
10
+ class TC_copylines < Test::RIO::TestCase
11
+ @@once = false
12
+ STR = 'peter piper picked a peck of pickled peppers'
13
+ WORDS = STR.split(/\s+/)
14
+ LINE = WORDS.map { |w| w+"\n" }.join('')
15
+ def self.once
16
+ @@once = true
17
+ src = rio('src').print!(LINE)
18
+ end
19
+ def setup
20
+ super
21
+ self.class.once unless @@once
22
+ end
23
+ def test_basic
24
+ out = rio(?")
25
+ rio('src').chomp.lines(/^[^p]/) > out
26
+ assert(out.closed?, "copy closed")
27
+
28
+ assert_equal('aof',out.contents)
29
+
30
+ out < rio('src').lines(/^[^p]/)
31
+ assert_equal("a\nof\n",out.contents)
32
+
33
+ aout = Array.new
34
+ rio('src').chomp.lines(1,4..6) > aout
35
+ assert_equal(%w{piper peck of pickled},aout)
36
+
37
+ out < rio('src').chomp.lines(0..1)
38
+ assert_equal("peterpiper",out.contents)
39
+
40
+ rio('src').chomp.lines(0..1) > aout
41
+ assert_equal(%w{peter piper},aout)
42
+
43
+ rio('src').chomp.lines(0..1) >> aout
44
+ assert_equal(%w{peter piper peter piper},aout)
39
45
  end
40
46
  end
data/test/tc/riorl.rb ADDED
@@ -0,0 +1,104 @@
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 'test/unit'
9
+ require 'test/unit/testsuite'
10
+ require 'extensions/symbol'
11
+ require 'tc/testcase'
12
+ require 'tmpdir'
13
+
14
+ class TC_riorl < Test::RIO::TestCase
15
+ @@once = false
16
+ def self.once
17
+ @@once = true
18
+ end
19
+ def setup
20
+ super
21
+ self.class.once unless @@once
22
+ @tmpdir = "#{::Dir::tmpdir}"
23
+ @tmppath = "#{@tmpdir}/rio"
24
+ end
25
+
26
+ def pathinfo(ario)
27
+ h = {}
28
+ [:scheme,:opaque,:path,:fspath,:to_s,:to_url,:to_uri].each do |sym|
29
+ begin
30
+ h[sym] = ario.__send__(sym)
31
+ rescue
32
+ h[sym] = 'error'
33
+ end
34
+ end
35
+ h
36
+ end
37
+ def pinfo(fmt,pi)
38
+ printf(fmt, pi[:scheme].inspect,pi[:opaque].inspect,pi[:path].inspect,
39
+ pi[:fspath].inspect,pi[:to_s].inspect,pi[:to_url].inspect)
40
+ end
41
+ def mkrios1()
42
+ rinfo = {
43
+ ?- => ['stdio',"",nil,nil,"stdio:","stdio:"],
44
+ ?= => ['stderr',"",nil,nil,"stderr:","stderr:"],
45
+ ?" => ['strio',"",nil,nil,"strio:","strio:"],
46
+ ?? => ['temp',@tmppath,nil,nil,"temp:#{@tmppath}","temp:#{@tmppath}"],
47
+ }
48
+ siopq = sprintf("0x%08x",$stdout.object_id)
49
+ rinfo[?_] = ['sysio',siopq,nil,nil,"sysio:#{siopq}","sysio:#{siopq}"]
50
+ rinfo[?`] = ['cmdio','echo%20x',nil,nil,'echo x','cmdio:echo%20x']
51
+ rinfo[?#] = ['fd','1',nil,nil,'fd:1','fd:1']
52
+ rios = {
53
+ ?- => rio(?-),
54
+ ?= => rio(?=),
55
+ ?" => rio(?"),
56
+ ?? => rio(??),
57
+ ?_ => rio($stdout),
58
+ ?` => rio(?`,'echo x'),
59
+ ?# => rio(?#,1),
60
+ }
61
+ [rios,rinfo]
62
+ end
63
+ def mkrios2()
64
+ rinfo = {
65
+ ?- => ['stdout',/^$/,nil,nil,/^stdout:$/,/^stdout:$/],
66
+ ?? => ['file',%r|//#{@tmppath}\d+\.\d+|,%r|#{@tmppath}\d+\.\d+|,%r|#{@tmppath}\d+\.\d+|,/#{@tmppath}\d+\.\d+/,/#{@tmppath}\d+\.\d+/],
67
+ }
68
+ siopq = sprintf("0x%08x",$stdout.object_id)
69
+ rios = {
70
+ ?- => rio(?-).print("."),
71
+ ?? => rio(??).puts("hw"),
72
+ }
73
+ [rios,rinfo]
74
+ end
75
+ def test_specialpaths
76
+ fmt = "%-12s %-12s %-8s %-8s %-20s %-20s\n"
77
+ #printf(fmt,'scheme','opaque','path','fspath','to_s','url')
78
+ rios,rinfo = mkrios1()
79
+ rios.each do |k,r|
80
+ #pinfo(fmt,pathinfo(r))
81
+ assert_equal(r.scheme,rinfo[k][0])
82
+ assert_equal(r.opaque,rinfo[k][1])
83
+ assert_equal(r.path,rinfo[k][2])
84
+ assert_equal(r.fspath,rinfo[k][3])
85
+ assert_equal(r.to_s,rinfo[k][4])
86
+ assert_equal(r.to_url,rinfo[k][5])
87
+ end
88
+ end
89
+
90
+ def test_specialpaths_op
91
+ fmt = "%-12s %-12s %-8s %-8s %-20s %-20s\n"
92
+ #printf(fmt,'scheme','opaque','path','fspath','to_s','url')
93
+ rios,rinfo = mkrios2()
94
+ rios.each do |k,r|
95
+ #pinfo(fmt,pathinfo(r))
96
+ assert_equal(rinfo[k][0],r.scheme)
97
+ assert(r.opaque =~ rinfo[k][1])
98
+ assert(r.to_s =~ rinfo[k][4])
99
+ assert(r.to_url =~ rinfo[k][5])
100
+ end
101
+ assert(rinfo[??][2] =~ rios[??].path)
102
+ assert(rinfo[??][3] =~ rios[??].fspath)
103
+ end
104
+ end
data/test/tc/temp.rb ADDED
@@ -0,0 +1,155 @@
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 'test/unit'
9
+ require 'test/unit/testsuite'
10
+ require 'extensions/symbol'
11
+ require 'tc/testcase'
12
+ require 'tmpdir'
13
+
14
+ class TC_tempfile < Test::RIO::TestCase
15
+ @@once = false
16
+ def self.once
17
+ @@once = true
18
+ end
19
+ def setup
20
+ super
21
+ self.class.once unless @@once
22
+ @tmpdir = ::Dir::tmpdir
23
+ @pfx = 'rio'
24
+ end
25
+
26
+ def pathinfo(ario)
27
+ [:scheme,:opaque,:path,:fspath,:to_s,:to_url,:to_uri].each do |sym|
28
+ puts "#{sym}: #{ario.__send__(sym)}"
29
+ end
30
+ end
31
+
32
+ def test_new
33
+ tmp = rio(??)
34
+ assert_equal('temp',tmp.scheme)
35
+ assert_equal(::Dir::tmpdir,tmp.dirname.to_s)
36
+ assert_match(/^rio/,tmp.filename.to_s)
37
+ end
38
+
39
+ def test_dir
40
+ tmp = rio(??).dir
41
+ assert(tmp.dir?)
42
+ assert_equal('file',tmp.scheme)
43
+ assert_equal(::Dir::tmpdir,tmp.dirname.to_s)
44
+ assert_match(/^rio/,tmp.filename.to_s)
45
+ tmp.close
46
+ end
47
+
48
+ def test_dir_chdir
49
+ rio(??).chdir { |tmp|
50
+ assert(tmp.dir?)
51
+ assert_equal('path',tmp.scheme)
52
+ assert_equal('.',tmp.dirname.to_s)
53
+ assert_equal('.',tmp.filename.to_s)
54
+ tmp.close
55
+ }
56
+ end
57
+ # def test_dir_chdir2
58
+ # tmp = rio(??).chdir
59
+ # assert(tmp.dir?)
60
+ # assert_equal('path',tmp.scheme)
61
+ # assert_equal('.',tmp.dirname.to_s)
62
+ # assert_equal('.',tmp.filename.to_s)
63
+ # tmp.close
64
+ # end
65
+ def test_dir_mkdir
66
+ tmp = rio(??).mkdir
67
+ assert(tmp.dir?)
68
+ assert_equal('file',tmp.scheme)
69
+ assert_equal(::Dir::tmpdir,tmp.dirname.to_s)
70
+ assert_match(/^rio/,tmp.filename.to_s)
71
+ tmp.close
72
+ end
73
+
74
+ def test_file
75
+ tmp = rio(??).file
76
+ assert(tmp.file?)
77
+ assert_equal('file',tmp.scheme)
78
+ assert_equal(::Dir::tmpdir,tmp.dirname.to_s)
79
+ assert_match(/^rio/,tmp.filename.to_s)
80
+ tmp.close
81
+ end
82
+
83
+ def test_dir_prefix
84
+ tmp = rio(??,'zippy').dir
85
+ assert(tmp.dir?)
86
+ assert_match(/^zippy/,tmp.filename.to_s)
87
+ assert_equal(::Dir::tmpdir,tmp.dirname.to_s)
88
+ tmp.close
89
+ end
90
+
91
+ def test_file_prefix
92
+ tmp = rio(??,'zippy').file
93
+ assert(tmp.file?)
94
+ assert_match(/^zippy/,tmp.filename.to_s)
95
+ assert_equal(::Dir::tmpdir,tmp.dirname.to_s)
96
+ tmp.close
97
+ end
98
+
99
+ def test_dir_tmpdir
100
+ rio('riotmpdir').delete!.mkdir
101
+ tmp = rio(??,'zippy','riotmpdir').dir
102
+ assert_match(/^zippy/,tmp.filename.to_s)
103
+ assert_match('riotmpdir',tmp.dirname.to_s)
104
+ tmp.close
105
+ end
106
+
107
+ def test_file_tmpdir
108
+ rio('riotmpdir').delete!.mkdir
109
+ tmp = rio(??,'zippy','riotmpdir').file
110
+ assert_match(/^zippy/,tmp.filename.to_s)
111
+ assert_match('riotmpdir',tmp.dirname.to_s)
112
+ tmp.close
113
+ end
114
+
115
+ def test_dir_prefix_url
116
+ tmp = rio('temp:zippy').dir
117
+ assert_match(/^zippy/,tmp.filename.to_s)
118
+ tmp.close
119
+ end
120
+
121
+ def test_file_prefix_url
122
+ tmp = rio('temp:zippy').file
123
+ assert_match(/^zippy/,tmp.filename.to_s)
124
+ tmp.close
125
+ end
126
+
127
+ def test_dir_tmpdir_url
128
+ rio('riotmpdir').delete!.mkdir
129
+ tmp = rio('temp:riotmpdir/zippy').dir
130
+ assert(tmp.dir?)
131
+ assert_match(/^zippy/,tmp.filename.to_s)
132
+ assert_match('riotmpdir',tmp.dirname.to_s)
133
+ tmp.close
134
+ end
135
+
136
+ def test_file_tmpdir_url
137
+ rio('riotmpdir').delete!.mkdir
138
+ tmp = rio('temp:riotmpdir/zippy').file
139
+ assert(tmp.file?)
140
+ assert_match(/^zippy/,tmp.filename.to_s)
141
+ assert_match('riotmpdir',tmp.dirname.to_s)
142
+ tmp.close
143
+ end
144
+
145
+ def test_file_write
146
+ rio('riotmpdir').delete!.mkdir
147
+ tmp = rio('temp:riotmpdir/zippy')
148
+ tmp.puts("Hello Tempfile")
149
+ assert(tmp.file?)
150
+ assert(tmp.open?)
151
+ tmp.close
152
+ end
153
+
154
+
155
+ end
@@ -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 'test/unit'
9
+ require 'test/unit/testsuite'
10
+ require 'extensions/symbol'
11
+ require 'tc/testcase'
12
+ require 'tmpdir'
13
+
14
+ class TC_tempfile < Test::RIO::TestCase
15
+ @@once = false
16
+ def self.once
17
+ @@once = true
18
+ end
19
+ def setup
20
+ super
21
+ self.class.once unless @@once
22
+ @tmpdir = ::Dir::tmpdir
23
+ @pfx = 'rio'
24
+ end
25
+
26
+ def pathinfo(ario)
27
+ [:scheme,:opaque,:path,:fspath,:to_s,:to_url,:to_uri].each do |sym|
28
+ puts "#{sym}: #{ario.__send__(sym)}"
29
+ end
30
+ end
31
+
32
+ def test_new
33
+ tmpdir = rio('tempdir:')
34
+ assert(tmpdir.dir?)
35
+ assert_equal(::Dir::tmpdir,tmpdir.dirname.to_s)
36
+ end
37
+
38
+ def test_prefix
39
+ tmpdir = rio('tempdir:','zippy')
40
+ assert_match(/^zippy/,tmpdir.filename.to_s)
41
+ end
42
+
43
+ def test_tmpdir
44
+ rio('riotmpdir').delete!.mkdir
45
+ tmpdir = rio('tempdir:','zippy','riotmpdir')
46
+ assert_match(/^zippy/,tmpdir.filename.to_s)
47
+ assert_match('riotmpdir',tmpdir.dirname.to_s)
48
+ end
49
+
50
+ def test_prefix_url
51
+ tmpdir = rio('tempdir:zippy')
52
+ assert_match(/^zippy/,tmpdir.filename.to_s)
53
+ end
54
+
55
+ def test_tmpdir_url
56
+ rio('riotmpdir').delete!.mkdir
57
+ tmpdir = rio('tempdir:riotmpdir/zippy')
58
+ assert_match(/^zippy/,tmpdir.filename.to_s)
59
+ assert_match('riotmpdir',tmpdir.dirname.to_s)
60
+ end
61
+
62
+
63
+ end
@@ -0,0 +1,38 @@
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 'test/unit'
9
+ require 'test/unit/testsuite'
10
+ require 'extensions/symbol'
11
+ require 'tc/testcase'
12
+ require 'tmpdir'
13
+
14
+ class TC_tempfile < Test::RIO::TestCase
15
+ @@once = false
16
+ def self.once
17
+ @@once = true
18
+ end
19
+ def setup
20
+ super
21
+ self.class.once unless @@once
22
+ @tmpdir = ::Dir::tmpdir
23
+ @pfx = 'rio'
24
+ end
25
+
26
+ def pathinfo(ario)
27
+ [:scheme,:opaque,:path,:fspath,:to_s,:to_url,:to_uri].each do |sym|
28
+ puts "#{sym}: #{ario.__send__(sym)}"
29
+ end
30
+ end
31
+
32
+ def test_io
33
+ str = "Hello Tempfile"
34
+ assert_equal(str,rio(??).puts(str).rewind.chomp.gets)
35
+ end
36
+
37
+
38
+ end