rio 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. data/ChangeLog +1273 -1482
  2. data/README +2 -2
  3. data/Rakefile +5 -5
  4. data/VERSION +1 -1
  5. data/{RUNME.1st.rb → build_doc.rb} +4 -10
  6. data/doc/ANNOUNCE +33 -80
  7. data/doc/RELEASE_NOTES +31 -1
  8. data/doc/generators/template/html/rio.rb +3 -3
  9. data/lib/rio/abstract_method.rb +2 -2
  10. data/lib/rio/argv.rb +2 -2
  11. data/lib/rio/arycopy.rb +2 -2
  12. data/lib/rio/assert.rb +2 -2
  13. data/lib/rio/base.rb +2 -2
  14. data/lib/rio/callstr.rb +47 -0
  15. data/lib/rio/const.rb +52 -0
  16. data/lib/rio/construct.rb +6 -24
  17. data/lib/rio/constructor.rb +12 -2
  18. data/lib/rio/context/autoclose.rb +73 -0
  19. data/lib/rio/context/copying.rb +2 -2
  20. data/lib/rio/context/cxx.rb +2 -2
  21. data/lib/rio/context/dir.rb +2 -2
  22. data/lib/rio/context/gzip.rb +2 -2
  23. data/lib/rio/context/methods.rb +6 -34
  24. data/lib/rio/context/skip.rb +2 -2
  25. data/lib/rio/context/stream.rb +2 -2
  26. data/lib/rio/context.rb +17 -2
  27. data/lib/rio/cp.rb +35 -9
  28. data/lib/rio/def.rb +54 -0
  29. data/lib/rio/dir.rb +19 -20
  30. data/lib/rio/doc/HOWTO.rb +23 -7
  31. data/lib/rio/doc/INTRO.rb +57 -23
  32. data/lib/rio/doc/MISC.rb +2 -2
  33. data/lib/rio/doc/OPTIONAL.rb +134 -0
  34. data/lib/rio/doc/SYNOPSIS.rb +11 -4
  35. data/lib/rio/doc.rb +2 -2
  36. data/lib/rio/entrysel.rb +25 -6
  37. data/lib/rio/exception/copy.rb +2 -2
  38. data/lib/rio/exception/notsupported.rb +47 -0
  39. data/lib/rio/exception/open.rb +2 -2
  40. data/lib/rio/exception/state.rb +2 -2
  41. data/lib/rio/exception.rb +2 -2
  42. data/lib/rio/ext/csv.rb +56 -11
  43. data/lib/rio/ext/yaml.rb +2 -2
  44. data/lib/rio/ext/zipfile.rb +91 -0
  45. data/lib/rio/ext.rb +38 -3
  46. data/lib/rio/factory.rb +17 -34
  47. data/lib/rio/file.rb +48 -8
  48. data/lib/rio/filter/closeoneof.rb +36 -16
  49. data/lib/rio/filter/gzip.rb +2 -2
  50. data/lib/rio/filter.rb +2 -2
  51. data/lib/rio/fs/base.rb +42 -0
  52. data/lib/rio/fs/impl.rb +123 -0
  53. data/lib/rio/fs/native.rb +76 -0
  54. data/lib/rio/{record.rb → fs/stream.rb} +21 -18
  55. data/lib/rio/fs/url.rb +64 -0
  56. data/lib/rio/ftp/{ioh.rb → conncache.rb} +38 -39
  57. data/lib/rio/ftp/dir.rb +95 -0
  58. data/lib/rio/ftp/fs.rb +173 -0
  59. data/lib/rio/ftp/ftpfile.rb +20 -0
  60. data/lib/rio/grande.rb +2 -2
  61. data/lib/rio/handle.rb +2 -2
  62. data/lib/rio/if/basic.rb +2 -2
  63. data/lib/rio/if/csv.rb +2 -2
  64. data/lib/rio/if/dir.rb +2 -2
  65. data/lib/rio/if/file.rb +26 -2
  66. data/lib/rio/if/fileordir.rb +44 -49
  67. data/lib/rio/if/grande.rb +32 -10
  68. data/lib/rio/if/grande_entry.rb +12 -2
  69. data/lib/rio/if/grande_stream.rb +17 -28
  70. data/lib/rio/if/internal.rb +2 -2
  71. data/lib/rio/if/path.rb +7 -6
  72. data/lib/rio/if/stream.rb +85 -29
  73. data/lib/rio/if/string.rb +2 -2
  74. data/lib/rio/if/temp.rb +2 -2
  75. data/lib/rio/if/test.rb +37 -4
  76. data/lib/rio/if/yaml.rb +2 -2
  77. data/lib/rio/if.rb +2 -2
  78. data/lib/rio/impl/path.rb +2 -2
  79. data/lib/rio/ioh.rb +17 -6
  80. data/lib/rio/iomode.rb +4 -3
  81. data/lib/rio/ios/fail.rb +107 -0
  82. data/lib/rio/ios/generic.rb +120 -0
  83. data/lib/rio/ios/mode.rb +61 -0
  84. data/lib/rio/ios/null.rb +120 -0
  85. data/lib/rio/iowrap.rb +129 -0
  86. data/lib/rio/kernel.rb +12 -3
  87. data/lib/rio/local.rb +2 -2
  88. data/lib/rio/match.rb +3 -3
  89. data/lib/rio/matchrecord.rb +2 -2
  90. data/lib/rio/no_warn.rb +50 -0
  91. data/lib/rio/{arrayio.rb → nullio.rb} +47 -86
  92. data/lib/rio/open3.rb +2 -2
  93. data/lib/rio/ops/construct.rb +20 -13
  94. data/lib/rio/ops/create.rb +10 -19
  95. data/lib/rio/ops/dir.rb +60 -54
  96. data/lib/rio/ops/either.rb +11 -9
  97. data/lib/rio/ops/file.rb +28 -24
  98. data/lib/rio/ops/path.rb +45 -43
  99. data/lib/rio/ops/stream/input.rb +12 -8
  100. data/lib/rio/ops/stream/output.rb +2 -2
  101. data/lib/rio/ops/stream/read.rb +35 -32
  102. data/lib/rio/ops/stream/write.rb +5 -5
  103. data/lib/rio/ops/stream.rb +7 -3
  104. data/lib/rio/ops/symlink.rb +12 -10
  105. data/lib/rio/path/reset.rb +5 -5
  106. data/lib/rio/path.rb +32 -24
  107. data/lib/rio/piper/cp.rb +2 -2
  108. data/lib/rio/piper.rb +2 -2
  109. data/lib/rio/prompt.rb +2 -2
  110. data/lib/rio/rectype.rb +9 -7
  111. data/lib/rio/rl/base.rb +5 -4
  112. data/lib/rio/rl/builder.rb +17 -5
  113. data/lib/rio/rl/ioi.rb +14 -4
  114. data/lib/rio/rl/path.rb +23 -15
  115. data/lib/rio/rl/pathmethods.rb +12 -2
  116. data/lib/rio/rl/uri.rb +13 -6
  117. data/lib/rio/scheme/aryio.rb +3 -3
  118. data/lib/rio/scheme/cmdio.rb +4 -3
  119. data/lib/rio/scheme/cmdpipe.rb +3 -35
  120. data/lib/rio/scheme/fd.rb +4 -3
  121. data/lib/rio/scheme/ftp.rb +36 -7
  122. data/lib/rio/scheme/http.rb +2 -2
  123. data/lib/rio/{context/closeoneof.rb → scheme/null.rb} +17 -11
  124. data/lib/rio/scheme/path.rb +28 -30
  125. data/lib/rio/scheme/stderr.rb +4 -4
  126. data/lib/rio/scheme/stdio.rb +6 -5
  127. data/lib/rio/scheme/strio.rb +10 -20
  128. data/lib/rio/scheme/sysio.rb +5 -2
  129. data/lib/rio/scheme/tcp.rb +4 -3
  130. data/lib/rio/scheme/temp.rb +14 -1
  131. data/lib/rio/state/error.rb +2 -2
  132. data/lib/rio/state.rb +80 -34
  133. data/lib/rio/stream/base.rb +7 -2
  134. data/lib/rio/stream/duplex.rb +13 -10
  135. data/lib/rio/stream/open.rb +74 -79
  136. data/lib/rio/stream.rb +15 -23
  137. data/lib/rio/symantics.rb +2 -2
  138. data/lib/rio/tempdir.rb +132 -132
  139. data/lib/rio/to_rio/all.rb +40 -0
  140. data/lib/rio/to_rio/array.rb +40 -0
  141. data/lib/rio/to_rio/io.rb +41 -0
  142. data/lib/rio/to_rio/object.rb +43 -0
  143. data/lib/rio/to_rio/string.rb +41 -0
  144. data/lib/rio/to_rio.rb +13 -2
  145. data/lib/rio/uri/file.rb +2 -2
  146. data/lib/rio/util.rb +2 -2
  147. data/lib/rio/version.rb +3 -3
  148. data/lib/rio.rb +16 -25
  149. data/test/bin/count_lines.rb +11 -0
  150. data/test/bin/find_lines.rb +13 -0
  151. data/test/bin/list_dir.rb +14 -0
  152. data/test/ftp/all.rb +9 -0
  153. data/test/ftp/anon_misc.rb +112 -0
  154. data/test/ftp/anon_read.rb +105 -0
  155. data/test/ftp/anon_special.rb +68 -0
  156. data/test/ftp/anon_write.rb +63 -0
  157. data/test/ftp/ftp2ftp.rb +51 -0
  158. data/test/ftp/initftpfiles.rb +14 -0
  159. data/test/ftp/testdef.rb +51 -0
  160. data/test/gem_runtests.rb +15 -15
  161. data/test/runalltests.rb +15 -0
  162. data/test/runftptests.rb +14 -0
  163. data/test/{1.rb → runhttptests.rb} +14 -14
  164. data/test/runtests.rb +14 -14
  165. data/test/tc/all.rb +36 -21
  166. data/test/tc/cmdpipe.rb +18 -15
  167. data/test/tc/copy-from-http.rb +89 -0
  168. data/test/tc/copy-from.rb +1 -52
  169. data/test/tc/copy.rb +19 -17
  170. data/test/tc/csv2.rb +6 -3
  171. data/test/tc/empty.rb +47 -0
  172. data/test/tc/emptyriodir.rb +129 -0
  173. data/test/tc/entsel.rb +110 -0
  174. data/test/tc/files_select.rb +92 -0
  175. data/test/tc/get.rb +7 -6
  176. data/test/tc/getrec.rb +2 -5
  177. data/test/tc/gzip.rb +82 -0
  178. data/test/tc/io_each_byte.rb +60 -0
  179. data/test/tc/io_read.rb +80 -0
  180. data/test/tc/iometh.rb +149 -0
  181. data/test/tc/likeio.rb +112 -0
  182. data/test/tc/methods.rb +10 -9
  183. data/test/tc/misc.rb +1 -37
  184. data/test/tc/null.rb +45 -0
  185. data/test/tc/pid.rb +31 -0
  186. data/test/tc/piper.rb +34 -37
  187. data/test/tc/programs_util.rb +24 -0
  188. data/test/tc/readline.rb +30 -0
  189. data/test/tc/rename.rb +12 -0
  190. data/test/tc/tempfile.rb +14 -0
  191. data/test/tc/testcase.rb +6 -0
  192. data/test/tc/tonl.rb +37 -0
  193. metadata +181 -144
  194. data/ex/colx.rb +0 -8
  195. data/ex/findinruby +0 -16
  196. data/ex/findruby +0 -15
  197. data/ex/passwd_report.rb +0 -8
  198. data/ex/prompt.rb +0 -25
  199. data/ex/rgb.txt.gz +0 -0
  200. data/ex/riocat +0 -35
  201. data/ex/riogunzip +0 -31
  202. data/ex/riogzip +0 -24
  203. data/ex/rioprompt.rb +0 -6
  204. data/ex/targz2zip +0 -17
  205. data/ex/tolf +0 -11
  206. data/lib/rio/ftp/conn.rb +0 -167
  207. data/lib/rio/ftp.rb +0 -275
  208. data/test/once.rb +0 -7
