rio 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +140 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/doc/ANNOUNCE +87 -0
- data/doc/RELEASE_NOTES +7 -0
- data/doc/rdoc/classes/Kernel.html +9 -9
- data/doc/rdoc/classes/Kernel.src/{M000183.html → M000182.html} +0 -0
- data/doc/rdoc/classes/RIO.html +35 -0
- data/doc/rdoc/classes/RIO.src/M000001.html +4 -4
- data/doc/rdoc/classes/RIO.src/M000002.html +4 -4
- data/doc/rdoc/classes/RIO.src/M000003.html +4 -4
- data/doc/rdoc/classes/RIO/Doc/HOWTO.html +11 -7
- data/doc/rdoc/classes/RIO/Doc/INTRO.html +255 -36
- data/doc/rdoc/classes/RIO/Doc/SYNOPSIS.html +47 -17
- data/doc/rdoc/classes/RIO/Rio.html +1032 -1007
- data/doc/rdoc/classes/RIO/Rio.src/M000011.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000012.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000013.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000014.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000015.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000016.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000017.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000018.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000019.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000020.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000021.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000022.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000023.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000024.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000025.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000026.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000027.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000028.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000029.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000030.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000031.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000032.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000033.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000034.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000035.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000036.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000037.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000038.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000039.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000040.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000041.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000042.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000043.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000044.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000045.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000046.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000047.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000048.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000049.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000050.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000051.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000052.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000053.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000054.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000055.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000056.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000057.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000058.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000059.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000060.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000061.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000062.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000063.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000064.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000065.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000066.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000067.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000068.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000069.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000070.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000071.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000072.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000073.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000074.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000075.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000076.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000077.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000078.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000079.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000080.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000081.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000082.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000083.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000084.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000085.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000086.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000087.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000088.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000089.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000090.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000091.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000092.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000093.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000094.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000095.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000096.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000097.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000098.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000099.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000100.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000101.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000102.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000103.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000104.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000105.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000106.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000107.html +2 -2
- data/doc/rdoc/classes/RIO/Rio.src/M000108.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000109.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000110.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000111.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000112.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000113.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000114.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000115.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000116.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000117.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000118.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000119.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000120.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000121.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000122.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000123.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000124.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000125.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000126.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000127.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000128.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000129.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000130.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000131.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000132.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000133.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000134.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000135.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000136.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000137.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000138.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000139.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000140.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000141.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000142.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000143.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000144.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000145.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000146.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000147.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000148.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000149.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000150.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000151.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000152.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000153.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000154.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000155.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000156.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000157.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000158.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000159.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000160.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000161.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000162.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000163.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000164.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000165.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000166.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000167.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000168.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000169.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000170.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000171.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000172.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000173.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000174.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000175.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000176.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000177.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000178.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000179.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000180.html +3 -3
- data/doc/rdoc/classes/RIO/Rio.src/M000181.html +3 -3
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/lib/rio/constructor_rb.html +1 -1
- data/doc/rdoc/files/lib/rio/doc/HOWTO_rb.html +1 -1
- data/doc/rdoc/files/lib/rio/doc/INTRO_rb.html +1 -1
- data/doc/rdoc/files/lib/rio/doc/SYNOPSIS_rb.html +1 -1
- data/doc/rdoc/files/lib/rio/if/basic_rb.html +1 -1
- data/doc/rdoc/files/lib/rio/if/path_rb.html +1 -1
- data/doc/rdoc/files/lib/rio_rb.html +1 -1
- data/doc/rdoc/fr_method_index.html +154 -155
- data/ex/findinruby +7 -3
- data/ex/findruby +6 -2
- data/lib/rio.rb +1 -1
- data/lib/rio/argv.rb +4 -0
- data/lib/rio/constructor.rb +17 -0
- data/lib/rio/context.rb +1 -1
- data/lib/rio/context/dir.rb +1 -0
- data/lib/rio/context/methods.rb +3 -3
- data/lib/rio/dir.rb +2 -2
- data/lib/rio/doc/HOWTO.rb +11 -6
- data/lib/rio/doc/INTRO.rb +149 -12
- data/lib/rio/doc/SYNOPSIS.rb +26 -13
- data/lib/rio/factory.rb +13 -2
- data/lib/rio/grande.rb +25 -0
- data/lib/rio/if/basic.rb +1 -1
- data/lib/rio/if/path.rb +61 -35
- data/lib/rio/matchrecord.rb +20 -1
- data/lib/rio/ops/dir.rb +2 -3
- data/lib/rio/ops/path.rb +25 -11
- data/lib/rio/ops/stream/input.rb +6 -3
- data/lib/rio/rl/base.rb +3 -2
- data/lib/rio/rl/ioi.rb +2 -1
- data/lib/rio/rl/path.rb +18 -3
- data/lib/rio/rl/uri.rb +8 -4
- data/lib/rio/scheme/cmdio.rb +1 -1
- data/lib/rio/scheme/path.rb +1 -0
- data/lib/rio/scheme/stdio.rb +1 -1
- data/lib/rio/scheme/strio.rb +1 -1
- data/lib/rio/scheme/sysio.rb +1 -1
- data/lib/rio/scheme/tcp.rb +1 -0
- data/lib/rio/scheme/temp.rb +184 -0
- data/lib/rio/state.rb +17 -6
- data/lib/rio/stream.rb +1 -1
- data/lib/rio/stream/open.rb +1 -1
- data/lib/rio/tempdir.rb +132 -0
- data/lib/rio/version.rb +1 -1
- data/test/tc/all.rb +4 -0
- data/test/tc/copylines.rb +38 -32
- data/test/tc/riorl.rb +104 -0
- data/test/tc/temp.rb +155 -0
- data/test/tc/tempdir.rb +63 -0
- data/test/tc/tempfile.rb +38 -0
- metadata +10 -5
- data/doc/rdoc/classes/RIO/Rio.src/M000182.html +0 -16
- data/lib/rio/scheme/tempfile.rb +0 -104
data/lib/rio/version.rb
CHANGED
data/test/tc/all.rb
CHANGED
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 '
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
data/test/tc/tempdir.rb
ADDED
@@ -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
|
data/test/tc/tempfile.rb
ADDED
@@ -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
|