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
@@ -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,6 @@ require 'rio/rectype'
43
43
  require 'rio/ops/stream/read'
44
44
  require 'rio/context/stream'
45
45
  require 'stringio'
46
- require 'rio/record'
47
46
  require 'rio/cp'
48
47
  require 'rio/piper/cp'
49
48
 
@@ -73,7 +72,9 @@ module RIO
73
72
  each_(*args,&block)
74
73
  self
75
74
  end
76
-
75
+ def empty?()
76
+ self.eof?
77
+ end
77
78
  def each_record(*args,&block)
78
79
  #p callstr('each_record',*args)
79
80
  each_record_(*args,&block)
@@ -91,6 +92,9 @@ module RIO
91
92
  raw_rec = self._get_rec
92
93
  return to_rec_(raw_rec) if @get_selrej.match?(raw_rec,@recno)
93
94
  end
95
+ self.close if closeoneof?
96
+ nil
97
+ # (closeoneof? ? self.on_eof_close{ nil } : nil)
94
98
  end
95
99
  def get_type(itertype,&block)
96
100
  old_itertype = cx['stream_itertype']
@@ -138,9 +142,9 @@ module RIO
138
142
  end
139
143
  end
140
144
  end
141
- return self
145
+ return closeoneof? ? self.close : self
142
146
  end
143
- closeoneof? ? ior.close_on_eof_(self) : self
147
+ closeoneof? ? self.close : self
144
148
  end
145
149
 
146
150
  # iterate over the records, yielding only with matching records
@@ -159,7 +163,7 @@ module RIO
159
163
  end
160
164
  return self
161
165
  }
162
- closeoneof? ? ior.close_on_eof_(self) : self
166
+ closeoneof? ? self.close : self
163
167
  end
164
168
  alias :each_row_ :each_
165
169
  def clear_selection()
@@ -204,7 +208,7 @@ module RIO
204
208
  selrej.rangetops
205
209
  end
206
210
 
207
- def on_closeoneof
211
+ def on_closeoneof()
208
212
  #p "on_closeoneof #{self.object_id} #{self.ior.object_id}"
209
213
  self.close
210
214
  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
@@ -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
@@ -40,42 +40,45 @@ module RIO
40
40
  module Ops
41
41
  module Stream
42
42
  module Read
43
- def contents()
44
- auto { ior.gets(nil) }
45
- end
46
- def readlines(*args)
47
- auto { ior.readlines(*args) }
43
+
44
+ private
45
+
46
+ def _post_eof_close(&block)
47
+ rtn = yield
48
+ self.close if closeoneof?
49
+ rtn
48
50
  end
49
- def read(*args)
50
- auto { ior.read(*args) }
51
+ def _pre_eof_close(&block)
52
+ begin
53
+ closit = ior.eof? && closeoneof?
54
+ rtn = yield
55
+ ensure
56
+ self.close if closit
57
+ end
58
+ rtn
51
59
  end
60
+
61
+ public
62
+
63
+ def contents() _post_eof_close { ior.gets(nil) || "" } end
64
+ def readlines(*args) _post_eof_close { ior.readlines(*args) } end
65
+ def each_line(*args,&block) _post_eof_close { ior.each_line(*args,&block) } end
66
+ def each_byte(*args,&block) _post_eof_close { ior.each_byte(*args,&block) } end
67
+ def each_bytes(nb,*args,&block) _post_eof_close { ior.each_bytes(nb,&block) } end
68
+
69
+ def read(*args) _pre_eof_close { ior.read(*args) } end
70
+ def gets(*args) _pre_eof_close { ior.gets(*args) } end
71
+ def readline(*args) _pre_eof_close { ior.readline(*args) } end
72
+ def readpartial(*args) _pre_eof_close { ior.readpartial(*args) } end
73
+ def readchar(*args) _pre_eof_close { ior.readchar(*args) } end
74
+ def getc(*args) _pre_eof_close { ior.getc(*args) } end
75
+
52
76
  def ungetc(*args)
53
77
  ior.ungetc(*args)
54
78
  self
55
79
  end
