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
@@ -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
@@ -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,7 +42,7 @@ require 'rio/context/stream'
42
42
  require 'rio/context/dir'
43
43
  require 'rio/context/skip'
44
44
  require 'rio/filter'
45
- require 'rio/context/closeoneof'
45
+ require 'rio/context/autoclose'
46
46
  require 'rio/context/gzip'
47
47
  require 'rio/context/copying'
48
48
 
@@ -76,37 +76,7 @@ module RIO
76
76
  end
77
77
  end
78
78
 
79
- module Cx
80
- module Methods
81
- def closeoncopy(arg=true,&block) cxx('closeoncopy',arg,&block) end
82
- def nocloseoncopy(arg=false,&block) nocxx('closeoncopy',arg,&block) end
83
- def closeoncopy?() cxx?('closeoncopy') end
84
- def closeoncopy_(arg=true) cxx_('closeoncopy',arg) end
85
- protected :closeoncopy_
86
- end
87
- end
88
-
89
- module Cx
90
- module Methods
91
- def noautoclose(arg=false,&block)
92
- closeoncopy(arg).closeoneof(arg,&block)
93
- end
94
- def noautoclose_(arg=false)
95
- closeoncopy_(arg).closeoneof_(arg)
96
- end
97
- protected :noautoclose_
98
- end
99
- end
100
79
 
101
- module Cx
102
- module Methods
103
- def autorewind(arg=true,&block) cxx('autorewind',arg,&block) end
104
- def noautorewind(arg=false,&block) nocxx('autorewind',arg,&block) end
105
- def autorewind?() cxx?('autorewind') end
106
- def autorewind_(arg=true) cxx_('autorewind',arg) end
107
- protected :autorewind_
108
- end
109
- end
110
80
 
111
81
  module Cx
112
82
  module Methods
@@ -183,7 +153,8 @@ module RIO
183
153
  protected :ext_
184
154
  end
185
155
  end
186
-
156
+ end
157
+ module RIO
187
158
  module Cx
188
159
  module Methods
189
160
  def a() cx['outputmode'] = Mode::Str.new('a'); self end
@@ -194,6 +165,7 @@ module RIO
194
165
  def r!() cx['inputmode'] = Mode::Str.new('r+'); self end
195
166
  def outputmode?() cxx?('outputmode') end
196
167
  def inputmode?() cxx?('inputmode') end
168
+ def +@() a() end
197
169
  end
198
170
  end
199
171
  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
data/lib/rio/context.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
@@ -51,6 +51,21 @@ module RIO
51
51
  @values.delete(key)
52
52
  @explicit.delete(key)
53
53
  end
54
+ def get_keystate(key)
55
+ key_exists = @values.key?(key)
56
+ key_val = @values[key]
57
+ key_explicit = @explicit[key]
58
+ [key,key_exists,key_val,key_explicit]
59
+ end
60
+ def set_keystate(key,key_exists,key_val,key_explicit)
61
+ if(key_exists) then
62
+ @values[key] = key_val
63
+ @explicit[key] = key_explicit
64
+ else
65
+ @values.delete(key)
66
+ @explicit.delete(key)
67
+ end
68
+ end
54
69
  def set_(key,val)
55
70
  @values[key] = val unless @explicit[key]
56
71
  end
data/lib/rio/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
@@ -42,11 +42,33 @@ class String #:nodoc: all
42
42
  self
43
43
  end
44
44
  end
45
+ require 'rio/no_warn'
46
+
45
47
  module RIO
46
48
  module Cp #:nodoc: all
47
49
  module Util
48
50
  module InOut
49
51
  def cpclose(*args,&block)
52
+ if args.empty?
53
+ oldcoc = self.cx.get_keystate('closeoncopy')
54
+ self.cx['closeoncopy'] = false
55
+ rtn = yield
56
+ rtn.cx.set_keystate(*oldcoc)
57
+ rtn.copyclose
58
+ else
59
+ if (ario = args[0]).kind_of?(Rio)
60
+ oldcoc = ario.cx.get_keystate('closeoncopy')
61
+ ario.cx['closeoncopy'] = false
62
+ rtn = yield
63
+ ario.cx.set_keystate(*oldcoc)
64
+ ario.copyclose
65
+ rtn
66
+ else
67
+ yield
68
+ end
69
+ end
70
+ end
71
+ def cpclose0(*args,&block)
50
72
  if args.empty?
