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/if/stream.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
|
@@ -49,7 +49,7 @@ module RIO
|
|
49
49
|
#
|
50
50
|
def gets(sep_string=$/) target.gets(sep_string) end
|
51
51
|
|
52
|
-
# Slurps the contents of the rio into a string.
|
52
|
+
# Slurps the contents of the rio into a string.
|
53
53
|
#
|
54
54
|
# astring = rio('afile.txt').contents # slurp the entire contents of afile.txt into astring
|
55
55
|
#
|
@@ -195,6 +195,68 @@ module RIO
|
|
195
195
|
def readline(*args) target.readline(*args) end
|
196
196
|
|
197
197
|
|
198
|
+
# Calls IO#readpartial
|
199
|
+
#
|
200
|
+
# Reads at most maxlen bytes from the I/O stream but it blocks
|
201
|
+
# only if ios has no data immediately available. If the optional
|
202
|
+
# outbuf argument is present, it must reference a String, which
|
203
|
+
# will receive the data. It raises EOFError on end of file.
|
204
|
+
#
|
205
|
+
# readpartial is designed for streams such as pipe, socket, tty, etc. It
|
206
|
+
# blocks only when no data immediately available. This means that it
|
207
|
+
# blocks only when following all conditions hold.
|
208
|
+
#
|
209
|
+
# * the buffer in the IO object is empty.
|
210
|
+
# * the content of the stream is empty.
|
211
|
+
# * the stream is not reached to EOF.
|
212
|
+
#
|
213
|
+
# When readpartial blocks, it waits data or EOF on the stream. If some
|
214
|
+
# data is reached, readpartial returns with the data. If EOF is reached,
|
215
|
+
# readpartial raises EOFError.
|
216
|
+
#
|
217
|
+
# When readpartial doesn�t blocks, it returns or raises immediately. If
|
218
|
+
# the buffer is not empty, it returns the data in the buffer. Otherwise
|
219
|
+
# if the stream has some content, it returns the data in the
|
220
|
+
# stream. Otherwise if the stream is reached to EOF, it raises EOFError.
|
221
|
+
#
|
222
|
+
# r, w = IO.pipe # buffer pipe content
|
223
|
+
# w << "abc" # "" "abc".
|
224
|
+
# r.readpartial(4096) #=> "abc" "" ""
|
225
|
+
# r.readpartial(4096) # blocks because buffer and pipe is empty.
|
226
|
+
#
|
227
|
+
# r, w = IO.pipe # buffer pipe content
|
228
|
+
# w << "abc" # "" "abc"
|
229
|
+
# w.close # "" "abc" EOF
|
230
|
+
# r.readpartial(4096) #=> "abc" "" EOF
|
231
|
+
# r.readpartial(4096) # raises EOFError
|
232
|
+
#
|
233
|
+
# r, w = IO.pipe # buffer pipe content
|
234
|
+
# w << "abc\ndef\n" # "" "abc\ndef\n"
|
235
|
+
# r.gets #=> "abc\n" "def\n" ""
|
236
|
+
# w << "ghi\n" # "def\n" "ghi\n"
|
237
|
+
# r.readpartial(4096) #=> "def\n" "" "ghi\n"
|
238
|
+
# r.readpartial(4096) #=> "ghi\n" "" ""
|
239
|
+
#
|
240
|
+
# Note that readpartial is nonblocking-flag insensitive. It blocks even
|
241
|
+
# if the nonblocking-flag is set.
|
242
|
+
#
|
243
|
+
# Also note that readpartial behaves similar to sysread in blocking
|
244
|
+
# mode. The behavior is identical when the buffer is empty.
|
245
|
+
# ios.reopen(other_IO) => ios ios.reopen(path, mode_str) => ios
|
246
|
+
#
|
247
|
+
# Reassociates ios with the I/O stream given in other_IO or to a new
|
248
|
+
# stream opened on path. This may dynamically change the actual class of
|
249
|
+
# this stream.
|
250
|
+
#
|
251
|
+
# f1 = File.new("testfile")
|
252
|
+
# f2 = File.new("testfile")
|
253
|
+
# f2.readlines[0] #=> "This is line one\n"
|
254
|
+
# f2.reopen(f1) #=> #<File:testfile>
|
255
|
+
# f2.readlines[0] #=> "This is line one\n"
|
256
|
+
#
|
257
|
+
def readpartial(*args) target.readpartial(*args) end
|
258
|
+
|
259
|
+
|
198
260
|
# Calls IO::print
|
199
261
|
#
|
200
262
|
# Writes the given object(s) to the Rio. If the output record separator ($\) is not nil,
|
@@ -283,7 +345,7 @@ module RIO
|
|
283
345
|
# ario.write(*args)
|
284
346
|
# ario.close
|
285
347
|
#
|
286
|
-
def write!(*argv) target.write!(*argv)
|
348
|
+
def write!(*argv) target.write!(*argv) end
|
287
349
|
|
288
350
|
|
289
351
|
# Calls IO#write
|
@@ -292,7 +354,7 @@ module RIO
|
|
292
354
|
# it will be converted to a
|
293
355
|
# string using +to_s+. Returns the number of bytes written.
|
294
356
|
#
|
295
|
-
def write(*argv) target.write(*argv)
|
357
|
+
def write(*argv) target.write(*argv) end
|
296
358
|
|
297
359
|
|
298
360
|
# Calls IO#eof?
|
@@ -404,8 +466,8 @@ module RIO
|
|
404
466
|
# query file-oriented I/O streams. Arguments and results are platform
|
405
467
|
# dependent. If _arg_ is a number, its value is passed directly. If
|
406
468
|
# it is a string, it is interpreted as a binary sequence of bytes
|
407
|
-
# (
|
408
|
-
# platforms, see
|
469
|
+
# (<tt>Array#pack</tt> might be a useful way to build this string). On Unix
|
470
|
+
# platforms, see <tt>fcntl(2)</tt> for details. Not implemented on all
|
409
471
|
# platforms.
|
410
472
|
#
|
411
473
|
#
|
@@ -446,21 +508,22 @@ module RIO
|
|
446
508
|
# Calls IO#pid
|
447
509
|
# ario.pid => fixnum
|
448
510
|
# Returns the process ID of a child process associated with _ario_.
|
449
|
-
# This will be set by
|
511
|
+
# This will be set by <tt>IO::popen</tt>.
|
450
512
|
#
|
451
|
-
#
|
452
|
-
#
|
453
|
-
#
|
454
|
-
#
|
455
|
-
#
|
456
|
-
#
|
513
|
+
# pipe = IO.popen("-")
|
514
|
+
# if pipe
|
515
|
+
# $stderr.puts "In parent, child pid is #{pipe.pid}"
|
516
|
+
# else
|
517
|
+
# $stderr.puts "In child, pid is #{$$}"
|
518
|
+
# end
|
457
519
|
#
|
458
|
-
#
|
520
|
+
# produces:
|
459
521
|
#
|
460
|
-
#
|
461
|
-
#
|
522
|
+
# In child, pid is 26209
|
523
|
+
# In parent, child pid is 26209
|
462
524
|
#
|
463
525
|
#
|
526
|
+
def pid() target.pid end
|
464
527
|
|
465
528
|
|
466
529
|
# Calls IO#putc
|
@@ -489,6 +552,7 @@ module RIO
|
|
489
552
|
# f.getc #=> 104
|
490
553
|
#
|
491
554
|
#
|
555
|
+
def getc() target.getc() end
|
492
556
|
|
493
557
|
# Calls IO#readchar
|
494
558
|
# ario.readchar => fixnum
|
@@ -511,6 +575,8 @@ module RIO
|
|
511
575
|
# f2.readlines[0] #=> "This is line one\n"
|
512
576
|
#
|
513
577
|
#
|
578
|
+
#def reopen(m) target.reopen(m) end
|
579
|
+
|
514
580
|
|
515
581
|
# Calls IO#stat
|
516
582
|
# ario.stat => stat
|
@@ -525,29 +591,19 @@ module RIO
|
|
525
591
|
#
|
526
592
|
#
|
527
593
|
|
528
|
-
# Calls IO#tell
|
529
|
-
# ario.pos => integer
|
530
|
-
# ario.tell => integer
|
531
|
-
# Returns the current offset (in bytes) of _ario_.
|
532
|
-
#
|
533
|
-
# f = rio("testfile")
|
534
|
-
# f.pos #=> 0
|
535
|
-
# f.gets #=> "This is line one\n"
|
536
|
-
# f.pos #=> 17
|
537
|
-
#
|
538
|
-
#
|
539
|
-
|
540
594
|
# Calls IO#to_i
|
541
595
|
# to_i()
|
542
596
|
# Alias for #fileno
|
543
597
|
#
|
544
598
|
#
|
599
|
+
def to_i() target.to_i() end
|
545
600
|
|
546
601
|
# Calls IO#to_io
|
547
602
|
# ario.to_io -> ios
|
548
603
|
# Returns _ario_.
|
549
604
|
#
|
550
605
|
#
|
606
|
+
def to_io() target.to_io() end
|
551
607
|
|
552
608
|
# Calls IO#tty?
|
553
609
|
# ario.tty? => true or false
|
data/lib/rio/if/string.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/if/temp.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/if/test.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
|
@@ -75,7 +75,7 @@ module RIO
|
|
75
75
|
# Returns +true+ if the named file is a symbolic link.
|
76
76
|
def symlink?() target.symlink? end
|
77
77
|
|
78
|
-
# Returns +true+ if a Rio is not closed?
|
78
|
+
# Returns +true+ if a Rio is not #closed?
|
79
79
|
def open?() target.open?() end
|
80
80
|
|
81
81
|
# Calls IO#closed?
|
@@ -84,9 +84,42 @@ module RIO
|
|
84
84
|
# both reader and writer), +false+ otherwise.
|
85
85
|
def closed?() target.closed?() end
|
86
86
|
|
87
|
+
# call-seq:
|
88
|
+
# fnmatch?( pattern, [flags] ) => (true or false)
|
89
|
+
#
|
87
90
|
# Calls File#fnmatch?
|
88
91
|
#
|
89
|
-
# Returns true if path matches
|
92
|
+
# Returns true if Rio#path matches <i>pattern</i>. The
|
93
|
+
# pattern is not a regular expression; instead it follows rules
|
94
|
+
# similar to shell filename globbing. It may contain the following
|
95
|
+
# metacharacters:
|
96
|
+
#
|
97
|
+
# <i>flags</i> is a bitwise OR of the <code>FNM_xxx</code> parameters.
|
98
|
+
# The same glob pattern and flags are used by <code>Dir::glob</code>.
|
99
|
+
#
|
100
|
+
# rio('cat').fnmatch?('cat') #=> true
|
101
|
+
# rio('category').fnmatch?('cat') #=> false
|
102
|
+
# rio('cats').fnmatch?('c{at,ub}s') #=> false
|
103
|
+
# rio('cubs').fnmatch?('c{at,ub}s') #=> false
|
104
|
+
# rio('cat').fnmatch?('c{at,ub}s') #=> false
|
105
|
+
#
|
106
|
+
# rio('cat').fnmatch?('c?t') #=> true
|
107
|
+
# rio('cat').fnmatch?('c\?t') #=> false
|
108
|
+
# rio('cat').fnmatch?('c??t') #=> false
|
109
|
+
# rio('cats').fnmatch?('c*') #=> true
|
110
|
+
#
|
111
|
+
# rio('cat').fnmatch?('c*t') #=> true
|
112
|
+
# rio('cat').fnmatch?('c\at') #=> true
|
113
|
+
# rio('cat').fnmatch?('c\at',File::FNM_NOESCAPE) #=> false
|
114
|
+
# rio('a/b').fnmatch?('a?b') #=> true
|
115
|
+
# rio('a/b').fnmatch?('a?b',File::FNM_PATHNAME) #=> false
|
116
|
+
#
|
117
|
+
# rio('.profile').fnmatch?('*') #=> false
|
118
|
+
# rio('.profile').fnmatch?('*',File::FNM_DOTMATCH) #=> true
|
119
|
+
# rio('dave/.profile').fnmatch?('*') #=> true
|
120
|
+
# rio('dave/.profile').fnmatch?('*',File::FNM_DOTMATCH) #=> true
|
121
|
+
# rio('dave/.profile').fnmatch?('*',File::FNM_PATHNAME) #=> false
|
122
|
+
#
|
90
123
|
def fnmatch?(*args) target.fnmatch?(*args) end
|
91
124
|
|
92
125
|
# Calls File#ftype
|
data/lib/rio/if/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
|
data/lib/rio/if.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/impl/path.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/ioh.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
|
@@ -58,9 +58,11 @@ module RIO
|
|
58
58
|
end
|
59
59
|
class Stream < Base
|
60
60
|
attr_reader :iostack
|
61
|
+
attr_accessor :hindex
|
61
62
|
def initialize(iosp,*args)
|
62
63
|
super
|
63
64
|
@iostack = [@ios]
|
65
|
+
@hindex = -1
|
64
66
|
end
|
65
67
|
def initialize_copy(*args)
|
66
68
|
#p callstr('ioh_stream:initialize_copy',*args)
|
@@ -75,7 +77,7 @@ module RIO
|
|
75
77
|
sz || 512
|
76
78
|
end
|
77
79
|
|
78
|
-
def handle() @iostack[
|
80
|
+
def handle() @iostack[@hindex] end
|
79
81
|
def close() handle.close unless self.closed? end
|
80
82
|
def closed?() handle.nil? or handle.closed? end
|
81
83
|
def eof?() closed? or handle.eof? end
|
@@ -87,13 +89,22 @@ module RIO
|
|
87
89
|
end
|
88
90
|
self
|
89
91
|
end
|
90
|
-
|
92
|
+
def puts(*args)
|
93
|
+
handle.puts(*args)
|
94
|
+
end
|
95
|
+
def each_bytes(nb,&block)
|
96
|
+
until handle.eof?
|
97
|
+
break unless s = handle.read(nb)
|
98
|
+
yield s
|
99
|
+
end
|
100
|
+
self
|
101
|
+
end
|
91
102
|
extend Forwardable
|
92
103
|
def_instance_delegators(:handle,:binmode,:stat,:rewind,
|
93
104
|
:each,:each_byte,:each_line,:gets,:getc,
|
94
105
|
:read,:readlines,:readline,:sysread,
|
95
|
-
:<<,:print,:printf,:
|
96
|
-
:pos,:pos=,:lineno
|
106
|
+
:<<,:print,:printf,:putc,:write,:syswrite,
|
107
|
+
:pos,:pos=,:lineno,:lineno=,
|
97
108
|
:fileno,
|
98
109
|
:close_read,:close_write,
|
99
110
|
:fsync,:sync,:sync=,:fcntl,:ioctl)
|
data/lib/rio/iomode.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
|
@@ -58,7 +58,7 @@ module RIO
|
|
58
58
|
|
59
59
|
def to_s() @mode.to_s end
|
60
60
|
|
61
|
-
abstract_method :primarily_read?, :primarily_write?, :allows_both?
|
61
|
+
abstract_method :primarily_read?, :primarily_write?, :allows_both?, :creates?
|
62
62
|
|
63
63
|
def read_only?()
|
64
64
|
allows_read? and !allows_write?
|
@@ -84,6 +84,7 @@ module RIO
|
|
84
84
|
def allows_both?()
|
85
85
|
@mode[1,1] == '+'
|
86
86
|
end
|
87
|
+
def creates?() primarily_append? || primarily_write? end
|
87
88
|
end
|
88
89
|
class Str < Base
|
89
90
|
include StrMethods
|
data/lib/rio/ios/fail.rb
ADDED
@@ -0,0 +1,107 @@
|
|
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/notsupported'
|
39
|
+
|
40
|
+
module RIO
|
41
|
+
module IOS
|
42
|
+
module Methods
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module RIO
|
48
|
+
module IOS
|
49
|
+
module Fail #:nodoc: all
|
50
|
+
def notsupported(sym)
|
51
|
+
raise RIO::Exception::NotSupported,RIO::Exception::NotSupported.emsg(sym,self)
|
52
|
+
end
|
53
|
+
|
54
|
+
def <<(obj) notsupported(:<<) end
|
55
|
+
def binmode() notsupported(:binmode) end
|
56
|
+
def close() notsupported(:close) end
|
57
|
+
def close_read() notsupported(:close_read) end
|
58
|
+
def close_write() notsupported(:close_write) end
|
59
|
+
def closed?() notsupported(:closed?) end
|
60
|
+
def each(sep_string=$/,&block) notsupported(:each) end
|
61
|
+
def each_line(sep_string=$/,&block) notsupported(:each_line) end
|
62
|
+
def each_byte(sep_string=$/,&block) notsupported(:each_byte) end
|
63
|
+
def eof?() notsupported(:eof?) end
|
64
|
+
def fcntl(integer_cmd,arg) notsupported(:fcntl) end
|
65
|
+
def fileno() notsupported(:fileno) end
|
66
|
+
def to_i() notsupported(:to_i) end
|
67
|
+
def flush() notsupported(:flush) end
|
68
|
+
def fsync() notsupported(:fsync) end
|
69
|
+
def getc() notsupported(:getc) end
|
70
|
+
def gets(sep_string=$/) notsupported(:gets) end
|
71
|
+
def ioctl(integer_cmd,arg) notsupported(:ioctl) end
|
72
|
+
def isatty() notsupported(:isatty) end
|
73
|
+
def tty?() notsupported(:tty?) end
|
74
|
+
def lineno() notsupported(:lineno) end
|
75
|
+
def lineno=(a) notsupported(:lineno=) end
|
76
|
+
def pid() notsupported(:pid) end
|
77
|
+
def pos() notsupported(:pos) end
|
78
|
+
def tell() notsupported(:tell) end
|
79
|
+
def pos=(v) notsupported(:pos=) end
|
80
|
+
def print(*objs) notsupported(:print) end
|
81
|
+
def printf(format,*objs) notsupported(:printf) end
|
82
|
+
def putc(obj) notsupported(:putc) end
|
83
|
+
def puts(*objs) notsupported(:puts) end
|
84
|
+
def read(*args) notsupported(:read) end
|
85
|
+
def readchar() notsupported(:readchar) end
|
86
|
+
def readline(sep_string=$/) notsupported(:readline) end
|
87
|
+
def readlines(sep_string=$/) notsupported(:readlines) end
|
88
|
+
def readpartial(maxlen,*args) notsupported(:readpartial) end
|
89
|
+
def reopen(*args) notsupported(:reopen) end
|
90
|
+
def rewind() notsupported(:rewind) end
|
91
|
+
def seek() notsupported(:seek) end
|
92
|
+
def stat() notsupported(:stat) end
|
93
|
+
def sync() notsupported(:sync) end
|
94
|
+
def sync=(v) notsupported(:sync=) end
|
95
|
+
def sysread() notsupported(:sysread) end
|
96
|
+
def sysseek() notsupported(:sysseek) end
|
97
|
+
def syswrite() notsupported(:syswrite) end
|
98
|
+
def ungetc() notsupported(:ungetc) end
|
99
|
+
def write(str) notsupported(:write) end
|
100
|
+
|
101
|
+
def callstr(func,*args)
|
102
|
+
self.class.to_s+'['+self.to_s+']'+'.'+func.to_s+'('+args.join(',')+')'
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,120 @@
|
|
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/notsupported'
|
39
|
+
|
40
|
+
module RIO
|
41
|
+
class GenericIOMode #:nodoc: all
|
42
|
+
def initialize(mode_string)
|
43
|
+
@str = mode_string
|
44
|
+
end
|
45
|
+
def to_s() @str end
|
46
|
+
def can_write?
|
47
|
+
@str =~ /^[aw]/ or @str =~ /\+/
|
48
|
+
end
|
49
|
+
def can_read?
|
50
|
+
@str =~ /^r/ or @str =~ /\+/
|
51
|
+
end
|
52
|
+
def appends?
|
53
|
+
@str =~ /^a/
|
54
|
+
end
|
55
|
+
def =~(re)
|
56
|
+
re =~ @str
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
module RIO
|
62
|
+
module IOS
|
63
|
+
class Generic #:nodoc: all
|
64
|
+
def initialize(el,m='r')
|
65
|
+
end
|
66
|
+
|
67
|
+
def <<(obj) self end
|
68
|
+
def binmode() self end
|
69
|
+
def close() nil end
|
70
|
+
def close_read() nil end
|
71
|
+
def close_write() nil end
|
72
|
+
def closed?() true end
|
73
|
+
def each(sep_string=$/,&block) self end
|
74
|
+
def each_line(sep_string=$/,&block) self end
|
75
|
+
def each_byte(sep_string=$/,&block) nil end
|
76
|
+
def eof?() true end
|
77
|
+
def fcntl(integer_cmd,arg) nil end
|
78
|
+
def fileno() nil end
|
79
|
+
def to_i() nil end
|
80
|
+
def flush() self end
|
81
|
+
def fsync() nil end
|
82
|
+
def getc() nil end
|
83
|
+
def gets(sep_string=$/) nil end
|
84
|
+
def ioctl(integer_cmd,arg) nil end
|
85
|
+
def isatty() false end
|
86
|
+
def tty?() false end
|
87
|
+
def lineno() 0 end
|
88
|
+
def lineno=(a) nil end
|
89
|
+
def pid() nil end
|
90
|
+
def pos() nil end
|
91
|
+
def tell() nil end
|
92
|
+
def pos=(v) self.pos end
|
93
|
+
def print(*objs) nil end
|
94
|
+
def printf(format,*objs) nil end
|
95
|
+
def putc(obj) nil end
|
96
|
+
def puts(*objs) nil end
|
97
|
+
def read(*args) nil end
|
98
|
+
def readchar() nil end
|
99
|
+
def readline(sep_string=$/) nil end
|
100
|
+
def readlines(sep_string=$/) [] end
|
101
|
+
def readpartial(maxlen,*args) end
|
102
|
+
def reopen(*args) self end
|
103
|
+
def rewind() 0 end
|
104
|
+
def seek() 0 end
|
105
|
+
def stat() nil end
|
106
|
+
def sync() nil end
|
107
|
+
def sync=(v) nil end
|
108
|
+
def sysread() 0 end
|
109
|
+
def sysseek() 0 end
|
110
|
+
def syswrite() 0 end
|
111
|
+
def ungetc() nil end
|
112
|
+
def write(str) 0 end
|
113
|
+
|
114
|
+
def callstr(func,*args)
|
115
|
+
self.class.to_s+'['+self.to_s+']'+'.'+func.to_s+'('+args.join(',')+')'
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|