rio 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/doc/INTRO.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
|
|
@@ -47,8 +47,8 @@ uses Zlib, and CSV to extend that functionality using a simple
|
|
|
47
47
|
consistent interface. Most of the instance methods of IO, File and
|
|
48
48
|
Dir are simply forwarded to the appropriate handle to provide
|
|
49
49
|
identical functionality. Rio also provides a "grande" interface that
|
|
50
|
-
allows many application level IO tasks to be
|
|
51
|
-
|
|
50
|
+
allows many application level IO tasks to be expressed succinctly.
|
|
51
|
+
|
|
52
52
|
|
|
53
53
|
Rio functionality can be broadly broken into three categories
|
|
54
54
|
* path manipulation
|
|
@@ -70,7 +70,7 @@ the presence of a block as an implied +each+.
|
|
|
70
70
|
== Using a Rio
|
|
71
71
|
|
|
72
72
|
Using a Rio can be described as having 3 steps:
|
|
73
|
-
* Creating a Rio
|
|
73
|
+
* Creating a Rio
|
|
74
74
|
* Configuring a Rio
|
|
75
75
|
* Rio I/O
|
|
76
76
|
|
|
@@ -93,64 +93,97 @@ that have a path and those that don't.
|
|
|
93
93
|
|
|
94
94
|
To create a Rio that has a path the arguments to +rio+ may be:
|
|
95
95
|
|
|
96
|
-
* a string representing the entire path. The separator used for Rios
|
|
96
|
+
* a string representing the entire path. The separator used for Rios
|
|
97
|
+
is as specified in RFC1738 ('/').
|
|
98
|
+
|
|
97
99
|
rio('adir/afile')
|
|
100
|
+
|
|
98
101
|
* a string representing a fully qualified +file+ URI as per RFC1738
|
|
102
|
+
|
|
99
103
|
rio('file:///atopleveldir/adir/afile')
|
|
104
|
+
|
|
100
105
|
* a +URI+ object representing a +file+ or generic +URI+
|
|
106
|
+
|
|
101
107
|
rio(URI('adir/afile'))
|
|
108
|
+
|
|
102
109
|
* the components of a path as separate arguments
|
|
110
|
+
|
|
103
111
|
rio('adir','afile')
|
|
112
|
+
|
|
104
113
|
* the components of a path as an array
|
|
114
|
+
|
|
105
115
|
rio(%w/adir afile/)
|
|
116
|
+
|
|
106
117
|
* another Rio
|
|
118
|
+
|
|
107
119
|
another_rio = rio('adir/afile')
|
|
108
120
|
rio(another_rio)
|
|
121
|
+
|
|
109
122
|
* any object whose +to_s+ method returns one of the above
|
|
123
|
+
|
|
110
124
|
rio(Pathname.new('apath'))
|
|
111
|
-
|
|
125
|
+
|
|
126
|
+
* any combination of the above either as separate arguments or as
|
|
127
|
+
elements of an array,
|
|
128
|
+
|
|
112
129
|
another_rio = rio('dir1/dir2')
|
|
113
130
|
auri = URI('dir4/dir5)
|
|
114
131
|
rio(another_rio,'dir3',auri,'dir6/dir7')
|
|
115
132
|
|
|
116
133
|
===== Creating a Rio that refers to a web page
|
|
117
134
|
|
|
118
|
-
To create a Rio that refers to a web page the arguments to +rio+ may
|
|
135
|
+
To create a Rio that refers to a web page the arguments to +rio+ may
|
|
136
|
+
be:
|
|
119
137
|
|
|
120
138
|
* a string representing a fully qualified +http+ URI
|
|
139
|
+
|
|
121
140
|
rio('http://ruby-doc.org/index.html')
|
|
141
|
+
|
|
122
142
|
* a +URI+ object representing a +http+ +URI+
|
|
143
|
+
|
|
123
144
|
rio(URI('http://ruby-doc.org/index.html'))
|
|
145
|
+
|
|
124
146
|
* either of the above with additional path elements
|
|
147
|
+
|
|
125
148
|
rio('http://www.ruby-doc.org/','core','classes/Object.html')
|
|
126
149
|
|
|
150
|
+
|
|
127
151
|
===== Creating a Rio that refers to a file or directory on a FTP server
|
|
128
152
|
|
|
129
|
-
To create a Rio that refers to a file on a FTP server the arguments to
|
|
153
|
+
To create a Rio that refers to a file on a FTP server the arguments to
|
|
154
|
+
+rio+ may be:
|
|
130
155
|
|
|
131
156
|
* a string representing a fully qualified +ftp+ URI
|
|
157
|
+
|
|
132
158
|
rio('ftp://user:password@ftp.example.com/afile.tar.gz')
|
|
159
|
+
|
|
133
160
|
* a +URI+ object representing a +ftp+ +URI+
|
|
161
|
+
|
|
134
162
|
rio(URI('ftp://ftp.example.com/afile.tar.gz'))
|
|
163
|
+
|
|
135
164
|
* either of the above with additional path elements
|
|
165
|
+
|
|
136
166
|
rio('ftp://ftp.gnu.org/pub/gnu','emacs','windows','README')
|
|
137
167
|
|
|
138
168
|
==== Creating Rios that do not have a path
|
|
139
169
|
|
|
140
|
-
To create a Rio without a path, the first argument to +rio+ is usually
|
|
141
|
-
character.
|
|
170
|
+
To create a Rio without a path, the first argument to +rio+ is usually
|
|
171
|
+
a single character.
|
|
142
172
|
|
|
143
173
|
===== Creating a Rio that refers to a clone of your programs stdin or stdout.
|
|
144
174
|
|
|
145
|
-
<tt>rio(?-)</tt> (mnemonic: '-' is used by some Unix programs to
|
|
175
|
+
<tt>rio(?-)</tt> (mnemonic: '-' is used by some Unix programs to
|
|
176
|
+
specify stdin or stdout in place of a file)
|
|
146
177
|
|
|
147
|
-
Just as a Rio that refers to a file, does not know whether that file
|
|
148
|
-
writing until an io operation is
|
|
149
|
-
|
|
178
|
+
Just as a Rio that refers to a file, does not know whether that file
|
|
179
|
+
will be opened for reading or writing until an io operation is
|
|
180
|
+
specified, a <tt>stdio:</tt> Rio does not know whether it will connect
|
|
181
|
+
to stdin or stdout until an I/O operation is specified.
|
|
150
182
|
|
|
151
183
|
===== Creating a Rio that refers to a clone of your programs stderr.
|
|
152
184
|
|
|
153
|
-
<tt>rio(?=)</tt> (mnemonic: '-' refers to fileno 1, so '=' refers to
|
|
185
|
+
<tt>rio(?=)</tt> (mnemonic: '-' refers to fileno 1, so '=' refers to
|
|
186
|
+
fileno 2)
|
|
154
187
|
|
|
155
188
|
===== Creating a Rio that refers to an arbitrary IO object.
|
|
156
189
|
|
|
@@ -195,14 +228,15 @@ or
|
|
|
195
228
|
or
|
|
196
229
|
rio('tcp://hostname:port')
|
|
197
230
|
|
|
198
|
-
===== Creating a Rio that runs an external program and connects to its
|
|
199
|
-
stdin and stdout
|
|
231
|
+
===== Creating a Rio that runs an external program and connects to its stdin and stdout
|
|
200
232
|
|
|
201
|
-
<tt>rio(?-,cmd)</tt> (mnemonic: '-' is used by some Unix programs to
|
|
233
|
+
<tt>rio(?-,cmd)</tt> (mnemonic: '-' is used by some Unix programs to
|
|
234
|
+
specify stdin or stdout in place of a file)
|
|
202
235
|
|
|
203
236
|
or
|
|
204
237
|
|
|
205
|
-
<tt>rio(?`,cmd)</tt> (mnemonic: '`' (backtick) runs an external
|
|
238
|
+
<tt>rio(?`,cmd)</tt> (mnemonic: '`' (backtick) runs an external
|
|
239
|
+
program in ruby)
|
|
206
240
|
|
|
207
241
|
This is Rio's interface to IO#popen
|
|
208
242
|
|
|
@@ -258,7 +292,7 @@ that this behavior differs from File#split.)
|
|
|
258
292
|
|
|
259
293
|
rio('a/b/c').split #=> [rio('a'),rio('b'),rio('c')]
|
|
260
294
|
|
|
261
|
-
The array returned is extended
|
|
295
|
+
The array returned is extended with a +to_rio+ method, which will put
|
|
262
296
|
the parts back together again.
|
|
263
297
|
|
|
264
298
|
ary = rio('a/b/c').split #=> [rio('a'),rio('b'),rio('c')]
|
|
@@ -447,7 +481,7 @@ accessed, no socket has been opened, not so much as a test for a files
|
|
|
447
481
|
existance has been done. When an I/O method is called on a Rio, the
|
|
448
482
|
sequence of events required to complete that operation on the
|
|
449
483
|
underlying object takes place. Rio takes care of creating the
|
|
450
|
-
|
|
484
|
+
appropriate object (eg IO,Dir), opening the object with the appropriate
|
|
451
485
|
mode, performing the operation, closing the object if required, and
|
|
452
486
|
returning the results of the operation.
|
|
453
487
|
|
|
@@ -458,7 +492,7 @@ Rio's I/O operations can be divide into two catagories:
|
|
|
458
492
|
==== Proxy operations
|
|
459
493
|
|
|
460
494
|
These are calls which are forwarded to the underlying object (eg
|
|
461
|
-
IO,Dir,Net::FTP), after
|
|
495
|
+
IO,Dir,Net::FTP), after appropriately creating and configuring that
|
|
462
496
|
object. The result produced by the method is returned, and the object
|
|
463
497
|
is closed.
|
|
464
498
|
|
data/lib/rio/doc/MISC.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,134 @@
|
|
|
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
|
+
|
|
38
|
+
module RIO
|
|
39
|
+
module Doc #:doc:
|
|
40
|
+
=begin rdoc
|
|
41
|
+
|
|
42
|
+
= Rio - Ruby I/O Comfort Class
|
|
43
|
+
|
|
44
|
+
Rio is a convenience class wrapping much of the functionality of IO,
|
|
45
|
+
File, Dir, Pathname, FileUtils, Tempfile, StringIO, and OpenURI and
|
|
46
|
+
uses Zlib, and CSV to extend that functionality using a simple
|
|
47
|
+
consistent interface. Most of the instance methods of IO, File and
|
|
48
|
+
Dir are simply forwarded to the appropriate handle to provide
|
|
49
|
+
identical functionality. Rio also provides a "grande" interface that
|
|
50
|
+
allows many application level IO tasks to be expressed succinctly.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Please read the following first:
|
|
54
|
+
* RIO::Doc::INTRO
|
|
55
|
+
* RIO::Doc::SYNOPSIS
|
|
56
|
+
* RIO::Doc::HOWTO
|
|
57
|
+
* RIO::Rio
|
|
58
|
+
|
|
59
|
+
= Rio Optional Componants
|
|
60
|
+
|
|
61
|
+
This document describes various optional Rio components, that must be
|
|
62
|
+
explicitly 'required' to be available. These are not included in
|
|
63
|
+
rio.rb either because they change classes that should not be changed
|
|
64
|
+
without the developers explicit permission, or because they are not of
|
|
65
|
+
general enough interest.
|
|
66
|
+
|
|
67
|
+
== to_rio
|
|
68
|
+
|
|
69
|
+
This option comprises 4 options
|
|
70
|
+
* Object#to_rio
|
|
71
|
+
|
|
72
|
+
require 'rio/to_rio/object'
|
|
73
|
+
ario = any_object.to_rio
|
|
74
|
+
|
|
75
|
+
This option adds a to_rio method to the Object class which calls the
|
|
76
|
+
object's #to_s method and passes it to the Rio constructor. Like:
|
|
77
|
+
|
|
78
|
+
ario = rio(any_object.to_s)
|
|
79
|
+
|
|
80
|
+
* String#to_rio and String#/
|
|
81
|
+
|
|
82
|
+
require 'rio/to_rio/string'
|
|
83
|
+
ario = "a/file/represented/as/a/string".to_rio
|
|
84
|
+
ario = 'strings'/'used'/'with'/'subdirectory'/'operator'
|
|
85
|
+
|
|
86
|
+
This option adds a to_rio method and the subdirectory operator '/'
|
|
87
|
+
to the String class. Note that due to operator precedance one must
|
|
88
|
+
use parenthesis when calling a method directly on a Rio created
|
|
89
|
+
using the subdirectory operator with Strings
|
|
90
|
+
|
|
91
|
+
array_of_first_ten_lines = ('adir'/'asubdir'/'afile').lines[0...10]
|
|
92
|
+
|
|
93
|
+
* Array#to_rio
|
|
94
|
+
|
|
95
|
+
require 'rio/to_rio/array'
|
|
96
|
+
ario = %w[an array of path components].to_rio #=> rio('an/array/of/path/components')
|
|
97
|
+
|
|
98
|
+
This option adds a to_rio method to the Array class. This behaves as
|
|
99
|
+
if
|
|
100
|
+
rio(%w[an array of path components]) had been called.
|
|
101
|
+
|
|
102
|
+
* require 'rio/to_rio/all' will make all of the above available.
|
|
103
|
+
|
|
104
|
+
== RIO.ARGV
|
|
105
|
+
|
|
106
|
+
require 'rio/argv'
|
|
107
|
+
arguments_as_rios = RIO.ARGV
|
|
108
|
+
|
|
109
|
+
This option provides a function which converts each element of ruby's
|
|
110
|
+
ARGV into a Rio. Useful when writing programs that take a list of
|
|
111
|
+
files as its arguments
|
|
112
|
+
|
|
113
|
+
== RIO.popen3
|
|
114
|
+
|
|
115
|
+
require 'rio/open3'
|
|
116
|
+
input,output,errput = RIO.popen3
|
|
117
|
+
RIO.popen3 { |input,output,errput| ... }
|
|
118
|
+
|
|
119
|
+
This options provides a wrapper around the Open3#popen3 call with the
|
|
120
|
+
IO objects converted to Rios
|
|
121
|
+
|
|
122
|
+
== RIO.prompt
|
|
123
|
+
|
|
124
|
+
require 'rio/prompt'
|
|
125
|
+
the_anwser = RIO.prompt('What is the answer? ')
|
|
126
|
+
|
|
127
|
+
This option provides a module function to prompt for input.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
=end
|
|
131
|
+
module OPTIONAL
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
data/lib/rio/doc/SYNOPSIS.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
|
|
@@ -52,10 +52,17 @@ module Doc #:doc:
|
|
|
52
52
|
|
|
53
53
|
= Rio - Ruby I/O Comfort Class
|
|
54
54
|
|
|
55
|
-
Rio is a convenience class wrapping much of the functionality of
|
|
56
|
-
|
|
55
|
+
Rio is a convenience class wrapping much of the functionality of IO,
|
|
56
|
+
File, Dir, Pathname, FileUtils, Tempfile, StringIO, and OpenURI and
|
|
57
|
+
uses Zlib, and CSV to extend that functionality using a simple
|
|
58
|
+
consistent interface. Most of the instance methods of IO, File and
|
|
59
|
+
Dir are simply forwarded to the appropriate handle to provide
|
|
60
|
+
identical functionality. Rio also provides a "grande" interface that
|
|
61
|
+
allows many application level IO tasks to be expressed succinctly.
|
|
62
|
+
|
|
57
63
|
|
|
58
64
|
== SYNOPSIS
|
|
65
|
+
|
|
59
66
|
For the following assume:
|
|
60
67
|
astring = ""
|
|
61
68
|
anarray = []
|
data/lib/rio/doc.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/entrysel.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
|
|
@@ -56,6 +56,11 @@ module RIO
|
|
|
56
56
|
abstract_method :=~
|
|
57
57
|
|
|
58
58
|
end
|
|
59
|
+
class Depth < Base
|
|
60
|
+
def =~(entry)
|
|
61
|
+
@match_to === entry.rl.pathdepth
|
|
62
|
+
end
|
|
63
|
+
end
|
|
59
64
|
class Any < Base
|
|
60
65
|
def =~(entry) true end
|
|
61
66
|
end
|
|
@@ -63,10 +68,24 @@ module RIO
|
|
|
63
68
|
def =~(entry) false end
|
|
64
69
|
end
|
|
65
70
|
class Glob < Base
|
|
66
|
-
def =~(entry)
|
|
71
|
+
def =~(entry)
|
|
72
|
+
::File.fnmatch?(@match_to,entry.filename.to_s)
|
|
73
|
+
end
|
|
67
74
|
end
|
|
68
75
|
class Regexp < Base
|
|
69
|
-
def =~(entry)
|
|
76
|
+
def =~(entry)
|
|
77
|
+
@match_to =~ entry.filename.to_s
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
class PathGlob < Base
|
|
81
|
+
def =~(entry)
|
|
82
|
+
::File.fnmatch?(@match_to,entry.to_s)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
class PathRegexp < Base
|
|
86
|
+
def =~(entry)
|
|
87
|
+
@match_to =~ entry.to_s
|
|
88
|
+
end
|
|
70
89
|
end
|
|
71
90
|
class Proc < Base
|
|
72
91
|
def =~(entry) @match_to[entry] end
|
|
@@ -84,6 +103,8 @@ module RIO
|
|
|
84
103
|
end
|
|
85
104
|
def create(arg)
|
|
86
105
|
case arg
|
|
106
|
+
when ::Fixnum then Depth.new(arg)
|
|
107
|
+
when ::Range then Depth.new(arg)
|
|
87
108
|
when ::String then Glob.new(arg)
|
|
88
109
|
when ::Regexp then Regexp.new(arg)
|
|
89
110
|
when ::Proc then Proc.new(arg)
|
|
@@ -128,8 +149,6 @@ module RIO
|
|
|
128
149
|
end
|
|
129
150
|
class Sels < Array
|
|
130
151
|
def <<(entry_list)
|
|
131
|
-
#p callstr('<<',entry_list)
|
|
132
|
-
|
|
133
152
|
same_sym = self.grep(entry_list)
|
|
134
153
|
if same_sym.empty?
|
|
135
154
|
super
|
data/lib/rio/exception/copy.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,47 @@
|
|
|
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
|
+
|
|
38
|
+
require 'rio/exception'
|
|
39
|
+
module RIO
|
|
40
|
+
module Exception
|
|
41
|
+
class NotSupported < Base #:nodoc: all
|
|
42
|
+
def self.emsg(fname,obj)
|
|
43
|
+
"#{fname}() is not supported for #{obj.class} objects"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
data/lib/rio/exception/open.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/exception/state.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/exception.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
|