56
- def each_line(*args,&block)
57
- auto {
58
- # self.ior.each_line(*args,&block)
59
- self.ior.each_line { |line|
60
- yield line
61
- } #(*args,&block)
62
- }
63
- end
64
- def each_byte(*args,&block)
65
- auto { ior.each_byte(*args,&block) }
66
- end
67
- def each_bytes(nb,*args,&block)
68
- #p callstr('each_bytes',nb,*args)
69
- auto {
70
- until ior.eof?
71
- break unless s = ior.read(nb)
72
- yield s
73
- end
74
- }
75
- end
76
-
77
- extend Forwardable
78
- def_instance_delegators(:ior,:readline,:readchar,:gets,:lineno)
80
+ def lineno() ior.lineno end
81
+ def lineno=(arg) ior.lineno = arg end
79
82
  end
80
83
  end
81
84
  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
@@ -39,7 +39,9 @@ module RIO
39
39
  module Ops
40
40
  module Stream
41
41
  module Write
42
- def puts(*argv) rtn_self { iow.puts(*argv) } end
42
+ def puts(*argv)
43
+ rtn_self { iow.puts(*argv) }
44
+ end
43
45
  def puts!(*argv) rtn_close { iow.puts(*argv); } end
44
46
  def putc(*argv) rtn_self { iow.putc(*argv) } end
45
47
  def putc!(*argv) rtn_close { iow.putc(*argv) } end
@@ -50,8 +52,6 @@ module RIO
50
52
  def write(*argv) iow.write(*argv) end
51
53
  def write!(*argv) then_close { iow.write(*argv) } end
52
54
  def _!(*argv) self.close.softreset end
53
- # extend Forwardable
54
- # def_instance_de
55
55
  end
56
56
  end
57
57
  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
@@ -48,16 +48,20 @@ module RIO
48
48
  end
49
49
  def closed?() self.ioh.nil? end
50
50
  def eof?() closed? or ior.eof? end
51
+ def stat() ioh ? ioh.stat : nil end #
51
52
  end
52
53
  end
53
54
 
54
55
  module Stream
55
56
  module Manip
57
+ def pid() ioh ? ioh.pid : nil end
58
+ def to_io() ioh ? ioh.to_io : nil end
59
+ def tty?() ioh ? ioh.tty? : false end
60
+ def isatty() ioh ? ioh.isatty : false end
56
61
  def binmode() rtn_self { self.ioh.binmode } end
57
62
  def flush() rtn_self { self.ioh.flush } end
58
63
  def fsync() rtn_self { self.ioh.fsync } end
59
64
  def seek(amount,whence=IO::SEEK_SET) rtn_self { self.ioh.seek(amount,whence) } end
60
-
61
65
  extend Forwardable
62
66
  def_instance_delegators(:ioh,:pos,:pos=,:fileno,:to_i,
63
67
  :fcntl,:ioctl)
@@ -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,18 +35,20 @@
35
35
  # The documented interface and behavior is subject to change without notice.</b>
36
36
 
37
37
 
38
+ # module RIO
39
+ # module Impl
40
+ # module U
41
+ # def self.readlink(s,*args) ::File.readlink(s,*args) end
42
+ # def self.lstat(s,*args) ::File.lstat(s,*args) end
43
+ # end
44
+ # end
45
+ # end
38
46
  module RIO
39
- module Impl
40
- module U
41
- def self.readlink(s,*args) ::File.readlink(s,*args) end
42
- def self.lstat(s,*args) ::File.lstat(s,*args) end
43
- end
44
- end
45
47
  module Ops
46
48
  module Symlink
47
49
  module ExistOrNot
48
- def readlink(*args) new_rio(Impl::U.readlink(self.to_s,*args)) end
49
- def lstat(*args) Impl::U.lstat(self.to_s,*args) end
50
+ def readlink(*args) new_rio(fs.readlink(self.to_s,*args)) end
51
+ def lstat(*args) fs.lstat(self.to_s,*args) end
50
52
 
51
53
  end
52
54
  module Existing
@@ -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
@@ -55,15 +55,15 @@ module RIO
55
55
 
56
56
  def when_missing(sym,*args)
57
57
  # p callstr('when_missing',sym,*args)
58
- if empty?
58
+ if to_s.empty?
59
59
  pathempty()
60
60
  else
61
61
  pathstring()