@@ -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
@@ -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
- # rake rdoc
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
- # rake rdoc
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
- # rake rdoc
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
- else
47
+ else
48
48
  cx['ss_type']
49
49
  end
50
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
- # rake rdoc
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,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
- # rake rdoc
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 AIOMode #:nodoc: all
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 AIOH #:nodoc: all
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
- raise ArgumentError,"ArrayIO.new() requires an array but got #{a.inspect}" unless a.kind_of?(::Array)
78
- a = a.array if a.kind_of?(ArrayIO)
79
- @hnd = AIOH.new(a,m)
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 = self.class.new(a,m)
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() @hnd.ln end
109
- def pos=(n) @hnd.ln = n end
86
+ def pos() 0 end
87
+ def pos=(n) 0 end
110
88
 
111
- def readchar() raise NotSupportedException,NotSupportedException.emsg('readchar',self) end
112
- def read() raise NotSupportedException,NotSupportedException.emsg('read',self) end
113
- def getc() raise NotSupportedException,NotSupportedException.emsg('getc',self) end
89
+ def readchar() nil end
90
+ def read() nil end
91
+ def getc() nil end
114
92
 
115
93
  def closed?
116
- @hnd.ln.nil?
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
- close_read
126
- close_write
97
+ @open = false
127
98
  end
128
99
  def eof?()
129
- raise IOError,"ArrayIO is not open for reading" unless @hnd.mode.can_read?
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,"ArrayIO is not open for reading" unless @hnd.mode.can_read?
141
- return nil if @hnd.ln >= @hnd.array.size
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 unless str = gets(sep_string)
156
- str
120
+ raise EOFError
157
121
  end
158
122
 
159
123
  def readlines(sep_string=$/)
160
- ary = []
161
- until eof?
162
- ary.push(gets(sep_string))
163
- end
164
- ary
124
+ []
165
125
  end
166
126
  def rewind
167
- @hnd.ln = @hnd.lineno = 0
127
+ @lineno = 0
168
128
  end
169
129
  def print(*objs)
170
- raise IOError,"ArrayIO is not open for writing" unless @hnd.mode.can_write?
171
- if objs.empty?
172
- @hnd.array[@hnd.ln] = $_
173
- @hnd.ln += 1
174
- else
175
- for obj in objs
176
- @hnd.array[@hnd.ln] = obj.to_s
177
- @hnd.ln += 1
178
- end
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
- for obj in objs
188
- print(obj.to_s.chomp + $/)
189
- end
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
- # rake rdoc
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