rio 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README +18 -12
- data/Rakefile +57 -87
- data/build_doc.rb +19 -17
- data/doc/ANNOUNCE +3 -32
- data/doc/RELEASE_NOTES +4 -5
- data/doc/RIOIS +215 -0
- data/doc/generators/template/html/rio.css +428 -0
- data/doc/generators/template/html/rio.rb +18 -389
- data/doc/generators/template/html/ugly.rb +130 -0
- data/doc/pkg_def.rb +66 -0
- data/ex/catcsv.rb +64 -0
- data/ex/colx.rb +8 -0
- data/ex/findinruby +15 -0
- data/ex/findruby +14 -0
- data/ex/passwd_report.rb +8 -0
- data/ex/prompt.rb +25 -0
- data/ex/rgb.txt.gz +0 -0
- data/ex/riocat +42 -0
- data/ex/riogunzip +31 -0
- data/ex/riogzip +24 -0
- data/ex/rioprompt.rb +10 -0
- data/ex/targz2zip +17 -0
- data/ex/tonl +10 -0
- data/lib/rio.rb +16 -10
- data/lib/rio/abstract_method.rb +3 -4
- data/lib/rio/argv.rb +3 -4
- data/lib/rio/arycopy.rb +3 -4
- data/lib/rio/assert.rb +3 -4
- data/lib/rio/base.rb +3 -4
- data/lib/rio/callstr.rb +3 -4
- data/lib/rio/const.rb +3 -4
- data/lib/rio/construct.rb +3 -4
- data/lib/rio/constructor.rb +12 -8
- data/lib/rio/context.rb +15 -30
- data/lib/rio/context/autoclose.rb +3 -4
- data/lib/rio/context/copying.rb +3 -4
- data/lib/rio/context/cxx.rb +3 -4
- data/lib/rio/context/dir.rb +3 -4
- data/lib/rio/context/gzip.rb +3 -4
- data/lib/rio/context/methods.rb +16 -5
- data/lib/rio/context/skip.rb +3 -4
- data/lib/rio/context/stream.rb +42 -5
- data/lib/rio/cp.rb +7 -7
- data/lib/rio/def.rb +3 -4
- data/lib/rio/dir.rb +3 -4
- data/lib/rio/doc.rb +4 -5
- data/lib/rio/doc/EXAMPLES.rb +299 -0
- data/lib/rio/doc/HOWTO.rb +3 -4
- data/lib/rio/doc/INTRO.rb +86 -105
- data/lib/rio/doc/OPTIONAL.rb +4 -5
- data/lib/rio/doc/SYNOPSIS.rb +7 -6
- data/lib/rio/entrysel.rb +21 -23
- data/lib/rio/exception.rb +3 -4
- data/lib/rio/exception/copy.rb +3 -4
- data/lib/rio/exception/notimplemented.rb +57 -0
- data/lib/rio/exception/notsupported.rb +3 -4
- data/lib/rio/exception/open.rb +3 -4
- data/lib/rio/exception/state.rb +3 -4
- data/lib/rio/ext.rb +47 -13
- data/lib/rio/ext/csv.rb +4 -5
- data/lib/rio/ext/if.rb +45 -0
- data/lib/rio/ext/mp3info.rb +80 -0
- data/lib/rio/ext/splitlines.rb +253 -0
- data/lib/rio/ext/yaml.rb +9 -5
- data/lib/rio/ext/yaml/doc.rb +133 -0
- data/lib/rio/ext/yaml/tie.rb +149 -0
- data/lib/rio/ext/zipfile.rb +23 -4
- data/lib/rio/ext/zipfile/fs.rb +116 -0
- data/lib/rio/ext/zipfile/rl.rb +251 -0
- data/lib/rio/ext/zipfile/rootdir.rb +117 -0
- data/lib/rio/ext/zipfile/state.rb +161 -0
- data/lib/rio/ext/zipfile/wrap.rb +204 -0
- data/lib/rio/factory.rb +235 -27
- data/lib/rio/file.rb +4 -4
- data/lib/rio/filter.rb +3 -4
- data/lib/rio/filter/closeoneof.rb +3 -4
- data/lib/rio/filter/gzip.rb +9 -4
- data/lib/rio/fs/base.rb +3 -4
- data/lib/rio/fs/impl.rb +4 -5
- data/lib/rio/fs/native.rb +3 -4
- data/lib/rio/fs/stream.rb +3 -4
- data/lib/rio/fs/url.rb +3 -4
- data/lib/rio/ftp/conncache.rb +19 -5
- data/lib/rio/ftp/dir.rb +3 -4
- data/lib/rio/ftp/fs.rb +30 -24
- data/lib/rio/grande.rb +27 -7
- data/lib/rio/handle.rb +3 -4
- data/lib/rio/if.rb +19 -15
- data/lib/rio/if/basic.rb +7 -7
- data/lib/rio/if/csv.rb +5 -6
- data/lib/rio/if/dir.rb +120 -114
- data/lib/rio/if/file.rb +52 -44
- data/lib/rio/if/fileordir.rb +217 -211
- data/lib/rio/if/grande.rb +674 -644
- data/lib/rio/if/grande_entry.rb +321 -313
- data/lib/rio/if/grande_stream.rb +653 -553
- data/lib/rio/if/internal.rb +3 -4
- data/lib/rio/if/path.rb +425 -426
- data/lib/rio/if/rubyio.rb +681 -0
- data/lib/rio/if/string.rb +42 -5
- data/lib/rio/if/temp.rb +3 -4
- data/lib/rio/if/test.rb +245 -238
- data/lib/rio/if/yaml.rb +15 -41
- data/lib/rio/ioh.rb +7 -5
- data/lib/rio/iomode.rb +19 -7
- data/lib/rio/ios/fail.rb +4 -5
- data/lib/rio/ios/generic.rb +4 -5
- data/lib/rio/ios/mode.rb +4 -5
- data/lib/rio/ios/null.rb +6 -7
- data/lib/rio/iowrap.rb +3 -4
- data/lib/rio/kernel.rb +3 -5
- data/lib/rio/local.rb +3 -4
- data/lib/rio/match.rb +3 -4
- data/lib/rio/matchrecord.rb +3 -4
- data/lib/rio/no_warn.rb +3 -4
- data/lib/rio/nullio.rb +3 -4
- data/lib/rio/open3.rb +4 -5
- data/lib/rio/ops/construct.rb +3 -4
- data/lib/rio/ops/create.rb +11 -6
- data/lib/rio/ops/dir.rb +19 -8
- data/lib/rio/ops/either.rb +6 -5
- data/lib/rio/ops/file.rb +3 -4
- data/lib/rio/ops/path.rb +14 -35
- data/lib/rio/ops/stream.rb +3 -4
- data/lib/rio/ops/stream/input.rb +4 -7
- data/lib/rio/ops/stream/output.rb +3 -4
- data/lib/rio/ops/stream/read.rb +6 -5
- data/lib/rio/ops/stream/write.rb +3 -4
- data/lib/rio/ops/symlink.rb +3 -4
- data/lib/rio/path.rb +22 -18
- data/lib/rio/path/reset.rb +4 -5
- data/lib/rio/piper.rb +3 -4
- data/lib/rio/piper/cp.rb +3 -4
- data/lib/rio/prompt.rb +10 -5
- data/lib/rio/rectype.rb +5 -5
- data/lib/rio/rl/base.rb +17 -71
- data/lib/rio/rl/builder.rb +14 -38
- data/lib/rio/rl/chmap.rb +66 -0
- data/lib/rio/rl/fs2url.rb +82 -0
- data/lib/rio/rl/ioi.rb +4 -4
- data/lib/rio/rl/path.rb +44 -122
- data/lib/rio/rl/pathmethods.rb +19 -8
- data/lib/rio/rl/uri.rb +137 -60
- data/lib/rio/rl/withpath.rb +295 -0
- data/lib/rio/scheme/aryio.rb +3 -4
- data/lib/rio/scheme/cmdio.rb +3 -4
- data/lib/rio/scheme/cmdpipe.rb +4 -4
- data/lib/rio/scheme/fd.rb +3 -4
- data/lib/rio/scheme/ftp.rb +7 -7
- data/lib/rio/scheme/http.rb +4 -5
- data/lib/rio/scheme/null.rb +3 -4
- data/lib/rio/scheme/path.rb +3 -4
- data/lib/rio/scheme/stderr.rb +3 -4
- data/lib/rio/scheme/stdio.rb +3 -4
- data/lib/rio/scheme/strio.rb +3 -4
- data/lib/rio/scheme/sysio.rb +3 -4
- data/lib/rio/scheme/tcp.rb +3 -4
- data/lib/rio/scheme/temp.rb +6 -6
- data/lib/rio/state.rb +18 -46
- data/lib/rio/state/error.rb +3 -4
- data/lib/rio/stream.rb +4 -4
- data/lib/rio/stream/base.rb +3 -4
- data/lib/rio/stream/duplex.rb +3 -4
- data/lib/rio/stream/open.rb +3 -8
- data/lib/rio/symantics.rb +3 -4
- data/lib/rio/tempdir.rb +2 -2
- data/lib/rio/to_rio.rb +3 -4
- data/lib/rio/to_rio/all.rb +3 -4
- data/lib/rio/to_rio/array.rb +4 -5
- data/lib/rio/to_rio/io.rb +4 -5
- data/lib/rio/to_rio/object.rb +4 -5
- data/lib/rio/to_rio/string.rb +4 -5
- data/lib/rio/uri/file.rb +41 -5
- data/lib/rio/util.rb +3 -4
- data/lib/rio/version.rb +4 -5
- data/setup.rb +368 -339
- data/test/bin/list_dir.rb +1 -1
- data/test/ftp/anon_misc.rb +13 -1
- data/test/ftp/anon_special.rb +6 -6
- data/test/ftp/anon_write.rb +10 -3
- data/test/ftp/ftp2ftp.rb +2 -2
- data/test/ftp/testdef.rb +9 -6
- data/test/http/all.rb +3 -0
- data/test/http/copy-from-http.rb +140 -0
- data/test/lib/temp_server.rb +44 -0
- data/test/runalltests.rb +3 -1
- data/test/runhttp.rb +12 -0
- data/test/runhttptests.rb +1 -1
- data/test/runtests.rb +41 -3
- data/test/tc/abs.rb +9 -5
- data/test/tc/all.rb +9 -4
- data/test/tc/base.rb +1 -1
- data/test/tc/base2.rb +87 -0
- data/test/tc/{methods.rb → clone.rb} +72 -50
- data/test/tc/closeoncopy.rb +13 -2
- data/test/tc/copy-dir-samevar.rb +91 -0
- data/test/tc/dir_iter.rb +0 -1
- data/test/tc/empty.rb +6 -2
- data/test/tc/expand_path.rb +36 -54
- data/test/tc/ext.rb +42 -18
- data/test/tc/gzip.rb +30 -3
- data/test/tc/likeio.rb +5 -1
- data/test/tc/line_record_row.rb +51 -0
- data/test/tc/noqae.rb +71 -70
- data/test/tc/path_parts.rb +175 -0
- data/test/tc/programs_util.rb +3 -3
- data/test/tc/rename.rb +4 -5
- data/test/tc/riorl.rb +9 -7
- data/test/tc/skip.rb +35 -6
- data/test/tc/skiplines.rb +34 -5
- data/test/tc/split.rb +8 -50
- data/test/tc/splitlines.rb +65 -0
- data/test/tc/splitpath.rb +83 -0
- data/test/tc/testcase.rb +1 -1
- data/test/tc/truncate.rb +39 -0
- data/test/tc/yaml.rb +9 -8
- metadata +261 -207
- data/ChangeLog +0 -1418
- data/VERSION +0 -1
- data/lib/rio/doc/MISC.rb +0 -259
- data/lib/rio/if/stream.rb +0 -680
- data/lib/rio/impl/path.rb +0 -87
- data/test/tc/copy-from-http.rb +0 -89
data/lib/rio/rl/builder.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005,
|
3
|
+
# Copyright (c) 2005,2006,2007 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -23,16 +23,15 @@
|
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
25
|
# ruby build_doc.rb
|
26
|
-
# from the distribution directory.
|
26
|
+
# from the distribution directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
29
29
|
# * RIO::Doc::SYNOPSIS
|
30
30
|
# * RIO::Doc::INTRO
|
31
31
|
# * RIO::Doc::HOWTO
|
32
|
+
# * RIO::Doc::EXAMPLES
|
32
33
|
# * RIO::Rio
|
33
34
|
#
|
34
|
-
# <b>Rio is pre-alpha software.
|
35
|
-
# The documented interface and behavior is subject to change without notice.</b>
|
36
35
|
|
37
36
|
|
38
37
|
require 'uri'
|
@@ -43,7 +42,9 @@ require 'stringio'
|
|
43
42
|
module RIO
|
44
43
|
module RL
|
45
44
|
class Builder
|
46
|
-
|
45
|
+
def self.build_path_rl(rl)
|
46
|
+
return rl
|
47
|
+
end
|
47
48
|
def self.build(*a)
|
48
49
|
#puts "build: #{a.inspect}"
|
49
50
|
a.flatten!
|
@@ -64,13 +65,15 @@ module RIO
|
|
64
65
|
return Factory.instance.riorl_class('path').new(*a)
|
65
66
|
end
|
66
67
|
when RIO::Rio
|
67
|
-
a[0] = a[0].
|
68
|
+
a[0] = a[0].rl
|
69
|
+
return build(*a)
|
68
70
|
when RL::Base
|
71
|
+
#p "HERE a=#{a.inspect}"
|
69
72
|
a0 = a.shift.clone
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
#return a0.
|
73
|
+
cl = Factory.instance.riorl_class(a0.scheme)
|
74
|
+
o = cl.new(a0,*a) unless cl.nil?
|
75
|
+
return o
|
76
|
+
# return (a.empty? ? a0 : a0.join(*a))
|
74
77
|
when ::URI
|
75
78
|
a0 = a.shift
|
76
79
|
cl = Factory.instance.riorl_class(a0.scheme)
|
@@ -88,7 +91,7 @@ module RIO
|
|
88
91
|
end
|
89
92
|
when ::NilClass
|
90
93
|
a[0] = 'rio:null:'
|
91
|
-
when ?? , ?= , ?_ , ?", ?[, ?#, ?`,
|
94
|
+
when ?? , ?= , ?_ , ?", ?[, ?#, ?`, ?|, ?z
|
92
95
|
a[0] = 'rio:'+CHMAP[a[0]]+':'
|
93
96
|
when ?-
|
94
97
|
a[0] = ( a.size == 1 ? 'rio:'+CHMAP[a[0]]+':' : 'rio:cmdio:' )
|
@@ -109,33 +112,6 @@ module RIO
|
|
109
112
|
|
110
113
|
end
|
111
114
|
|
112
|
-
|
113
|
-
def self.build0(*args)
|
114
|
-
#p "build(#{args.inspect})"
|
115
|
-
|
116
|
-
# aryio is a special case -- must not flatten
|
117
|
-
if args[0] == 'rio:aryio'
|
118
|
-
args.shift
|
119
|
-
ary = args[0] unless args.empty?
|
120
|
-
require 'rio/scheme/aryio'
|
121
|
-
return RIO::AryIO::RL.new(ary)
|
122
|
-
end
|
123
|
-
|
124
|
-
args = canon(args.flatten)
|
125
|
-
a0 = args.shift
|
126
|
-
case a0
|
127
|
-
when RL::Base
|
128
|
-
a0.class.new(a0.uri.dup,*args)
|
129
|
-
when ::URI
|
130
|
-
cl = Factory.instance.riorl_class(a0.scheme)
|
131
|
-
cl.new(a0,*args) unless cl.nil?
|
132
|
-
else
|
133
|
-
sch = Base.subscheme(a0)
|
134
|
-
cl = Factory.instance.riorl_class(sch)
|
135
|
-
cl.parse(a0,*args) unless cl.nil?
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
115
|
end
|
140
116
|
end
|
141
117
|
end
|
data/lib/rio/rl/chmap.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#--
|
2
|
+
# ===============================================================================
|
3
|
+
# Copyright (c) 2005,2006,2007 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
|
+
# ruby build_doc.rb
|
26
|
+
# from the distribution directory.
|
27
|
+
#
|
28
|
+
# Suggested Reading
|
29
|
+
# * RIO::Doc::SYNOPSIS
|
30
|
+
# * RIO::Doc::INTRO
|
31
|
+
# * RIO::Doc::HOWTO
|
32
|
+
# * RIO::Doc::EXAMPLES
|
33
|
+
# * RIO::Rio
|
34
|
+
#
|
35
|
+
|
36
|
+
|
37
|
+
require 'uri'
|
38
|
+
require 'rio/local'
|
39
|
+
require 'rio/uri/file'
|
40
|
+
|
41
|
+
module RIO
|
42
|
+
module RL
|
43
|
+
CHMAP = {
|
44
|
+
'_' => 'sysio',
|
45
|
+
'-' => 'stdio',
|
46
|
+
'=' => 'stderr',
|
47
|
+
'"' => 'strio',
|
48
|
+
'?' => 'temp',
|
49
|
+
'[' => 'aryio',
|
50
|
+
'`' => 'cmdio',
|
51
|
+
'|' => 'cmdpipe',
|
52
|
+
'#' => 'fd',
|
53
|
+
|
54
|
+
?_ => 'sysio',
|
55
|
+
?- => 'stdio',
|
56
|
+
?= => 'stderr',
|
57
|
+
?" => 'strio',
|
58
|
+
?? => 'temp',
|
59
|
+
?[ => 'aryio',
|
60
|
+
?` => 'cmdio',
|
61
|
+
?| => 'cmdpipe',
|
62
|
+
?# => 'fd',
|
63
|
+
?z => 'zipfile',
|
64
|
+
}.freeze
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#--
|
2
|
+
# ===============================================================================
|
3
|
+
# Copyright (c) 2005,2006,2007 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
|
+
# ruby build_doc.rb
|
26
|
+
# from the distribution directory.
|
27
|
+
#
|
28
|
+
# Suggested Reading
|
29
|
+
# * RIO::Doc::SYNOPSIS
|
30
|
+
# * RIO::Doc::INTRO
|
31
|
+
# * RIO::Doc::HOWTO
|
32
|
+
# * RIO::Doc::EXAMPLES
|
33
|
+
# * RIO::Rio
|
34
|
+
#
|
35
|
+
|
36
|
+
|
37
|
+
require 'uri'
|
38
|
+
require 'rio/local'
|
39
|
+
require 'rio/uri/file'
|
40
|
+
require 'rio/rl/chmap'
|
41
|
+
|
42
|
+
module RIO
|
43
|
+
module RL #:nodoc: all
|
44
|
+
PESCAPE = Regexp.new("[^-_.!~*'()a-zA-Z0-9;?:@&=+$,]",false, 'N').freeze
|
45
|
+
ESCAPE = Regexp.new("[^-_.!~*'()a-zA-Z0-9;\/?:@&=+$,]",false, 'N').freeze
|
46
|
+
def escape(pth,esc=ESCAPE)
|
47
|
+
::URI.escape(pth,esc)
|
48
|
+
end
|
49
|
+
def unescape(pth)
|
50
|
+
::URI.unescape(pth)
|
51
|
+
end
|
52
|
+
def fs2urls(*args)
|
53
|
+
args.map{ |pth| fs2url(pth) }
|
54
|
+
end
|
55
|
+
def fs2url(pth)
|
56
|
+
#pth.sub!(/^[a-zA-Z]:/,'')
|
57
|
+
pth = URI.escape(pth,ESCAPE)
|
58
|
+
pth = '/' + pth if pth =~ /^[a-zA-Z]:/
|
59
|
+
pth
|
60
|
+
# (Local::SEPARATOR == '/' ? pth : pth.gsub(Local::SEPARATOR,%r|/|))
|
61
|
+
end
|
62
|
+
|
63
|
+
def url2fs(pth)
|
64
|
+
# pth = pth.chop if pth.length > 1 and pth[-1] == ?/ cwd = RIO::RL.fs2url(::Dir.getwd)
|
65
|
+
|
66
|
+
#pth = pth.chop if pth != '/' and pth[-1] == ?/
|
67
|
+
pth = ::URI.unescape(pth)
|
68
|
+
if pth =~ %r#^/[a-zA-Z]:#
|
69
|
+
pth = pth[1..-1]
|
70
|
+
end
|
71
|
+
pth
|
72
|
+
# (Local::SEPARATOR == '/' ? pth : pth.gsub(%r|/|,Local::SEPARATOR))
|
73
|
+
end
|
74
|
+
|
75
|
+
def getwd()
|
76
|
+
#::URI::FILE.build({:path => fs2url(::Dir.getwd)+'/'})
|
77
|
+
::URI::FILE.build({:path => fs2url(::Dir.getwd)})
|
78
|
+
end
|
79
|
+
|
80
|
+
module_function :url2fs,:fs2url,:fs2urls,:getwd,:escape,:unescape
|
81
|
+
end
|
82
|
+
end
|
data/lib/rio/rl/ioi.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005,
|
3
|
+
# Copyright (c) 2005,2006,2007 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -23,16 +23,15 @@
|
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
25
|
# ruby build_doc.rb
|
26
|
-
# from the distribution directory.
|
26
|
+
# from the distribution directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
29
29
|
# * RIO::Doc::SYNOPSIS
|
30
30
|
# * RIO::Doc::INTRO
|
31
31
|
# * RIO::Doc::HOWTO
|
32
|
+
# * RIO::Doc::EXAMPLES
|
32
33
|
# * RIO::Rio
|
33
34
|
#
|
34
|
-
# <b>Rio is pre-alpha software.
|
35
|
-
# The documented interface and behavior is subject to change without notice.</b>
|
36
35
|
|
37
36
|
|
38
37
|
require 'rio/rl/base'
|
@@ -66,6 +65,7 @@ module RIO
|
|
66
65
|
super
|
67
66
|
end
|
68
67
|
def initialize_copy(cp)
|
68
|
+
super
|
69
69
|
@ios = cp.ios.clone unless cp.ios.nil?
|
70
70
|
end
|
71
71
|
def open(ios=nil)
|
data/lib/rio/rl/path.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005,
|
3
|
+
# Copyright (c) 2005,2006,2007 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -23,165 +23,87 @@
|
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
25
|
# ruby build_doc.rb
|
26
|
-
# from the distribution directory.
|
26
|
+
# from the distribution directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
29
29
|
# * RIO::Doc::SYNOPSIS
|
30
30
|
# * RIO::Doc::INTRO
|
31
31
|
# * RIO::Doc::HOWTO
|
32
|
+
# * RIO::Doc::EXAMPLES
|
32
33
|
# * RIO::Rio
|
33
34
|
#
|
34
|
-
# <b>Rio is pre-alpha software.
|
35
|
-
# The documented interface and behavior is subject to change without notice.</b>
|
36
35
|
|
37
36
|
|
38
37
|
require 'rio/rl/uri'
|
38
|
+
require 'rio/rl/withpath'
|
39
39
|
require 'rio/rl/pathmethods'
|
40
40
|
|
41
41
|
module RIO
|
42
42
|
module RL
|
43
|
-
class PathBase <
|
43
|
+
class PathBase < URIBase
|
44
44
|
RESET_STATE = 'Path::Reset'
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
case pth
|
56
|
-
when ::Hash
|
57
|
-
@host = pth[:host]
|
58
|
-
@fspath = RL.url2fs(pth[:path])
|
59
|
-
@base = pth[:base]
|
60
|
-
when RL::Base
|
61
|
-
@host = pth.host
|
62
|
-
@fspath = RL.url2fs(pth.path)
|
63
|
-
@base = pth.base
|
64
|
-
when ::URI
|
65
|
-
u = pth.dup
|
66
|
-
u.path = '/' if pth.absolute? and pth.path == ''
|
67
|
-
@fspath = RL.url2fs(u.path)
|
68
|
-
@host = u.host
|
69
|
-
when %r|^file://(#{HOST})?(/.*)?$|
|
70
|
-
@host = $1 || ''
|
71
|
-
@fspath = $2 ? RL.url2fs($2) : '/'
|
46
|
+
def arg0_info_(arg0,*args)
|
47
|
+
#p "arg0_info_(#{arg0.inspect},#{args.inspect})"
|
48
|
+
#p callstr('init_from_args_',arg0.inspect,args)
|
49
|
+
vuri,vbase,vfs = nil,nil,nil
|
50
|
+
case arg0
|
51
|
+
when RIO::Rio, URIBase, ::URI
|
52
|
+
return super
|
53
|
+
when ::String
|
54
|
+
vuri = uri_from_string_(RL.fs2url(arg0)) || ::URI.parse(RL.fs2url(arg0))
|
72
55
|
else
|
73
|
-
|
56
|
+
raise(ArgumentError,"'#{arg0}'[#{arg0.class}] can not be used to create a Rio")
|
74
57
|
end
|
75
|
-
|
76
|
-
self.join(*args) unless args.empty?
|
77
|
-
unless self.absolute? or @base
|
78
|
-
@base = RL.fs2url(::Dir.getwd)+'/'
|
79
|
-
end
|
80
|
-
@fspath.sub!(%r|/\.$|,'/')
|
81
|
-
#@fs = openfs_
|
82
|
-
super
|
58
|
+
[vuri,vbase,vfs]
|
83
59
|
end
|
84
|
-
def
|
85
|
-
|
60
|
+
def build_arg0_(path_str)
|
61
|
+
RL.url2fs(path_str)
|
86
62
|
end
|
87
|
-
def
|
88
|
-
|
89
|
-
rrl = self.clone
|
90
|
-
if self.urlpath =~ %r%^(/[a-zA-Z]):%
|
91
|
-
$1+':/'
|
92
|
-
else
|
93
|
-
'/'
|
94
|
-
end
|
63
|
+
def scheme()
|
64
|
+
uri.scheme || 'path'
|
95
65
|
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
if !args.empty? and args[-1].kind_of?(::Hash)
|
101
|
-
opts = args.pop
|
102
|
-
if b = opts[:base]
|
103
|
-
@base = case b
|
104
|
-
when %r%^file://(#{HOST})?(/.*)?$% then b
|
105
|
-
when %r%^/% then b
|
106
|
-
else RL.fs2url(::Dir.getwd)+'/'+b
|
107
|
-
end
|
108
|
-
@base.squeeze('/')
|
109
|
-
end
|
110
|
-
if fs = opts[:fs]
|
111
|
-
@fs = fs
|
112
|
-
end
|
113
|
-
end
|
114
|
-
args
|
66
|
+
def url
|
67
|
+
str = uri.to_s
|
68
|
+
str = scheme + ':' +str unless uri.scheme
|
69
|
+
str
|
115
70
|
end
|
116
|
-
def base(arg=nil)
|
117
|
-
self.base = arg unless arg.nil?
|
118
|
-
if absolute?
|
119
|
-
#p self.dirname
|
120
|
-
urlpath
|
121
|
-
else
|
122
|
-
@base
|
123
|
-
end
|
124
|
-
end
|
125
|
-
def base=(arg) @base = arg end
|
126
|
-
|
127
|
-
# def urlpath() @pth end
|
128
|
-
# def urlpath=(arg) @pth = arg end
|
129
|
-
def urlpath() RL.fs2url(@fspath) end
|
130
|
-
def urlpath=(arg) @fspath = RL.url2fs(arg) end
|
131
|
-
|
132
|
-
def path() self.fspath() end
|
133
|
-
def path=(arg) self.fspath = arg end
|
134
|
-
def path_no_slash() self.path.sub(/\/$/,'') end
|
135
71
|
def use_host?
|
136
|
-
|
72
|
+
hst = uri.host
|
73
|
+
!(hst.nil? || hst.empty? || hst == 'localhost')
|
137
74
|
end
|
138
75
|
|
76
|
+
def join(*args)
|
77
|
+
return self if args.empty?
|
78
|
+
join_(args.map{ |arg| RL.fs2url(arg.to_s)})
|
79
|
+
end
|
139
80
|
def fspath()
|
140
81
|
if use_host?
|
141
|
-
'//' +
|
82
|
+
'//' + uri.host + RL.url2fs(self.urlpath)
|
142
83
|
else
|
143
|
-
|
84
|
+
RL.url2fs(self.urlpath)
|
144
85
|
end
|
145
86
|
end
|
146
|
-
def fspath=(pt)
|
147
|
-
if pt =~ %r|^//(#{HOST})(/.*)?$|
|
148
|
-
@host = $1
|
149
|
-
@fspath = $2 || '/'
|
150
|
-
else
|
151
|
-
@fspath = pt
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
def scheme() (absolute? ? 'file' : 'path') end
|
158
|
-
def host() @host end
|
159
|
-
def host=(arg) @host = arg end
|
160
|
-
|
161
|
-
def absolute?()
|
162
|
-
(@fspath =~ %r%^([a-zA-Z]:)?/% ? true : false)
|
87
|
+
# def fspath=(pt)
|
88
|
+
# if pt =~ %r|^//(#{HOST})(/.*)?$|
|
89
|
+
# @host = $1
|
90
|
+
# @fspath = $2 || '/'
|
91
|
+
# else
|
92
|
+
# @fspath = pt
|
93
|
+
# end
|
94
|
+
# end
|
95
|
+
def to_s()
|
96
|
+
self.fspath
|
163
97
|
end
|
164
|
-
alias abs? absolute?
|
165
|
-
|
166
|
-
def abs()
|
167
|
-
return self if absolute?
|
168
|
-
self.class.new(@base, @fspath)
|
169
|
-
end
|
170
|
-
|
171
|
-
def uri()
|
172
|
-
(absolute? ?
|
173
|
-
::URI::FILE.new('file',nil,@host,nil,nil,RL.fs2url(@fspath),nil,nil,nil) : ::URI.parse(RL.fs2url(@fspath)))
|
174
|
-
end
|
175
|
-
|
176
98
|
def self.splitrl(s)
|
177
99
|
sch,opq,whole = split_riorl(s)
|
100
|
+
#p sch,opq,whole
|
178
101
|
case sch
|
179
102
|
when 'file' then [whole]
|
180
103
|
else [opq]
|
181
104
|
end
|
182
105
|
end
|
183
|
-
|
184
|
-
|
185
106
|
end
|
186
107
|
end
|
187
108
|
end
|
109
|
+
__END__
|