62
62
  end
63
63
  end
64
64
 
65
- extend Forwardable
66
- def_instance_delegators(:path,:empty?)
65
+ # extend Forwardable
66
+ # def_instance_delegators(:path,:empty?)
67
67
  end
68
68
  end
69
69
 
data/lib/rio/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
- # 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
@@ -49,6 +49,22 @@ module RIO
49
49
  class Empty < State::Base
50
50
  include Ops::Path::Empty
51
51
  def check?() fspath.nil? or fspath.empty? end
52
+ def [](*args)
53
+ self.rl = Path::RL.new('.')
54
+ softreset[*args]
55
+ end
56
+ def each(&block)
57
+ self.rl = Path::RL.new('.')
58
+ softreset.each(&block)
59
+ end
60
+ def read(*args)
61
+ self.rl = Path::RL.new('.')
62
+ softreset.read(*args)
63
+ end
64
+ def get(*args)
65
+ self.rl = Path::RL.new('.')
66
+ softreset.get(*args)
67
+ end
52
68
  def when_missing(sym,*args) gofigure(sym,*args) end
53
69
  end
54
70
 
@@ -68,26 +84,21 @@ module RIO
68
84
  end
69
85
  end
70
86
 
71
- protected
87
+ private
72
88
 
73
- def edir()
74
- #rl.path += '/' unless rl.path.empty? or rl.path[-1] == ?/
75
- next_state = become('Dir::Existing')
76
- next_state.extend(Ops::Symlink::Existing) if symlink?
77
- next_state
78
- end
79
- def efile()
80
- next_state = become('File::Existing')
81
- next_state.extend(Ops::Symlink::Existing) if symlink?
82
- next_state
83
- end
84
- def npath()
85
- next_state = become('Path::NonExisting')
86
- next_state.extend(Ops::Symlink::NonExisting) if symlink?
89
+ def _fs_state(become_state,symlink_mod)
90
+ next_state = become(become_state)
91
+ next_state.extend(symlink_mod) if symlink?
87
92
  next_state
88
93
  end
89
94
 
90
- end # class PathString
95
+ protected
96
+
97
+ def edir() _fs_state('Dir::Existing',Ops::Symlink::Existing) end
98
+ def efile() _fs_state('File::Existing',Ops::Symlink::Existing) end
99
+ def npath() _fs_state('Path::NonExisting',Ops::Symlink::NonExisting) end
100
+
101
+ end
91
102
 
92
103
  # A transition state. Anything but simple path tests must cause a transition out of this state.
93
104
  class NonExisting < State::Base
@@ -96,10 +107,7 @@ module RIO
96
107
 
97
108
  def check?() not exist? end
98
109
 
99
- def ndir()
100
- #rl.path += '/' unless rl.path.empty? or rl.path[-1] == ?/
101
- become('Dir::NonExisting')
102
- end
110
+ def ndir() become 'Dir::NonExisting' end
103
111
  def nfile() become('File::NonExisting') end
104
112
 
105
113
  def when_missing(sym,*args)
@@ -110,8 +118,8 @@ module RIO
110
118
  nfile()
111
119
  end
112
120
  end
113
- end # class NPath
121
+ end
114
122
 
115
- end # module Rsc
123
+ end
116
124
 
117
125
  end
data/lib/rio/piper/cp.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/piper.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/prompt.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/rectype.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
@@ -42,10 +42,11 @@ module RIO
42
42
  def get_arg_() $/ end
43
43
  def get_(sep_string=get_arg_)
44
44
  #p callstr('get_',sep_string.inspect)
45
- self.ioh.gets(sep_string)
45
+ self.ior.gets(sep_string)
46
46
  end
47
47
  def each_rec_(&block)
