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/ios/mode.rb
ADDED
@@ -0,0 +1,61 @@
|
|
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
|
+
class Mode #:nodoc: all
|
43
|
+
def initialize(mode_string)
|
44
|
+
@str = mode_string
|
45
|
+
end
|
46
|
+
def to_s() @str end
|
47
|
+
def can_write?
|
48
|
+
@str =~ /^[aw]/ or @str =~ /\+/
|
49
|
+
end
|
50
|
+
def can_read?
|
51
|
+
@str =~ /^r/ or @str =~ /\+/
|
52
|
+
end
|
53
|
+
def appends?
|
54
|
+
@str =~ /^a/
|
55
|
+
end
|
56
|
+
def =~(re)
|
57
|
+
re =~ @str
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/rio/ios/null.rb
ADDED
@@ -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
|
+
require 'rio/ios/mode'
|
40
|
+
module RIO
|
41
|
+
module IOS
|
42
|
+
module Methods
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
module RIO
|
47
|
+
module IOS
|
48
|
+
module Exception
|
49
|
+
class NotDuplex < RIO::Exception::Base
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
module RIO
|
56
|
+
module IOS
|
57
|
+
class Null #:nodoc: all
|
58
|
+
def initialize(el=nil,m='r')
|
59
|
+
@lineno = 0
|
60
|
+
@open = true
|
61
|
+
@mode = Mode.new(m)
|
62
|
+
@pos = 0
|
63
|
+
end
|
64
|
+
require 'rio/ios/fail'
|
65
|
+
include Fail
|
66
|
+
|
67
|
+
def <<(obj) self end
|
68
|
+
def binmode() self end
|
69
|
+
def close() @open = false end
|
70
|
+
def close_read() raise Exception::NotDuplex end
|
71
|
+
def close_write() raise Exception::NotDuplex end
|
72
|
+
def closed?() not @open 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) self end
|
76
|
+
def eof?() true end
|
77
|
+
#def fcntl(integer_cmd,arg) notsupported(:fcntl) end
|
78
|
+
#def fileno() notsupported(:fileno) end
|
79
|
+
#def to_i() notsupported(:to_i) end
|
80
|
+
def flush() nil end
|
81
|
+
def fsync() nil end
|
82
|
+
def getc() nil end
|
83
|
+
def gets(sep_string=$/) nil end
|
84
|
+
#def ioctl(integer_cmd,arg) notsupported(:ioctl) end
|
85
|
+
def tty?() false end
|
86
|
+
def isatty() tty? end
|
87
|
+
def lineno() @lineno end
|
88
|
+
def lineno=(a) @lineno = a; lineno() end
|
89
|
+
#def pid() notsupported(:pid) end
|
90
|
+
def pos() 0 end
|
91
|
+
def tell() pos() end
|
92
|
+
def pos=(v) @pos = v; 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(length=nil,*args) length.nil? ? "" : nil end
|
98
|
+
def readchar() raise EOFError end
|
99
|
+
def readline(sep_string=$/) raise EOFError end
|
100
|
+
def readlines(sep_string=$/) [] end
|
101
|
+
def readpartial(maxlen,*args) raise EOFError end
|
102
|
+
def reopen(*args) self end
|
103
|
+
def rewind() 0 end
|
104
|
+
def seek(amount,whence) 0 end
|
105
|
+
#def stat() notsupported(:stat) end
|
106
|
+
#def sync() notsupported(:sync) end
|
107
|
+
#def sync=(v) notsupported(:sync=) end
|
108
|
+
#def sysread() notsupported(:sysread) end
|
109
|
+
#def sysseek() notsupported(:sysseek) end
|
110
|
+
#def syswrite() notsupported(:syswrite) end
|
111
|
+
#def ungetc() notsupported(:ungetc) end
|
112
|
+
def write(str) str.length 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
|
data/lib/rio/iowrap.rb
ADDED
@@ -0,0 +1,129 @@
|
|
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 'fileutils'
|
39
|
+
|
40
|
+
module RIO
|
41
|
+
module IOWrap #:nodoc: all
|
42
|
+
class Base
|
43
|
+
attr :ios
|
44
|
+
def initialize(ios)
|
45
|
+
@ios = ios
|
46
|
+
end
|
47
|
+
def initialize_copy(other)
|
48
|
+
super
|
49
|
+
@ios = other.ios.clone unless other.ios.nil?
|
50
|
+
end
|
51
|
+
def callstr(func,*args)
|
52
|
+
self.class.to_s+'['+self.to_s+']'+'.'+func.to_s+'('+args.join(',')+')'
|
53
|
+
end
|
54
|
+
def handle() @ios end
|
55
|
+
def open?() not closed? end
|
56
|
+
end
|
57
|
+
class Stream < Base
|
58
|
+
attr_reader :eof
|
59
|
+
def initialize(ios)
|
60
|
+
@eof = false
|
61
|
+
@closed = false
|
62
|
+
super
|
63
|
+
end
|
64
|
+
def close()
|
65
|
+
@closed = true
|
66
|
+
handle.close
|
67
|
+
end
|
68
|
+
def closed?()
|
69
|
+
@closed
|
70
|
+
end
|
71
|
+
def eof?() @eof end
|
72
|
+
|
73
|
+
def each(*args,&block)
|
74
|
+
rtn = handle.each(*args,&block)
|
75
|
+
@eof = true
|
76
|
+
rtn
|
77
|
+
end
|
78
|
+
alias :each_line :each
|
79
|
+
def gets(*args)
|
80
|
+
@eof = true unless ans = handle.gets(*args)
|
81
|
+
ans
|
82
|
+
end
|
83
|
+
def getc(*args)
|
84
|
+
@eof = true unless ans = handle.getc(*args)
|
85
|
+
ans
|
86
|
+
end
|
87
|
+
def readlines(*args)
|
88
|
+
rtn = handle.readlines(*args)
|
89
|
+
@eof = true
|
90
|
+
rtn
|
91
|
+
end
|
92
|
+
def readline(*args)
|
93
|
+
begin
|
94
|
+
return handle.readline
|
95
|
+
rescue EOFError
|
96
|
+
@eof = true
|
97
|
+
raise
|
98
|
+
end
|
99
|
+
end
|
100
|
+
def read(*args)
|
101
|
+
@eof = true unless ans = handle.read(*args)
|
102
|
+
ans
|
103
|
+
end
|
104
|
+
def sysread(*args)
|
105
|
+
@eof = true unless ans = handle.sysread(*args)
|
106
|
+
ans
|
107
|
+
end
|
108
|
+
# extend Forwardable
|
109
|
+
# def_instance_delegators(:handle,
|
110
|
+
# :binmode,
|
111
|
+
# :stat,
|
112
|
+
# :rewind,
|
113
|
+
# :<<,:print,:printf,:puts,:putc,:write,:syswrite,
|
114
|
+
# :pos,:pos=,:lineno,:lineno=,
|
115
|
+
# :fileno,
|
116
|
+
# :close_read,:close_write,
|
117
|
+
# :fsync,:sync,:sync=,:fcntl,:ioctl)
|
118
|
+
|
119
|
+
#def puts(*args)
|
120
|
+
# handle.puts(*args)
|
121
|
+
#end
|
122
|
+
def method_missing(sym,*args,&block)
|
123
|
+
#p callstr('method_missing',sym,*args)
|
124
|
+
handle.__send__(sym,*args,&block)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
__END__
|
data/lib/rio/kernel.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,9 @@
|
|
35
35
|
# The documented interface and behavior is subject to change without notice.</b>
|
36
36
|
|
37
37
|
|
38
|
+
require 'rio/def'
|
38
39
|
|
39
40
|
module Kernel
|
40
|
-
require 'rio'
|
41
41
|
# Shortcut for RIO.rio
|
42
42
|
def rio(*args,&block) # :yields: self
|
43
43
|
RIO::Rio.rio(*args,&block)
|
@@ -45,3 +45,12 @@ module Kernel
|
|
45
45
|
module_function :rio
|
46
46
|
alias :io :rio
|
47
47
|
end
|
48
|
+
|
49
|
+
module RIO
|
50
|
+
# See also: RIO::Doc::SYNOPSIS; RIO::Doc::INTRO; RIO::Doc::HOWTO.
|
51
|
+
class Rio < Base #:doc:
|
52
|
+
undef_method(:rio)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
require 'rio'
|
data/lib/rio/local.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/match.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
|
@@ -44,7 +44,7 @@ module RIO
|
|
44
44
|
case cx['ss_type']
|
45
45
|
when nil
|
46
46
|
keys[0]
|
47
|
-
|
47
|
+
else
|
48
48
|
cx['ss_type']
|
49
49
|
end
|
50
50
|
end
|
data/lib/rio/matchrecord.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/no_warn.rb
ADDED
@@ -0,0 +1,50 @@
|
|
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
|
+
# Based on a suggestion posted by Andrew L. Johnson to comp.lang.ruby
|
40
|
+
def no_warn
|
41
|
+
begin
|
42
|
+
verbose = $VERBOSE
|
43
|
+
$VERBOSE = nil
|
44
|
+
yield
|
45
|
+
ensure
|
46
|
+
$VERBOSE = verbose
|
47
|
+
end
|
48
|
+
end
|
49
|
+
module_function :no_warn
|
50
|
+
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
|
@@ -43,7 +43,7 @@ module RIO
|
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
46
|
-
class
|
46
|
+
class NullIOMode #:nodoc: all
|
47
47
|
def initialize(mode_string)
|
48
48
|
@str = mode_string
|
49
49
|
end
|
@@ -61,39 +61,17 @@ module RIO
|
|
61
61
|
re =~ @str
|
62
62
|
end
|
63
63
|
end
|
64
|
-
class
|
65
|
-
attr_accessor :array,:lineno,:mode,:ln
|
66
|
-
def initialize(a,m)
|
67
|
-
@array = a || []
|
68
|
-
@mode = AIOMode.new(m)
|
69
|
-
@lineno = 0
|
70
|
-
@ln = 0
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class ArrayIO #:nodoc: all
|
64
|
+
class NullIO #:nodoc: all
|
75
65
|
def initialize(a=nil,m='r')
|
76
66
|
# p "#{callstr('initialize',a,m)} hnd=#{@hnd.inspect}"
|
77
|
-
|
78
|
-
|
79
|
-
@
|
80
|
-
_open(@hnd.mode)
|
81
|
-
end
|
82
|
-
def array() @hnd.array end
|
83
|
-
def array=(a) @hnd.array = a end
|
84
|
-
def lineno() @hnd.lineno end
|
85
|
-
def lineno=(a) @hnd.lineno = a end
|
86
|
-
def to_a() array.dup end
|
87
|
-
|
88
|
-
def _open(m)
|
89
|
-
@hnd.mode = AIOMode.new(m.to_s)
|
90
|
-
@hnd.ln = 0
|
91
|
-
# p m.to_s,@hnd.mode.to_s,@hnd.array
|
92
|
-
@hnd.array.clear if @hnd.mode.to_s =~ /^w/
|
93
|
-
@hnd.ln = @hnd.array.size if @hnd.mode.to_s =~ /^a/
|
67
|
+
@lineno = 0
|
68
|
+
@open = true
|
69
|
+
@mode = NullIOMode.new(m)
|
94
70
|
end
|
71
|
+
def lineno() @lineno end
|
72
|
+
def lineno=(a) @lineno = a end
|
95
73
|
def self.open(a=nil,m='r',&block)
|
96
|
-
rtn = io =
|
74
|
+
rtn = io = new(a,m)
|
97
75
|
if block_given?
|
98
76
|
rtn = yield(io)
|
99
77
|
io.close
|
@@ -105,89 +83,72 @@ module RIO
|
|
105
83
|
def fsync() nil end
|
106
84
|
def isatty() false end
|
107
85
|
def tty?() false end
|
108
|
-
def pos()
|
109
|
-
def pos=(n)
|
86
|
+
def pos() 0 end
|
87
|
+
def pos=(n) 0 end
|
110
88
|
|
111
|
-
def readchar()
|
112
|
-
def read()
|
113
|
-
def getc()
|
89
|
+
def readchar() nil end
|
90
|
+
def read() nil end
|
91
|
+
def getc() nil end
|
114
92
|
|
115
93
|
def closed?
|
116
|
-
@
|
117
|
-
end
|
118
|
-
def close_read
|
119
|
-
@hnd.ln = @hnd.lineno = nil
|
120
|
-
end
|
121
|
-
def close_write
|
122
|
-
@hnd.ln = nil
|
94
|
+
not @open
|
123
95
|
end
|
124
96
|
def close
|
125
|
-
|
126
|
-
close_write
|
97
|
+
@open = false
|
127
98
|
end
|
128
99
|
def eof?()
|
129
|
-
|
130
|
-
@hnd.ln >= @hnd.array.size
|
100
|
+
true
|
131
101
|
end
|
132
102
|
def each_line(sep_string=$/,&block)
|
133
|
-
while line = gets(sep_string)
|
134
|
-
yield(line)
|
135
|
-
end
|
136
103
|
self
|
137
104
|
end
|
105
|
+
def each_byte(sep_string=$/,&block)
|
106
|
+
nil
|
107
|
+
end
|
108
|
+
def fcntl(integer_cmd,arg)
|
109
|
+
raise NotSupportedException,NotSupportedException.emsg('fcntl',self)
|
110
|
+
end
|
111
|
+
def ioctl(integer_cmd,arg)
|
112
|
+
raise NotSupportedException,NotSupportedException.emsg('fcntl',self)
|
113
|
+
end
|
138
114
|
alias each each_line
|
139
115
|
def gets(sep_string=$/)
|
140
|
-
raise IOError,"
|
141
|
-
|
142
|
-
str = nil
|
143
|
-
if sep_string.nil?
|
144
|
-
str = @hnd.array[@hnd.ln...@hnd.array.size].join('')
|
145
|
-
@hnd.lineno += @hnd.array.size - @hnd.ln
|
146
|
-
@hnd.ln = @hnd.array.size
|
147
|
-
else
|
148
|
-
str = @hnd.array[@hnd.ln]
|
149
|
-
@hnd.lineno += 1
|
150
|
-
@hnd.ln += 1
|
151
|
-
end
|
152
|
-
$_ = str
|
116
|
+
raise IOError,"NullIO is not open for reading" unless @mode.can_read?
|
117
|
+
nil
|
153
118
|
end
|
154
119
|
def readline(sep_string=$/)
|
155
|
-
raise EOFError
|
156
|
-
str
|
120
|
+
raise EOFError
|
157
121
|
end
|
158
122
|
|
159
123
|
def readlines(sep_string=$/)
|
160
|
-
|
161
|
-
until eof?
|
162
|
-
ary.push(gets(sep_string))
|
163
|
-
end
|
164
|
-
ary
|
124
|
+
[]
|
165
125
|
end
|
166
126
|
def rewind
|
167
|
-
@
|
127
|
+
@lineno = 0
|
168
128
|
end
|
169
129
|
def print(*objs)
|
170
|
-
raise IOError,"
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
end
|
130
|
+
raise IOError,"NullIO is not open for writing" unless @mode.can_write?
|
131
|
+
nil
|
132
|
+
end
|
133
|
+
def close_read(*objs)
|
134
|
+
raise IOError,"NullIO is not a duplex stream"
|
135
|
+
nil
|
136
|
+
end
|
137
|
+
def close_write(*objs)
|
138
|
+
raise IOError,"NullIO is not a duplex stream"
|
180
139
|
nil
|
181
140
|
end
|
182
141
|
def <<(obj)
|
183
|
-
print(obj.to_s)
|
184
142
|
self
|
185
143
|
end
|
186
144
|
def puts(*objs)
|
187
|
-
|
188
|
-
|
189
|
-
|
145
|
+
nil
|
146
|
+
end
|
147
|
+
def write(string)
|
148
|
+
print(string)
|
149
|
+
string.size
|
190
150
|
end
|
151
|
+
def binmode() nil end
|
191
152
|
def printf(fmt,*args)
|
192
153
|
print(sprintf(fmt,*args))
|
193
154
|
end
|
data/lib/rio/open3.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
|