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/rl/uri.rb
CHANGED
@@ -45,7 +45,7 @@ module RIO
|
|
45
45
|
#p callstr('initialize',u,*args)
|
46
46
|
# u should be a ::URI or something that can be parsed to one
|
47
47
|
args = get_base(*args)
|
48
|
-
@uri =
|
48
|
+
@uri = _mkuri(u)
|
49
49
|
self.join(*args)
|
50
50
|
@uri.path = '/' if @uri.absolute? and @uri.path == ''
|
51
51
|
end
|
@@ -56,6 +56,13 @@ module RIO
|
|
56
56
|
@uri = @uri.clone unless @uri.nil?
|
57
57
|
@base = @base.clone unless @base.nil?
|
58
58
|
end
|
59
|
+
def _mkuri(arg)
|
60
|
+
(arg.kind_of?(::URI) ? arg.dup : parse_url(arg.to_s))
|
61
|
+
end
|
62
|
+
def base(arg=nil)
|
63
|
+
@base = _mkuri(arg) unless arg.nil? or @uri.absolute?
|
64
|
+
(@base.nil? ? @uri : @base)
|
65
|
+
end
|
59
66
|
def join(*args)
|
60
67
|
# self.class.joinuri(self.uri,*args)
|
61
68
|
return @uri if args.empty?
|
@@ -83,9 +90,6 @@ module RIO
|
|
83
90
|
def merge(other)
|
84
91
|
self.class.new(@uri.merge(other.uri))
|
85
92
|
end
|
86
|
-
def base()
|
87
|
-
(@base.nil? ? @uri : @base)
|
88
|
-
end
|
89
93
|
def get_base(*args)
|
90
94
|
# args.each { |a| p "get_base len=#{args.length} #{a.class}##{a.to_s}" }
|
91
95
|
@base = nil
|
data/lib/rio/scheme/cmdio.rb
CHANGED
data/lib/rio/scheme/path.rb
CHANGED
data/lib/rio/scheme/stdio.rb
CHANGED
data/lib/rio/scheme/strio.rb
CHANGED
data/lib/rio/scheme/sysio.rb
CHANGED
@@ -42,7 +42,7 @@ module RIO
|
|
42
42
|
|
43
43
|
class RL < RL::SysIOBase
|
44
44
|
RIOSCHEME = 'sysio'
|
45
|
-
RIOPATH = RIO::RL::CHMAP.invert[RIOSCHEME].freeze
|
45
|
+
RIOPATH = RIO::RL::CHMAP.invert[RIOSCHEME].to_s.freeze
|
46
46
|
def opaque() sprintf('0x%08x',self.ios.object_id) end
|
47
47
|
# must be able to process both
|
48
48
|
# parse('rio:sysio',ios)
|
data/lib/rio/scheme/tcp.rb
CHANGED
@@ -0,0 +1,184 @@
|
|
1
|
+
#--
|
2
|
+
# ===============================================================================
|
3
|
+
# Copyright (c) 2005, Christopher Kleckner
|
4
|
+
# All rights reserved
|
5
|
+
#
|
6
|
+
# This file is part of the Rio library for ruby.
|
7
|
+
#
|
8
|
+
# Rio is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# Rio is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with Rio; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
# ===============================================================================
|
22
|
+
#++
|
23
|
+
#
|
24
|
+
# To create the documentation for Rio run the command
|
25
|
+
# rake rdoc
|
26
|
+
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
|
+
#
|
28
|
+
# Suggested Reading
|
29
|
+
# * RIO::Doc::SYNOPSIS
|
30
|
+
# * RIO::Doc::INTRO
|
31
|
+
# * RIO::Doc::HOWTO
|
32
|
+
# * RIO::Rio
|
33
|
+
#
|
34
|
+
# <b>Rio is pre-alpha software.
|
35
|
+
# The documented interface and behavior is subject to change without notice.</b>
|
36
|
+
#
|
37
|
+
require 'tmpdir'
|
38
|
+
module RIO
|
39
|
+
module Temp
|
40
|
+
RESET_STATE = 'Temp::Reset'
|
41
|
+
|
42
|
+
require 'rio/rl/base'
|
43
|
+
class RL < RL::Base
|
44
|
+
RIOSCHEME = 'temp'
|
45
|
+
RIOPATH = RIO::RL::CHMAP.invert[RIOSCHEME].to_s.freeze
|
46
|
+
DFLT_PREFIX = 'rio'
|
47
|
+
DFLT_TMPDIR = ::Dir::tmpdir
|
48
|
+
attr_reader :prefix,:tmpdir
|
49
|
+
def initialize(file_prefix=DFLT_PREFIX,temp_dir=DFLT_TMPDIR)
|
50
|
+
#puts "initialize(#{file_prefix.inspect},#{temp_dir.inspect})"
|
51
|
+
@prefix = file_prefix || DFLT_PREFIX
|
52
|
+
@tmpdir = temp_dir || DFLT_TMPDIR
|
53
|
+
end
|
54
|
+
#def path() nil end
|
55
|
+
def scheme() self.class.const_get(:RIOSCHEME) end
|
56
|
+
def opaque()
|
57
|
+
td = @tmpdir.to_s
|
58
|
+
td += '/' unless td.nil? or td.empty? or (td.ends_with?('/') and td != '/')
|
59
|
+
td+@prefix
|
60
|
+
end
|
61
|
+
|
62
|
+
SPLIT_RE = %r|(?:(.*)/)?([^/]*)$|.freeze
|
63
|
+
def self.splitrl(s)
|
64
|
+
sub,opq,whole = split_riorl(s)
|
65
|
+
if opq.nil? or opq.empty?
|
66
|
+
[]
|
67
|
+
elsif bm = SPLIT_RE.match(opq)
|
68
|
+
tdir = bm[1] unless bm[1].nil? or bm[1].empty?
|
69
|
+
tpfx = bm[2] unless bm[2].nil? or bm[2].empty?
|
70
|
+
[tpfx,tdir]
|
71
|
+
else
|
72
|
+
[]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
module Dir
|
77
|
+
require 'rio/rl/path'
|
78
|
+
RESET_STATE = RIO::RL::PathBase::RESET_STATE
|
79
|
+
require 'tmpdir'
|
80
|
+
class RL < RIO::RL::PathBase
|
81
|
+
RIOSCHEME = 'tempdir'
|
82
|
+
DFLT_PREFIX = Temp::RL::DFLT_PREFIX
|
83
|
+
DFLT_TMPDIR = Temp::RL::DFLT_TMPDIR
|
84
|
+
attr_reader :prefix,:tmpdir,:tmprl
|
85
|
+
def initialize(file_prefix=DFLT_PREFIX,temp_dir=DFLT_TMPDIR)
|
86
|
+
#puts "initialize(#{file_prefix.inspect},#{temp_dir.inspect})"
|
87
|
+
@prefix = file_prefix || DFLT_PREFIX
|
88
|
+
@tmpdir = temp_dir || DFLT_TMPDIR
|
89
|
+
require 'rio/tempdir'
|
90
|
+
@td = ::Tempdir.new( @prefix.to_s, @tmpdir.to_s)
|
91
|
+
super(@td.to_s)
|
92
|
+
end
|
93
|
+
SPLIT_RE = Temp::RL::SPLIT_RE
|
94
|
+
def self.splitrl(s)
|
95
|
+
Temp::RL.splitrl(s)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
module File
|
100
|
+
require 'rio/rl/path'
|
101
|
+
RESET_STATE = 'Temp::Stream::Open'
|
102
|
+
class RL < RIO::RL::PathBase
|
103
|
+
RIOSCHEME = 'tempfile'
|
104
|
+
DFLT_PREFIX = Temp::RL::DFLT_PREFIX
|
105
|
+
DFLT_TMPDIR = Temp::RL::DFLT_TMPDIR
|
106
|
+
attr_reader :prefix,:tmpdir,:tmprl
|
107
|
+
def initialize(file_prefix=DFLT_PREFIX,temp_dir=DFLT_TMPDIR)
|
108
|
+
#puts "initialize(#{file_prefix.inspect},#{temp_dir.inspect})"
|
109
|
+
@prefix = file_prefix || DFLT_PREFIX
|
110
|
+
@tmpdir = temp_dir || DFLT_TMPDIR
|
111
|
+
require 'tempfile'
|
112
|
+
@tf = ::Tempfile.new( @prefix.to_s, @tmpdir.to_s)
|
113
|
+
super(@tf.path)
|
114
|
+
end
|
115
|
+
def open(mode='ignored',tf=nil,td=nil)
|
116
|
+
@tf
|
117
|
+
end
|
118
|
+
def close
|
119
|
+
super
|
120
|
+
@tf = nil
|
121
|
+
end
|
122
|
+
SPLIT_RE = Temp::RL::SPLIT_RE
|
123
|
+
def self.splitrl(s)
|
124
|
+
Temp::RL.splitrl(s)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
require 'rio/state'
|
129
|
+
class Reset < State::Base
|
130
|
+
def initialize(*args)
|
131
|
+
super
|
132
|
+
@tempobj = nil
|
133
|
+
end
|
134
|
+
def check?() true end
|
135
|
+
def dir(prefix=rl.prefix,tmpdir=rl.tmpdir)
|
136
|
+
self.rl = RIO::Temp::Dir::RL.new(prefix, tmpdir)
|
137
|
+
become 'Dir::Existing'
|
138
|
+
end
|
139
|
+
def mkdir()
|
140
|
+
dir()
|
141
|
+
end
|
142
|
+
def chdir(&block)
|
143
|
+
dir.chdir(&block)
|
144
|
+
end
|
145
|
+
def file(prefix=rl.prefix,tmpdir=rl.tmpdir)
|
146
|
+
self.rl = RIO::Temp::File::RL.new(prefix, tmpdir)
|
147
|
+
become 'Temp::Stream::Open'
|
148
|
+
end
|
149
|
+
def scheme() rl.scheme() end
|
150
|
+
def host() rl.host() end
|
151
|
+
def opaque() rl.opaque() end
|
152
|
+
def to_s() rl.url() end
|
153
|
+
def exist?() false end
|
154
|
+
def file?() false end
|
155
|
+
def dir?() false end
|
156
|
+
def open?() false end
|
157
|
+
def closed?() true end
|
158
|
+
def when_missing(sym,*args)
|
159
|
+
if @tempobj.nil?
|
160
|
+
file()
|
161
|
+
else
|
162
|
+
gofigure(sym,*args)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
require 'rio/stream/open'
|
167
|
+
module Stream
|
168
|
+
class Open < RIO::Stream::Open
|
169
|
+
def iostate(sym)
|
170
|
+
mode('w+').noautoclose_.open_.inout()
|
171
|
+
end
|
172
|
+
# def inout() stream_state('Temp::Stream::InOut') end
|
173
|
+
end
|
174
|
+
# require 'rio/stream'
|
175
|
+
# class InOut < RIO::Stream::InOut
|
176
|
+
# def base_state() 'Temp::Stream::Close' end
|
177
|
+
# end
|
178
|
+
# class Close < RIO::Stream::Close
|
179
|
+
# def base_state() 'Temp::Reset' end
|
180
|
+
# end
|
181
|
+
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
data/lib/rio/state.rb
CHANGED
@@ -40,6 +40,7 @@ require 'rio/context'
|
|
40
40
|
require 'rio/context/methods'
|
41
41
|
require 'rio/ext'
|
42
42
|
require 'rio/symantics'
|
43
|
+
$trace_states = false
|
43
44
|
module RIO
|
44
45
|
|
45
46
|
|
@@ -109,7 +110,7 @@ module RIO
|
|
109
110
|
# it's job is create an instance of the next state
|
110
111
|
# and change the value in the handle that is shared with the fs object
|
111
112
|
def become(new_class,*args)
|
112
|
-
|
113
|
+
p "become : #{self.class.to_s} => #{new_class.to_s} (#{self.mode?})" if $trace_states
|
113
114
|
#
|
114
115
|
return self if new_class == self.class
|
115
116
|
|
@@ -124,7 +125,7 @@ module RIO
|
|
124
125
|
"missing: "+self.class.to_s+'['+self.to_url+']'+'.'+sym.to_s+'('+args.join(',')+')'
|
125
126
|
end
|
126
127
|
def method_missing(sym,*args,&block)
|
127
|
-
|
128
|
+
p method_missing_trace_str(sym,*args) if $trace_states
|
128
129
|
|
129
130
|
obj = when_missing(sym,*args)
|
130
131
|
raise RuntimeError,"when_missing returns nil" if obj.nil?
|
@@ -163,15 +164,25 @@ module RIO
|
|
163
164
|
|
164
165
|
def to_rl() self.rl.rl end
|
165
166
|
|
166
|
-
|
167
|
-
|
168
|
-
|
167
|
+
|
168
|
+
extend Forwardable
|
169
|
+
# def_instance_delegators(:rl,:path,:to_s,:fspath,:opaque,:host,:length)
|
170
|
+
def_instance_delegators(:rl,:path,:to_s,:fspath,:length)
|
171
|
+
|
172
|
+
# def fspath() @rl.fspath end
|
173
|
+
# def path() @rl.path() end
|
174
|
+
# def opaque() @rl.opaque() end
|
175
|
+
# def scheme() @rl.scheme() end
|
176
|
+
# def host() @rl.host() end
|
177
|
+
# def to_s() @rl.to_s() end
|
178
|
+
# def length() @rl.length end
|
179
|
+
|
180
|
+
|
169
181
|
def ==(other) @rl == other end
|
170
182
|
def ===(other) self == other end
|
171
183
|
def =~(other) other =~ self.to_s end
|
172
184
|
def to_url() @rl.url end
|
173
185
|
def to_uri() @rl.uri end
|
174
|
-
def length() @rl.length end
|
175
186
|
alias to_str to_s
|
176
187
|
|
177
188
|
def hash() @rl.to_s.hash end
|
data/lib/rio/stream.rb
CHANGED
data/lib/rio/stream/open.rb
CHANGED
@@ -66,7 +66,7 @@ module RIO
|
|
66
66
|
#p callstr('open_',args.inspect)+" mode='#{mode?}' (#{mode?.class}) ioh=#{self.ioh} open?=#{open?}"
|
67
67
|
unless open?
|
68
68
|
ios = self.rl.open(mode?,*args)
|
69
|
-
|
69
|
+
noautoclose_(false) if ios.tty?
|
70
70
|
self.ioh = IOH::Stream.new(ios)
|
71
71
|
end
|
72
72
|
self
|
data/lib/rio/tempdir.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
|
3
|
+
== tempdir.rb - provides class Tempdir
|
4
|
+
|
5
|
+
=== Synopsis
|
6
|
+
In order to
|
7
|
+
|
8
|
+
1. create a temporary directory with a name starting with "hoge",
|
9
|
+
2. show the name of that directory, and
|
10
|
+
3. show its properties with the system "ls -dl" command:
|
11
|
+
|
12
|
+
require 'tempdir'
|
13
|
+
|
14
|
+
d = Tempdir.new("hoge")
|
15
|
+
p d.to_s
|
16
|
+
system("ls", "-dl", d.to_s)
|
17
|
+
|
18
|
+
After the run, the directory will appear to be removed. That is: if you
|
19
|
+
are not running inside it, which may provide you a means to create a
|
20
|
+
directory with a unique name that will be available after the run.
|
21
|
+
|
22
|
+
=== Description
|
23
|
+
<i>tempdir.rb</i> provides the Tempdir class, which is analogous to the
|
24
|
+
Tempfile class, but manipulates temporary directories. Derived from a
|
25
|
+
proposal of nobu.nokada@softhome.net. He added the class to
|
26
|
+
tempfile.rb, but since it does not seem to appear in cvs, I'll keep
|
27
|
+
it apart in tempdir.rb.
|
28
|
+
|
29
|
+
=end
|
30
|
+
|
31
|
+
require 'tmpdir'
|
32
|
+
|
33
|
+
module AutoRemoval
|
34
|
+
MAX_TRY = 10
|
35
|
+
@@cleanlist = []
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def make_tmpname(basename, n)
|
40
|
+
sprintf('%s%d.%d', basename, $$, n)
|
41
|
+
end
|
42
|
+
private :make_tmpname
|
43
|
+
|
44
|
+
def createtmp(basename, tmpdir=Dir::tmpdir) # :nodoc:
|
45
|
+
if $SAFE > 0 and tmpdir.tainted?
|
46
|
+
tmpdir = '/tmp'
|
47
|
+
end
|
48
|
+
|
49
|
+
lock = nil
|
50
|
+
n = failure = 0
|
51
|
+
|
52
|
+
begin
|
53
|
+
Thread.critical = true
|
54
|
+
begin
|
55
|
+
tmpname = File.join(tmpdir, make_tmpname(basename, n))
|
56
|
+
n += 1
|
57
|
+
end until !@@cleanlist.include?(tmpname) and yield(tmpname)
|
58
|
+
rescue
|
59
|
+
p $!
|
60
|
+
failure += 1
|
61
|
+
retry if failure < MAX_TRY
|
62
|
+
raise "cannot generate tempfile `%s'" % tmpname
|
63
|
+
ensure
|
64
|
+
Thread.critical = false
|
65
|
+
end
|
66
|
+
|
67
|
+
tmpname
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.callback(path, clear) # :nodoc:
|
71
|
+
@@cleanlist << path
|
72
|
+
data = [path]
|
73
|
+
pid = $$
|
74
|
+
return Proc.new {
|
75
|
+
if pid == $$
|
76
|
+
path, tmpfile = *data
|
77
|
+
|
78
|
+
print "removing ", path, "..." if $DEBUG
|
79
|
+
|
80
|
+
tmpfile.close if tmpfile
|
81
|
+
|
82
|
+
# keep this order for thread safeness
|
83
|
+
if File.exist?(path)
|
84
|
+
clear.call(path)
|
85
|
+
end
|
86
|
+
@@cleanlist.delete(path)
|
87
|
+
|
88
|
+
print "done\n" if $DEBUG
|
89
|
+
end
|
90
|
+
}, data
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.unregister(path)
|
94
|
+
@@cleanlist.delete(path)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
require 'pathname'
|
99
|
+
class Tempdir < Pathname
|
100
|
+
include AutoRemoval
|
101
|
+
|
102
|
+
def initialize(*args)
|
103
|
+
require 'fileutils'
|
104
|
+
|
105
|
+
tmpname = createtmp(*args) do |tmpname|
|
106
|
+
unless File.exist?(tmpname)
|
107
|
+
Dir.mkdir(tmpname, 0700)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
super(tmpname)
|
112
|
+
@clean_proc, = AutoRemoval.callback(tmpname, FileUtils.method(:rm_rf))
|
113
|
+
ObjectSpace.define_finalizer(self, @clean_proc) end
|
114
|
+
|
115
|
+
def open(basename, *modes, &block)
|
116
|
+
File.open(self+basename, *modes, &block)
|
117
|
+
end
|
118
|
+
|
119
|
+
def clear
|
120
|
+
FileUtils.rm_rf(@tmpname)
|
121
|
+
@clean_proc.call
|
122
|
+
ObjectSpace.undefine_finalizer(self)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
if __FILE__ == $0
|
127
|
+
# $DEBUG = true
|
128
|
+
d = Tempdir.new("hoge")
|
129
|
+
p d.to_s
|
130
|
+
system("ls", "-dl", d.to_s)
|
131
|
+
p d
|
132
|
+
end
|