48
- each_line { |line|
48
+ self.ior.each_line { |line|
49
+ #self.ior.each { |line|
49
50
  yield line
50
51
  }
51
52
  self
@@ -54,8 +55,9 @@ module RIO
54
55
  module Output
55
56
  def put_(rec,*args)
56
57
  #p callstr('put_',rec,*args)
58
+ #p self.ioh
57
59
  self.ioh.print(rec.to_s)
58
- end
60
+ end
59
61
  end
60
62
  end
61
63
  module Bytes
@@ -64,12 +66,12 @@ module RIO
64
66
  cx['bytes_n']
65
67
  end
66
68
  def get_(nb=get_arg_())
67
- self.ioh.read(nb)
69
+ self.ior.read(nb)
68
70
  end
69
71
  def each_rec_(&block)
70
72
  #p callstr('each_rec_ (EachIter::Bytes)')
71
73
  # p 'each_rec_ => each_line'
72
- each_bytes(cx['bytes_n']) { |b|
74
+ self.ior.each_bytes(cx['bytes_n']) { |b|
73
75
  yield b
74
76
  }
75
77
  self
data/lib/rio/rl/base.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
@@ -112,10 +112,11 @@ module RIO
112
112
  SUBSEPAR = ':'
113
113
 
114
114
  class Base
115
+ attr :fs
115
116
  def initialize(*args)
116
-
117
+ @fs = openfs_
117
118
  end
118
-
119
+ def openfs_() nil end
119
120
  def self.subscheme(s)
120
121
  /^rio:([^:]+):/.match(s)[1]
121
122
  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
@@ -47,6 +47,7 @@ module RIO
47
47
  def self.build(*a)
48
48
  #puts "build: #{a.inspect}"
49
49
  a.flatten!
50
+ a.push('') if a.empty?
50
51
  case a[0]
51
52
  when ::String
52
53
  case a[0]
@@ -65,9 +66,10 @@ module RIO
65
66
  when RIO::Rio
66
67
  a[0] = a[0].to_rl
67
68
  when RL::Base
68
- a0 = a.shift
69
+ a0 = a.shift.clone
70
+ return (a.empty? ? a0 : a0.join(*a))
69
71
  #p 'THERE',a0,a0.clone
70
- return a0.clone
72
+ #return a0.clone.join(*a)
71
73
  #return a0.class.new(a0.clone,*a)
72
74
  when ::URI
73
75
  a0 = a.shift
@@ -75,7 +77,17 @@ module RIO
75
77
  o = cl.new(a0,*a) unless cl.nil?
76
78
  return o
77
79
  when ::Symbol
78
- a[0] = 'rio:' + a[0].to_s + ':'
80
+ case a[0]
81
+ when :zpath
82
+ a0 = a.shift
83
+ cl = Factory.instance.riorl_class(a0.to_s)
84
+ o = cl.new(*a) unless cl.nil?
85
+ return o
86
+ else
87
+ a[0] = 'rio:' + a[0].to_s + ':'
88
+ end
89
+ when ::NilClass
90
+ a[0] = 'rio:null:'
79
91
  when ?? , ?= , ?_ , ?", ?[, ?#, ?`, ?|
80
92
  a[0] = 'rio:'+CHMAP[a[0]]+':'
81
93
  when ?-
data/lib/rio/rl/ioi.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
@@ -36,16 +36,24 @@
36
36
 
37
37
 
38
38
  require 'rio/rl/base'
39
+ require 'rio/ioh'
40
+ require 'rio/fs/stream'
39
41
 
40
42
  module RIO
41
43
  module RL
42
44
  class IOIBase < Base
43
45
  RESET_STATE = 'Stream::Open'
46
+ def openfs_()
47
+ RIO::FS::Stream.create()
48
+ end
44
49
  def scheme() self.class.const_get(:RIOSCHEME) end
45
50
  def opaque() '' end
46
51
  def self.splitrl(s) nil end
47
52
  #def path() self.class.const_get(:RIOPATH) end
48
53
  def to_s() url() end
54
+ def open(ios)
55
+ IOH::Stream.new(ios)
56
+ end
49
57
  end
50
58
  end
51
59
  module RL
@@ -55,12 +63,14 @@ module RIO
55
63
  protected(:ios=)
56
64
  def initialize(ios=nil)
57
65
  @ios = ios
66
+ super
58
67
  end
59
68
  def initialize_copy(cp)
60
69
  @ios = cp.ios.clone unless cp.ios.nil?
61
70
  end
62
- def open(*args)
63
- @ios
71
+ def open(ios=nil)
72
+ @ios = ios unless ios.nil?
73
+ super(@ios)
64
74
  end
65
75
 
66
76
  end