51
73
  oldcoc,self.cx['closeoncopy'] = self.cx['closeoncopy'],false
52
74
  rtn = yield
@@ -141,10 +163,12 @@ module RIO
141
163
 
142
164
  def cpto_rio_(arg,sym)
143
165
  ario = ensure_rio(arg)
166
+ #p ario
144
167
  ario = ario.join(self.filename) if ario.dir?
145
168
  ario.cpclose {
146
169
  ario = ario.iostate(sym)
147
170
  self.copying(ario).each { |el|
171
+ # p el
148
172
  ario.putrec(el)
149
173
  # ario << el
150
174
  }.copying_done(ario)
@@ -166,15 +190,16 @@ module RIO
166
190
  case arg
167
191
  when ::Array then cpfrom_array_(arg)
168
192
  when ::IO then cpfrom_obj_(arg)
169
- when ::String then self.put_(arg)
193
+ when ::String then
194
+ self.put_(arg)
170
195
  else cpfrom_rio_(arg)
171
196
  end
172
197
  self
173
198
  end
174
199
  def cpfrom_rio_(arg)
175
200
  ensure_rio(arg).copying(self).each { |el|
176
- self.putrec(el)
177
- # self << el
201
+ #self.putrec(el)
202
+ self << el
178
203
  }.copying_done(self)
179
204
  end
180
205
  end
@@ -206,7 +231,8 @@ module RIO
206
231
  end
207
232
  def spcp(arg)
208
233
  if arg.kind_of?(Rio) and arg.scheme == 'ftp'
209
- arg < new_rio(rl.path)
234
+ arg.copy_from(new_rio(rl.path))
235
+ #arg < new_rio(rl.path)
210
236
  self
211
237
  else
212
238
  nil
@@ -255,7 +281,6 @@ module RIO
255
281
  end
256
282
  end
257
283
  def cpfrom_rio_(ario)
258
- #p callstr('cpfrom_rio_',ario)
259
284
  dest = self.join(ario.filename)
260
285
  case
261
286
  when ario.symlink?
@@ -289,7 +314,7 @@ module RIO
289
314
  alias :copy_to :>
290
315
  alias :append_to :>>
291
316
 
292
- private
317
+ protected
293
318
 
294
319
  def cpto_rio_(ario)
295
320
  ario = ario.join(self.filename) if ario.exist?
@@ -306,7 +331,8 @@ module RIO
306
331
  include Util::Output
307
332
  def <(arg)
308
333
  if _switch_direction?(arg)
309
- arg > self
334
+ #arg > self
335
+ arg.copy_to(self)
310
336
  self
311
337
  else
312
338
  _cpsrc(arg) < arg
data/lib/rio/def.rb ADDED
@@ -0,0 +1,54 @@
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
+ require 'rio/base'
38
+
39
+ module RIO
40
+ # See also: RIO::Doc::SYNOPSIS; RIO::Doc::INTRO; RIO::Doc::HOWTO.
41
+ class Rio < Base #:doc:
42
+ end
43
+ end
44
+
45
+ if $0 == __FILE__
46
+ eval DATA.read, nil, $0, __LINE__+4
47
+ end
48
+
49
+ __END__
50
+
51
+ puts
52
+ puts("Run the tests that came with the distribution")
53
+ puts("From the distribution directory use 'test/runtests.rb'")
54
+ puts
data/lib/rio/dir.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
@@ -43,9 +43,6 @@ module RIO
43
43
  module Dir #:nodoc: all
44
44
  class Base < State::Base
45
45
  include Ops::Path::Str
46
- def self.copy_(src,dst)
47
- Impl::U.cp_r(src,dst)
48
- end
49
46
  def open?() !ioh.nil? end
50
47
  end
51
48
 
@@ -60,21 +57,27 @@ module RIO
60
57
 
61
58
  def check?() self.directory? end
62
59
  def when_missing(sym,*args) dopen() end
60
+
61
+ protected
62
+
63
+ def stream_rl_
64
+ self.rl.dir_rl()
65
+ #RIO::Dir::RL.new(self.to_uri, {:fs => self.fs})
66
+ end
67
+
68
+ public
69
+
63
70
  def dopen()
64
- self.rl = RIO::Dir::RL.new(self.to_uri)
71
+ self.rl = self.stream_rl_
65
72
  become 'Dir::Open'
66
73
  end
67
74
  end
68
75
  class Open < Base
69
76
  def check?() true end
70
- def open(m=nil,*args)
71
- open_(*args)
72
- end
77
+ def open(m=nil,*args) open_(*args) end
73
78
  def open_(*args)
74
79
  unless open?
75
- ios = self.rl.open(*args)
76
- self.ioh = IOH::Dir.new(ios)
77
- # self.ioh = self.rl.open()
80
+ self.ioh = self.rl.open()
78
81
  end
79
82
  self
80
83
  end
@@ -96,18 +99,14 @@ module RIO
96
99
  class Stream < Base
97
100
  include Ops::Dir::Stream
98
101
  def check?() open? end
99
- def when_missing(sym,*args)
100
- #p callstr('when_missing',sym,*args)
101
- retryreset()
102
- end
102
+ def when_missing(sym,*args) retryreset() end
103
103
  def base_state() 'Dir::Close' end
104
-
105
- def reset()
106
- self.close.softreset()
107
- end
104
+ def reset() self.close.softreset() end
108
105
  alias :copyclose :reset
109
106
  end
110
107
  class Close < Base
108
+ def reopen(*args) self.close_.softreset.open(*args) end
109
+
111
110
  def close()
112
111
  #p callstr('close')+" mode='#{mode?}' ioh=#{self.ioh} open?=#{open?}"
113
112
  return self unless self.open?
data/lib/rio/doc/HOWTO.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
@@ -269,7 +269,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
269
269
  # method 1
270
270
  array = ario['*.txt']
271
271
  # method 2
272
- array = ario[/\.txt/]
272
+ array = ario[/\.txt$/]
273
273
  # method 3
274
274
  array = ario.entries['*.txt']
275
275
 
@@ -277,7 +277,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
277
277
  # method 1
278
278
  array = ario.files['*.txt']
279
279
  # method 2
280
- array = ario.files[/\.txt/]
280
+ array = ario.files[/\.txt$/]
281
281
  # method 3
282
282
  array = ario.files['*.txt']
283
283
 
@@ -285,7 +285,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
285
285
  # method 1
286
286
  array = ario.all['*.txt']
287
287
  # method 2
288
- array = ario.all[/\.txt/]
288
+ array = ario.all[/\.txt$/]
289
289
  # method 3
290
290
  array = ario.all.entries['*.txt']
291
291
 
@@ -294,7 +294,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
294
294
  # method 1
295
295
  array = ario.norecurse('.svn').all['*.txt']
296
296
  # method 2
297
- array = ario.norecurse(/^\.svn$/).all[/\.txt/]
297
+ array = ario.norecurse(/^\.svn$/).all[/\.txt$/]
298
298
  # method 3
299
299
  array = ario.norecurse('.svn').entries['*.txt']
300
300
  # method 4
@@ -302,6 +302,17 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
302
302
  # method 5
303
303
  array = ario.norecurse('.svn')['*.txt']
304
304
 
305
+ * Put all directories (recursively) into an array
306
+ # method 1
307
+ array = ario.dirs[]
308
+ # method 2
309
+ array = ario.dirs.to_a
310
+
311
+ * Put all entries (recursively) into an array, but limit the depth of recursion to 2
312
+ # method 1
313
+ array = ario.norecurse(3).to_a
314
+
315
+
305
316
  * Iterate through ruby files in a directory and subdirectories skipping
306
317
  those in the '.svn', and 'pkg' directories
307
318
  # method 1
@@ -337,7 +348,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
337
348
  # method 1
338
349
  array = ario.skipdirs['.svn']
339
350
  # method 2
340
- array = ario.skipdirs[/^\.svn/]
351
+ array = ario.skipdirs[/^\.svn$/]
341
352
  # method 3
342
353
  array = ario.skipdirs('.svn').to_a
343
354
  # method 4
@@ -649,6 +660,11 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
649
660
  htmfile.rename.extname = '.html'
650
661
  end
651
662
 
663
+ * Move a file in an arbitrary directory into the current working directory.
664
+ # method 1
665
+ rio('arb/i/trary/di/rec/tory/afile').rename.dirname = '.'
666
+
667
+
652
668
  ---
653
669
 
654
670
  === Manipulate a Rio's path