rio 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1273 -1482
- data/README +2 -2
- data/Rakefile +5 -5
- data/VERSION +1 -1
- data/{RUNME.1st.rb → build_doc.rb} +4 -10
- data/doc/ANNOUNCE +33 -80
- data/doc/RELEASE_NOTES +31 -1
- data/doc/generators/template/html/rio.rb +3 -3
- data/lib/rio/abstract_method.rb +2 -2
- data/lib/rio/argv.rb +2 -2
- data/lib/rio/arycopy.rb +2 -2
- data/lib/rio/assert.rb +2 -2
- data/lib/rio/base.rb +2 -2
- data/lib/rio/callstr.rb +47 -0
- data/lib/rio/const.rb +52 -0
- data/lib/rio/construct.rb +6 -24
- data/lib/rio/constructor.rb +12 -2
- data/lib/rio/context/autoclose.rb +73 -0
- data/lib/rio/context/copying.rb +2 -2
- data/lib/rio/context/cxx.rb +2 -2
- data/lib/rio/context/dir.rb +2 -2
- data/lib/rio/context/gzip.rb +2 -2
- data/lib/rio/context/methods.rb +6 -34
- data/lib/rio/context/skip.rb +2 -2
- data/lib/rio/context/stream.rb +2 -2
- data/lib/rio/context.rb +17 -2
- data/lib/rio/cp.rb +35 -9
- data/lib/rio/def.rb +54 -0
- data/lib/rio/dir.rb +19 -20
- data/lib/rio/doc/HOWTO.rb +23 -7
- data/lib/rio/doc/INTRO.rb +57 -23
- data/lib/rio/doc/MISC.rb +2 -2
- data/lib/rio/doc/OPTIONAL.rb +134 -0
- data/lib/rio/doc/SYNOPSIS.rb +11 -4
- data/lib/rio/doc.rb +2 -2
- data/lib/rio/entrysel.rb +25 -6
- data/lib/rio/exception/copy.rb +2 -2
- data/lib/rio/exception/notsupported.rb +47 -0
- data/lib/rio/exception/open.rb +2 -2
- data/lib/rio/exception/state.rb +2 -2
- data/lib/rio/exception.rb +2 -2
- data/lib/rio/ext/csv.rb +56 -11
- data/lib/rio/ext/yaml.rb +2 -2
- data/lib/rio/ext/zipfile.rb +91 -0
- data/lib/rio/ext.rb +38 -3
- data/lib/rio/factory.rb +17 -34
- data/lib/rio/file.rb +48 -8
- data/lib/rio/filter/closeoneof.rb +36 -16
- data/lib/rio/filter/gzip.rb +2 -2
- data/lib/rio/filter.rb +2 -2
- data/lib/rio/fs/base.rb +42 -0
- data/lib/rio/fs/impl.rb +123 -0
- data/lib/rio/fs/native.rb +76 -0
- data/lib/rio/{record.rb → fs/stream.rb} +21 -18
- data/lib/rio/fs/url.rb +64 -0
- data/lib/rio/ftp/{ioh.rb → conncache.rb} +38 -39
- data/lib/rio/ftp/dir.rb +95 -0
- data/lib/rio/ftp/fs.rb +173 -0
- data/lib/rio/ftp/ftpfile.rb +20 -0
- data/lib/rio/grande.rb +2 -2
- data/lib/rio/handle.rb +2 -2
- data/lib/rio/if/basic.rb +2 -2
- data/lib/rio/if/csv.rb +2 -2
- data/lib/rio/if/dir.rb +2 -2
- data/lib/rio/if/file.rb +26 -2
- data/lib/rio/if/fileordir.rb +44 -49
- data/lib/rio/if/grande.rb +32 -10
- data/lib/rio/if/grande_entry.rb +12 -2
- data/lib/rio/if/grande_stream.rb +17 -28
- data/lib/rio/if/internal.rb +2 -2
- data/lib/rio/if/path.rb +7 -6
- data/lib/rio/if/stream.rb +85 -29
- data/lib/rio/if/string.rb +2 -2
- data/lib/rio/if/temp.rb +2 -2
- data/lib/rio/if/test.rb +37 -4
- data/lib/rio/if/yaml.rb +2 -2
- data/lib/rio/if.rb +2 -2
- data/lib/rio/impl/path.rb +2 -2
- data/lib/rio/ioh.rb +17 -6
- data/lib/rio/iomode.rb +4 -3
- data/lib/rio/ios/fail.rb +107 -0
- data/lib/rio/ios/generic.rb +120 -0
- data/lib/rio/ios/mode.rb +61 -0
- data/lib/rio/ios/null.rb +120 -0
- data/lib/rio/iowrap.rb +129 -0
- data/lib/rio/kernel.rb +12 -3
- data/lib/rio/local.rb +2 -2
- data/lib/rio/match.rb +3 -3
- data/lib/rio/matchrecord.rb +2 -2
- data/lib/rio/no_warn.rb +50 -0
- data/lib/rio/{arrayio.rb → nullio.rb} +47 -86
- data/lib/rio/open3.rb +2 -2
- data/lib/rio/ops/construct.rb +20 -13
- data/lib/rio/ops/create.rb +10 -19
- data/lib/rio/ops/dir.rb +60 -54
- data/lib/rio/ops/either.rb +11 -9
- data/lib/rio/ops/file.rb +28 -24
- data/lib/rio/ops/path.rb +45 -43
- data/lib/rio/ops/stream/input.rb +12 -8
- data/lib/rio/ops/stream/output.rb +2 -2
- data/lib/rio/ops/stream/read.rb +35 -32
- data/lib/rio/ops/stream/write.rb +5 -5
- data/lib/rio/ops/stream.rb +7 -3
- data/lib/rio/ops/symlink.rb +12 -10
- data/lib/rio/path/reset.rb +5 -5
- data/lib/rio/path.rb +32 -24
- data/lib/rio/piper/cp.rb +2 -2
- data/lib/rio/piper.rb +2 -2
- data/lib/rio/prompt.rb +2 -2
- data/lib/rio/rectype.rb +9 -7
- data/lib/rio/rl/base.rb +5 -4
- data/lib/rio/rl/builder.rb +17 -5
- data/lib/rio/rl/ioi.rb +14 -4
- data/lib/rio/rl/path.rb +23 -15
- data/lib/rio/rl/pathmethods.rb +12 -2
- data/lib/rio/rl/uri.rb +13 -6
- data/lib/rio/scheme/aryio.rb +3 -3
- data/lib/rio/scheme/cmdio.rb +4 -3
- data/lib/rio/scheme/cmdpipe.rb +3 -35
- data/lib/rio/scheme/fd.rb +4 -3
- data/lib/rio/scheme/ftp.rb +36 -7
- data/lib/rio/scheme/http.rb +2 -2
- data/lib/rio/{context/closeoneof.rb → scheme/null.rb} +17 -11
- data/lib/rio/scheme/path.rb +28 -30
- data/lib/rio/scheme/stderr.rb +4 -4
- data/lib/rio/scheme/stdio.rb +6 -5
- data/lib/rio/scheme/strio.rb +10 -20
- data/lib/rio/scheme/sysio.rb +5 -2
- data/lib/rio/scheme/tcp.rb +4 -3
- data/lib/rio/scheme/temp.rb +14 -1
- data/lib/rio/state/error.rb +2 -2
- data/lib/rio/state.rb +80 -34
- data/lib/rio/stream/base.rb +7 -2
- data/lib/rio/stream/duplex.rb +13 -10
- data/lib/rio/stream/open.rb +74 -79
- data/lib/rio/stream.rb +15 -23
- data/lib/rio/symantics.rb +2 -2
- data/lib/rio/tempdir.rb +132 -132
- data/lib/rio/to_rio/all.rb +40 -0
- data/lib/rio/to_rio/array.rb +40 -0
- data/lib/rio/to_rio/io.rb +41 -0
- data/lib/rio/to_rio/object.rb +43 -0
- data/lib/rio/to_rio/string.rb +41 -0
- data/lib/rio/to_rio.rb +13 -2
- data/lib/rio/uri/file.rb +2 -2
- data/lib/rio/util.rb +2 -2
- data/lib/rio/version.rb +3 -3
- data/lib/rio.rb +16 -25
- data/test/bin/count_lines.rb +11 -0
- data/test/bin/find_lines.rb +13 -0
- data/test/bin/list_dir.rb +14 -0
- data/test/ftp/all.rb +9 -0
- data/test/ftp/anon_misc.rb +112 -0
- data/test/ftp/anon_read.rb +105 -0
- data/test/ftp/anon_special.rb +68 -0
- data/test/ftp/anon_write.rb +63 -0
- data/test/ftp/ftp2ftp.rb +51 -0
- data/test/ftp/initftpfiles.rb +14 -0
- data/test/ftp/testdef.rb +51 -0
- data/test/gem_runtests.rb +15 -15
- data/test/runalltests.rb +15 -0
- data/test/runftptests.rb +14 -0
- data/test/{1.rb → runhttptests.rb} +14 -14
- data/test/runtests.rb +14 -14
- data/test/tc/all.rb +36 -21
- data/test/tc/cmdpipe.rb +18 -15
- data/test/tc/copy-from-http.rb +89 -0
- data/test/tc/copy-from.rb +1 -52
- data/test/tc/copy.rb +19 -17
- data/test/tc/csv2.rb +6 -3
- data/test/tc/empty.rb +47 -0
- data/test/tc/emptyriodir.rb +129 -0
- data/test/tc/entsel.rb +110 -0
- data/test/tc/files_select.rb +92 -0
- data/test/tc/get.rb +7 -6
- data/test/tc/getrec.rb +2 -5
- data/test/tc/gzip.rb +82 -0
- data/test/tc/io_each_byte.rb +60 -0
- data/test/tc/io_read.rb +80 -0
- data/test/tc/iometh.rb +149 -0
- data/test/tc/likeio.rb +112 -0
- data/test/tc/methods.rb +10 -9
- data/test/tc/misc.rb +1 -37
- data/test/tc/null.rb +45 -0
- data/test/tc/pid.rb +31 -0
- data/test/tc/piper.rb +34 -37
- data/test/tc/programs_util.rb +24 -0
- data/test/tc/readline.rb +30 -0
- data/test/tc/rename.rb +12 -0
- data/test/tc/tempfile.rb +14 -0
- data/test/tc/testcase.rb +6 -0
- data/test/tc/tonl.rb +37 -0
- metadata +181 -144
- data/ex/colx.rb +0 -8
- data/ex/findinruby +0 -16
- data/ex/findruby +0 -15
- data/ex/passwd_report.rb +0 -8
- data/ex/prompt.rb +0 -25
- data/ex/rgb.txt.gz +0 -0
- data/ex/riocat +0 -35
- data/ex/riogunzip +0 -31
- data/ex/riogzip +0 -24
- data/ex/rioprompt.rb +0 -6
- data/ex/targz2zip +0 -17
- data/ex/tolf +0 -11
- data/lib/rio/ftp/conn.rb +0 -167
- data/lib/rio/ftp.rb +0 -275
- data/test/once.rb +0 -7
data/lib/rio/ext/csv.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -35,9 +35,28 @@
|
|
35
35
|
# The documented interface and behavior is subject to change without notice.</b>
|
36
36
|
|
37
37
|
|
38
|
+
# begin
|
39
|
+
# require 'faster_csv' # first choice--for speed
|
40
|
+
|
41
|
+
# # A CSV compatible interface for FasterCSV.
|
42
|
+
# module CSV # :nodoc:
|
43
|
+
# def self.parse_line( line, field_sep=nil, row_sep=nil )
|
44
|
+
# FasterCSV.parse_line( line, :col_sep => field_sep || ",",
|
45
|
+
# :row_sep => row_sep || :auto )
|
46
|
+
# end
|
47
|
+
|
48
|
+
# def self.generate_line( array, field_sep=nil, row_sep=nil )
|
49
|
+
# FasterCSV.generate_line( array, :col_sep => field_sep || ",",
|
50
|
+
# :row_sep => row_sep || "" )
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
# rescue LoadError
|
54
|
+
# require 'csv' # second choice--slower but standard
|
55
|
+
# end
|
56
|
+
|
38
57
|
require 'csv'
|
39
|
-
require 'rio/record'
|
40
58
|
|
59
|
+
$EXTEND_CSV_RESULTS = false
|
41
60
|
module RIO
|
42
61
|
module Ext
|
43
62
|
module CSV
|
@@ -92,21 +111,42 @@ module RIO
|
|
92
111
|
end
|
93
112
|
end
|
94
113
|
end
|
114
|
+
end
|
115
|
+
end
|
95
116
|
|
96
117
|
|
118
|
+
module RIO
|
119
|
+
module Ext
|
97
120
|
module CSV
|
98
121
|
module Input
|
99
122
|
|
100
123
|
protected
|
124
|
+
# def ior()
|
125
|
+
# p cx['stream_itertype']
|
126
|
+
# case cx['stream_itertype']
|
127
|
+
# when 'lines',nil
|
128
|
+
# self.ioh.iostack[-2]
|
129
|
+
# else
|
130
|
+
# self.ioh
|
131
|
+
# end
|
132
|
+
# end
|
133
|
+
# def each_rec_(&block)
|
134
|
+
# self.ior.each { |line|
|
135
|
+
# yield line
|
136
|
+
# }
|
137
|
+
# self
|
138
|
+
# end
|
101
139
|
|
102
140
|
def to_rec_(raw_rec)
|
103
141
|
#_init_cols_from_line(raw_rec) if @recno == 0
|
104
142
|
#p "#{callstr('to_rec_',raw_rec,@recno)} ; itertype=#{cx['stream_itertype']}"
|
105
143
|
case cx['stream_itertype']
|
106
144
|
when 'lines'
|
107
|
-
|
108
|
-
|
109
|
-
|
145
|
+
if $EXTEND_CSV_RESULTS
|
146
|
+
unless copying_from?
|
147
|
+
raw_rec.extend(RIO::Ext::CSV::Str)
|
148
|
+
raw_rec.csv_s_to_rec = _s_to_rec_proc(cx['csv_fs'],cx['csv_rs'])
|
149
|
+
end
|
110
150
|
end
|
111
151
|
raw_rec
|
112
152
|
when 'records'
|
@@ -154,15 +194,20 @@ module RIO
|
|
154
194
|
end
|
155
195
|
tfields
|
156
196
|
end
|
157
|
-
def
|
197
|
+
def parse_line_(line,fs,rs)
|
158
198
|
::CSV.parse_line(line,fs,rs)
|
159
199
|
end
|
200
|
+
def _l2a(line,fs,rs)
|
201
|
+
parse_line_(line,fs,rs)
|
202
|
+
end
|
160
203
|
def _l2record(line,fs,rs)
|
161
204
|
#p callstr('_l2record',line,fs,rs,cols)
|
162
|
-
fields = trim(
|
163
|
-
|
164
|
-
|
165
|
-
|
205
|
+
fields = trim(parse_line_(line,fs,rs))
|
206
|
+
if $EXTEND_CSV_RESULTS
|
207
|
+
unless copying_from?
|
208
|
+
fields.extend(RIO::Ext::CSV::Ary)
|
209
|
+
fields.csv_rec_to_s = _rec_to_s_proc(fs,rs)
|
210
|
+
end
|
166
211
|
end
|
167
212
|
fields
|
168
213
|
end
|
data/lib/rio/ext/yaml.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#--
|
2
|
+
# ===============================================================================
|
3
|
+
# Copyright (c) 2005, 2006 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. 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
|
+
module RIO
|
38
|
+
module_function
|
39
|
+
def load_lib(lib)
|
40
|
+
begin
|
41
|
+
require lib
|
42
|
+
rescue LoadError => ex
|
43
|
+
begin
|
44
|
+
p "using Gem for #{lib}" if $DEBUG
|
45
|
+
require 'rubygems'
|
46
|
+
require_gem lib
|
47
|
+
rescue
|
48
|
+
raise ex
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
begin
|
55
|
+
RIO.load_lib('zip/zip')
|
56
|
+
require 'zip/zipfilesystem'
|
57
|
+
require 'rio/ext/zipfile/opt'
|
58
|
+
RIO::Ext::ZipFile.load_extension
|
59
|
+
rescue LoadError
|
60
|
+
p "No zipfile support" if $DEBUG
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
# module RIO
|
65
|
+
# module Ext
|
66
|
+
# module ZipFile
|
67
|
+
# module Cx
|
68
|
+
# def zipfile(&block)
|
69
|
+
# #require 'rio/ext/zipfile/state'
|
70
|
+
# cxx('zipfile',true,&block)
|
71
|
+
# #self.extend(ZipFile::State).fstream
|
72
|
+
# end
|
73
|
+
# def zipfile?() cxx?('zipfile') end
|
74
|
+
# def zipfile_()
|
75
|
+
# cxx_('zipfile',true)
|
76
|
+
# end
|
77
|
+
# protected :zipfile_
|
78
|
+
|
79
|
+
# def zipent(&block)
|
80
|
+
# cxx('zipent',true,&block)
|
81
|
+
# end
|
82
|
+
# def zipent?() cxx?('zipent') end
|
83
|
+
# def zipent_()
|
84
|
+
# cxx_('zipent',true)
|
85
|
+
# end
|
86
|
+
# protected :zipent_
|
87
|
+
# end
|
88
|
+
# end
|
89
|
+
# end
|
90
|
+
# end
|
91
|
+
__END__
|
data/lib/rio/ext.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -37,7 +37,33 @@
|
|
37
37
|
|
38
38
|
require 'rio/ext/csv'
|
39
39
|
require 'rio/ext/yaml'
|
40
|
+
#require 'rio/ext/zipfile'
|
41
|
+
|
40
42
|
require 'rio/util'
|
43
|
+
module RIO
|
44
|
+
module Ext #:nodoc: all
|
45
|
+
@@extensions = {}
|
46
|
+
|
47
|
+
module_function
|
48
|
+
def add(cl,meth)
|
49
|
+
@@extensions[cl] ||= []
|
50
|
+
@@extensions[cl].push(meth)
|
51
|
+
end
|
52
|
+
def extend_state(state_class,ext_module)
|
53
|
+
ext_proc = proc{ |obj| obj.extend(ext_module) }
|
54
|
+
RIO::Ext.add(state_class,ext_proc)
|
55
|
+
end
|
56
|
+
|
57
|
+
def became(obj)
|
58
|
+
if @@extensions[obj.class]
|
59
|
+
@@extensions[obj.class].each { |meth|
|
60
|
+
meth[obj]
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
41
67
|
module RIO
|
42
68
|
module Ext #:nodoc: all
|
43
69
|
OUTPUT_SYMS = Util::build_sym_hash(CSV::Output.instance_methods + YAML::Output.instance_methods)
|
@@ -45,14 +71,22 @@ module RIO
|
|
45
71
|
module Cx
|
46
72
|
include CSV::Cx
|
47
73
|
include YAML::Cx
|
74
|
+
#include ZipFile::Cx
|
48
75
|
end
|
49
76
|
end
|
50
77
|
module Ext
|
51
78
|
module Input
|
52
79
|
def add_extensions(obj)
|
53
80
|
#p "add_extensions(#{obj.inspect})"
|
54
|
-
|
81
|
+
#p obj.ioh
|
82
|
+
if obj.csv?
|
83
|
+
obj.extend(CSV::Input)
|
84
|
+
end
|
55
85
|
obj.extend(YAML::Input) if obj.yaml?
|
86
|
+
# if obj.zipfile?
|
87
|
+
# require 'rio/ext/zipfile/state'
|
88
|
+
# obj.extend(ZipFile::Input)
|
89
|
+
# end
|
56
90
|
obj
|
57
91
|
end
|
58
92
|
module_function :add_extensions
|
@@ -67,3 +101,4 @@ module RIO
|
|
67
101
|
end
|
68
102
|
end
|
69
103
|
end
|
104
|
+
|
data/lib/rio/factory.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -64,12 +64,18 @@ module RIO
|
|
64
64
|
when 'file','path'
|
65
65
|
require 'rio/scheme/path'
|
66
66
|
Path
|
67
|
+
when 'zfile','zpath'
|
68
|
+
require 'rio/ext/zipfile/zpath'
|
69
|
+
Ext::ZipFile::ZPath
|
67
70
|
when 'stdio','stdin','stdout'
|
68
71
|
require 'rio/scheme/stdio'
|
69
72
|
StdIO
|
70
73
|
when 'stderr'
|
71
74
|
require 'rio/scheme/stderr'
|
72
75
|
StdErr
|
76
|
+
when 'null'
|
77
|
+
require 'rio/scheme/null'
|
78
|
+
Null
|
73
79
|
when 'tempfile'
|
74
80
|
require 'rio/scheme/temp'
|
75
81
|
Temp::File
|
@@ -138,54 +144,32 @@ module RIO
|
|
138
144
|
|
139
145
|
'Stream::Close' => 'rio/stream/open',
|
140
146
|
'Stream::Reset' => 'rio/stream',
|
141
|
-
|
142
147
|
'Stream::Open' => 'rio/stream/open',
|
143
148
|
'Stream::Input' => 'rio/stream',
|
144
149
|
'Stream::Output' => 'rio/stream',
|
145
150
|
'Stream::InOut' => 'rio/stream',
|
146
151
|
|
147
152
|
'Stream::Duplex::Open' => 'rio/stream/duplex',
|
148
|
-
'Stream::Duplex::Input' => 'rio/stream/duplex',
|
149
|
-
'Stream::Duplex::Output' => 'rio/stream/duplex',
|
150
|
-
'Stream::Duplex::InOut' => 'rio/stream/duplex',
|
151
153
|
|
152
|
-
'Path::Stream::Input' => 'rio/scheme/path',
|
153
|
-
'Path::Stream::Output' => 'rio/scheme/path',
|
154
|
-
'Path::Stream::InOut' => 'rio/scheme/path',
|
155
154
|
'Path::Stream::Open' => 'rio/scheme/path',
|
156
155
|
|
157
|
-
'StrIO::Stream::Input' => 'rio/scheme/strio',
|
158
|
-
'StrIO::Stream::Output' => 'rio/scheme/strio',
|
159
|
-
'StrIO::Stream::InOut' => 'rio/scheme/strio',
|
160
156
|
'StrIO::Stream::Open' => 'rio/scheme/strio',
|
161
157
|
|
158
|
+
'Null::Stream::Open' => 'rio/scheme/null',
|
159
|
+
|
160
|
+
'ZipFile::CentralDir::Open' => 'rio/zipfile/centraldir',
|
161
|
+
'ZipFile::CentralDir::Stream' => 'rio/zipfile/centraldir',
|
162
|
+
'ZipFile::CentralDir::Close' => 'rio/zipfile/centraldir',
|
163
|
+
'ZipFile::Path::Str' => 'rio/zipfile/path',
|
164
|
+
|
162
165
|
'CmdPipe::Stream::Reset' => 'rio/scheme/cmdpipe',
|
163
|
-
# 'CmdPipe::Stream::Open' => 'rio/scheme/cmdpipe',
|
164
|
-
# 'CmdPipe::Stream::Input' => 'rio/scheme/cmdpipe',
|
165
|
-
# 'CmdPipe::Stream::Output' => 'rio/scheme/cmdpipe',
|
166
|
-
# 'CmdPipe::Stream::InOut' => 'rio/scheme/cmdpipe',
|
167
166
|
|
168
167
|
'HTTP::Stream::Input' => 'rio/scheme/http',
|
169
168
|
'HTTP::Stream::Open' => 'rio/scheme/http',
|
170
169
|
|
171
170
|
'Temp::Reset' => 'rio/scheme/temp',
|
172
171
|
'Temp::Stream::Open' => 'rio/scheme/temp',
|
173
|
-
|
174
|
-
#'Temp::Stream::InOut' => 'rio/scheme/temp',
|
175
|
-
|
176
|
-
'FTP::State::Dir' => 'rio/ftp',
|
177
|
-
'FTP::State::File' => 'rio/ftp',
|
178
|
-
'FTP::State::Reset' => 'rio/ftp',
|
179
|
-
'FTP::State::Open' => 'rio/ftp',
|
180
|
-
'FTP::Stream::Input' => 'rio/ftp',
|
181
|
-
'FTP::Stream::Open' => 'rio/ftp',
|
182
|
-
'FTP::Stream::Close' => 'rio/ftp',
|
183
|
-
'FTP::Stream::Reset' => 'rio/ftp',
|
184
|
-
|
185
|
-
'AryIO::Stream::Input' => 'rio/scheme/aryio',
|
186
|
-
'AryIO::Stream::Output' => 'rio/scheme/aryio',
|
187
|
-
'AryIO::Stream::InOut' => 'rio/scheme/aryio',
|
188
|
-
'AryIO::Stream::Open' => 'rio/scheme/aryio',
|
172
|
+
|
189
173
|
}
|
190
174
|
def state2class(state_name)
|
191
175
|
#p "state_name=#{state_name}"
|
@@ -218,8 +202,7 @@ module RIO
|
|
218
202
|
# factory creates a state from args
|
219
203
|
def create_state(*args)
|
220
204
|
riorl = RIO::RL::Builder.build(*args)
|
221
|
-
|
222
|
-
create_handle(state2class(reset_state(riorl)).new_r(riorl))
|
205
|
+
create_handle(state2class(reset_state(riorl)).new(riorl))
|
223
206
|
end
|
224
207
|
def clone_state(state)
|
225
208
|
create_handle(state.target.clone)
|
data/lib/rio/file.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -35,6 +35,7 @@
|
|
35
35
|
# The documented interface and behavior is subject to change without notice.</b>
|
36
36
|
|
37
37
|
|
38
|
+
require 'rio/state'
|
38
39
|
require 'rio/ops/path'
|
39
40
|
require 'rio/ops/file'
|
40
41
|
|
@@ -45,12 +46,24 @@ module RIO
|
|
45
46
|
class Base < State::Base
|
46
47
|
include Ops::Path::Str
|
47
48
|
|
49
|
+
protected
|
50
|
+
|
51
|
+
def stream_rl_
|
52
|
+
#RIO::File::RL.new(self.to_uri,{:fs => self.fs})
|
53
|
+
self.rl.file_rl
|
54
|
+
end
|
55
|
+
|
56
|
+
public
|
57
|
+
|
48
58
|
def fstream()
|
49
|
-
self.rl
|
59
|
+
#p self.rl.class
|
60
|
+
self.rl = self.stream_rl_
|
50
61
|
become 'Path::Stream::Open'
|
51
|
-
# become 'Stream::Open'
|
52
62
|
end
|
53
|
-
|
63
|
+
|
64
|
+
def when_missing(sym,*args)
|
65
|
+
fstream()
|
66
|
+
end
|
54
67
|
end
|
55
68
|
|
56
69
|
class NonExisting < Base
|
@@ -60,19 +73,46 @@ module RIO
|
|
60
73
|
|
61
74
|
class Existing < Base
|
62
75
|
include Ops::File::Existing
|
76
|
+
include Enumerable
|
77
|
+
|
63
78
|
def check?() self.file? end
|
79
|
+
def handle_skipped
|
80
|
+
return self unless cx.has_key?('skip_args')
|
81
|
+
args = cx['skip_args'] || []
|
82
|
+
self.skipentries(*args)
|
83
|
+
end
|
84
|
+
def [](*args)
|
85
|
+
#p "#{callstr('[]',*args)} ss_type=#{ss_type?}"
|
86
|
+
if _using_files_with_a_file
|
87
|
+
unless args.empty?
|
88
|
+
ss_args = cx['ss_args'] = args
|
89
|
+
return self.files(*ss_args).to_a
|
90
|
+
else
|
91
|
+
return to_a()
|
92
|
+
end
|
93
|
+
else
|
94
|
+
fstream[*args]
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
64
98
|
def each(*args,&block)
|
65
99
|
#p "#{callstr('each',*args)} ss_type=#{ss_type?}"
|
66
|
-
if
|
67
|
-
|
100
|
+
if _using_files_with_a_file
|
101
|
+
handle_skipped()
|
68
102
|
sel = Match::Entry::Selector.new(cx['entry_sel'])
|
69
103
|
yield new_rio_cx(self) if sel.match?(self)
|
70
104
|
else
|
71
105
|
fstream.each(*args,&block)
|
72
106
|
end
|
73
107
|
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def _using_files_with_a_file
|
112
|
+
ss_type? == 'files' and !stream_iter?
|
113
|
+
end
|
74
114
|
end
|
75
115
|
|
76
116
|
end
|
77
117
|
|
78
|
-
end
|
118
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
@@ -48,36 +48,56 @@ module RIO
|
|
48
48
|
def autoclosed?
|
49
49
|
@autoclosed
|
50
50
|
end
|
51
|
-
|
51
|
+
# def close_on_eof_raise(&block)
|
52
|
+
# begin
|
53
|
+
# rtn = yield
|
54
|
+
# rescue EOFError
|
55
|
+
# close_on_eof_(rtn)
|
56
|
+
# raise
|
57
|
+
# end
|
58
|
+
# rtn
|
59
|
+
# end
|
60
|
+
def close_on_eof(&block)
|
52
61
|
#p callstr('close_on_eof',rtn)
|
53
|
-
|
62
|
+
rtn = yield
|
54
63
|
if handle.eof?
|
55
64
|
close_on_eof_(rtn)
|
56
65
|
end
|
57
66
|
rtn
|
58
67
|
end
|
68
|
+
def close_on_eof1(&block)
|
69
|
+
#p callstr('close_on_eof',rtn)
|
70
|
+
if handle.eof?
|
71
|
+
close_on_eof_(nil)
|
72
|
+
yield
|
73
|
+
else
|
74
|
+
yield
|
75
|
+
end
|
76
|
+
end
|
59
77
|
def close_on_eof_(rtn)
|
60
78
|
#p callstr('close_on_eof_',rtn)
|
61
|
-
# p @ios
|
62
79
|
unless @autoclosed or closed?
|
63
|
-
handle.close()
|
80
|
+
#handle.close()
|
64
81
|
@oncloseproc.call() unless @oncloseproc.nil?
|
65
82
|
@autoclosed = true
|
66
83
|
end
|
67
84
|
rtn
|
68
85
|
end
|
69
86
|
|
70
|
-
def
|
71
|
-
def
|
72
|
-
def
|
73
|
-
|
74
|
-
def readline(*args) close_on_eof
|
75
|
-
|
76
|
-
def readchar(*args) close_on_eof
|
77
|
-
def gets(*args) close_on_eof
|
87
|
+
def each_line(*args,&block) close_on_eof{super} end
|
88
|
+
def each_byte(*args,&block) close_on_eof{super} end
|
89
|
+
def each_bytes(nb,*args,&block) close_on_eof{super} end
|
90
|
+
|
91
|
+
def readline(*args) close_on_eof{super} end
|
92
|
+
|
93
|
+
def readchar(*args) close_on_eof{super} end
|
94
|
+
def gets(*args) close_on_eof{super} end
|
95
|
+
def readlines(*args) close_on_eof{super} end
|
96
|
+
|
97
|
+
def read(*args) close_on_eof{super} end
|
78
98
|
|
79
|
-
def copy_stream(dst) close_on_eof
|
80
|
-
def contents() close_on_eof
|
99
|
+
def copy_stream(dst) close_on_eof{super} end
|
100
|
+
def contents() close_on_eof{super} end
|
81
101
|
end
|
82
102
|
end
|
83
103
|
end
|
data/lib/rio/filter/gzip.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
data/lib/rio/filter.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# ===============================================================================
|
3
|
-
# Copyright (c) 2005, Christopher Kleckner
|
3
|
+
# Copyright (c) 2005, 2006 Christopher Kleckner
|
4
4
|
# All rights reserved
|
5
5
|
#
|
6
6
|
# This file is part of the Rio library for ruby.
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#++
|
23
23
|
#
|
24
24
|
# To create the documentation for Rio run the command
|
25
|
-
#
|
25
|
+
# ruby build_doc.rb
|
26
26
|
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
|
27
27
|
#
|
28
28
|
# Suggested Reading
|
data/lib/rio/fs/base.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#--
|
2
|
+
# ===============================================================================
|
3
|
+
# Copyright (c) 2005, 2006 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. 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
|
+
module RIO
|
38
|
+
module FS
|
39
|
+
class Base
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|