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
@@ -34,21 +34,28 @@
34
34
  # <b>Rio is pre-alpha software.
35
35
  # The documented interface and behavior is subject to change without notice.</b>
36
36
 
37
+ module RIO
38
+ CONSTRUCTOR_SYMS = [
39
+ :strio,
40
+ :stdio,
41
+ :stderr,
42
+ :temp,
43
+ :tempfile,
44
+ :tempdir,
45
+ :tcp,
46
+ :cmdio,
47
+ :cmdpipe,
48
+ :sysio,
49
+ :fd,
50
+ ]
51
+ end
37
52
 
38
53
  module RIO
39
54
  module Ops
40
55
  module Construct
41
- def strio(*args,&block) Rio.rio(:strio,*args,&block) end
42
- def stdio(*args,&block) Rio.rio(:stdio,*args,&block) end
43
- def stderr(*args,&block) Rio.rio(:stderr,*args,&block) end
44
- def temp(*args,&block) Rio.rio(:temp,*args,&block) end
45
- def tempfile(*args,&block) Rio.rio(:tempfile,*args,&block) end
46
- def tempdir(*args,&block) Rio.rio(:tempdir,*args,&block) end
47
- def tcp(*args,&block) Rio.rio(:tcp,*args,&block) end
48
- def cmdio(*args,&block) Rio.rio(:cmdio,*args,&block) end
49
- def cmdpipe(*args,&block) Rio.rio(:cmdpipe,*args,&block) end
50
- def sysio(*args,&block) Rio.rio(:sysio,*args,&block) end
51
- def fd(*args,&block) Rio.rio(:fd,*args,&block) end
56
+ RIO::CONSTRUCTOR_SYMS.each { |sym|
57
+ module_eval "def #{sym}(*args,&block) Rio.rio(:#{sym},*args,&block) end"
58
+ }
52
59
  end
53
60
  end
54
61
  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
@@ -36,23 +36,11 @@
36
36
 
37
37
 
38
38
  module RIO
39
- module Impl
40
- module U
41
- def self.getwd() ::Dir.getwd() end
42
- def self.rootdir()
43
- require 'rio/local'
44
- ::RIO::Local::ROOT_DIR
45
- end
46
- def self.join(*args)
47
- ::File.join(*args)
48
- end
49
- end
50
- end
51
39
  module Ops
52
40
  module Path
53
41
  module Create
54
42
  def join(*args)
55
- new_rio(self,*args)
43
+ new_rio(self.rl,*args)
56
44
  end
57
45
  #alias :catpath :join
58
46
  def join!(*args)
@@ -65,15 +53,18 @@ module RIO
65
53
  end
66
54
 
67
55
  def getwd(*args,&block)
68
- new_rio(RL::getwd,*args,&block)
56
+ new_rio(fs.getwd,*args,&block)
57
+ end
58
+ def cwd(*args,&block)
59
+ new_rio(fs.cwd,*args,&block)
69
60
  end
70
- alias :cwd :getwd
61
+
71
62
  def rootpath(*args,&block)
72
- new_rio(Impl::U.rootdir(),*args,&block)
63
+ new_rio(fs.root(),*args,&block)
73
64
  end
74
65
  alias :root :rootpath
75
66
  def cleanpath(*args)
76
- new_rio(Impl::U.cleanpath(fspath,*args))
67
+ new_rio(fs.cleanpath(fspath,*args))
77
68
  end
78
69
  end
79
70
  end
data/lib/rio/ops/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
@@ -40,41 +40,41 @@ require 'rio/cp'
40
40
  require 'rio/ops/either'
41
41
 
42
42
  module RIO
43
- module Impl
44
- module U
45
- def self.rmdir(s) ::Dir.rmdir(s.to_s) end
46
- def self.mkdir(s,*args) ::Dir.mkdir(s.to_s,*args) end
47
- def self.chdir(s,&block) ::Dir.chdir(s.to_s,&block) end
48
- def self.foreach(s,&block) ::Dir.foreach(s.to_s,&block) end
49
- def self.entries(s) ::Dir.entries(s.to_s) end
50
- def self.cp_r(s,d)
51
- require 'fileutils'
52
- ::FileUtils.cp_r(s.to_s,d.to_s)
53
- end
54
- def self.find(s,&block)
55
- require 'find'
56
- Find.find(s.to_s) do |f|
57
- yield f
58
- end
59
- end
60
- def self.glob(gstr,*args,&block)
61
- ::Dir.glob(gstr,*args,&block)
62
- end
63
- def self.rmtree(s)
64
- require 'fileutils'
65
- ::FileUtils.rmtree(s.to_s)
66
- end
67
- def self.mkpath(s)
68
- require 'fileutils'
69
- ::FileUtils.mkpath(s.to_s)
70
- end
71
- end
72
- end
43
+ # module Impl
44
+ # module U
45
+ # def self.rmdir(s) ::Dir.rmdir(s.to_s) end
46
+ # def self.mkdir(s,*args) ::Dir.mkdir(s.to_s,*args) end
47
+ # def self.chdir(s,&block) ::Dir.chdir(s.to_s,&block) end
48
+ # def self.foreach(s,&block) ::Dir.foreach(s.to_s,&block) end
49
+ # def self.entries(s) ::Dir.entries(s.to_s) end
50
+ # def self.cp_r(s,d)
51
+ # require 'fileutils'
52
+ # ::FileUtils.cp_r(s.to_s,d.to_s)
53
+ # end
54
+ # def self.find(s,&block)
55
+ # require 'find'
56
+ # Find.find(s.to_s) do |f|
57
+ # yield f
58
+ # end
59
+ # end
60
+ # def self.glob(gstr,*args,&block)
61
+ # ::Dir.glob(gstr,*args,&block)
62
+ # end
63
+ # def self.rmtree(s)
64
+ # require 'fileutils'
65
+ # ::FileUtils.rmtree(s.to_s)
66
+ # end
67
+ # def self.mkpath(s)
68
+ # require 'fileutils'
69
+ # ::FileUtils.mkpath(s.to_s)
70
+ # end
71
+ # end
72
+ # end
73
73
 
74
74
  module Ops
75
75
  module Dir
76
76
  module ExistOrNot
77
- include ::RIO::Ops::FileOrDir::ExistOrNot
77
+ include RIO::Ops::FileOrDir::ExistOrNot
78
78
  end
79
79
  end
80
80
  end
@@ -84,13 +84,13 @@ module RIO
84
84
  include ExistOrNot
85
85
  include ::RIO::Ops::FileOrDir::NonExisting
86
86
  def mkdir(*args)
87
- # p callstr('mkdir',*args)
88
- Impl::U.mkdir(self,*args);
87
+ fs.mkdir(self.to_s,*args);
89
88
  softreset()
90
89
  end
91
90
  def mkpath(*args)
92
91
  # p callstr('mkpath',*args)
93
- Impl::U.mkpath(self,*args);
92
+ fs.mkpath(self.to_s,*args);
93
+ #fs.mkpath(self,*args);
94
94
  softreset()
95
95
  end
96
96
  def rmdir(*args) self end
@@ -124,13 +124,14 @@ module RIO
124
124
  def selective?
125
125
  %w[entry_sel stream_sel stream_nosel].any? { |k| cx.has_key?(k) }
126
126
  end
127
+ def empty?() self.to_a.empty? end
127
128
  def mkdir(*args) self end
128
129
  def mkpath(*args) self end
129
130
  def rmdir(*args)
130
- Impl::U.rmdir(self,*args);
131
+ fs.rmdir(self.to_s,*args);
131
132
  softreset()
132
133
  end
133
- def rmtree(*args) Impl::U.rmtree(self,*args); softreset() end
134
+ def rmtree(*args) fs.rmtree(self.to_s,*args); softreset() end
134
135
 
135
136
  alias :delete :rmdir
136
137
  alias :delete! :rmtree
@@ -138,16 +139,16 @@ module RIO
138
139
 
139
140
  def chdir(*args,&block)
140
141
  if block_given?
141
- Impl::U.chdir(self,*args) { |dir|
142
+ fs.chdir(self.to_s,*args) { |dir|
142
143
  yield new_rio('.')
143
144
  }
144
145
  else
145
- Impl::U.chdir(self,*args)
146
+ fs.chdir(self.path,*args)
146
147
  return new_rio('.')
147
148
  end
148
149
  self
149
150
  end
150
-
151
+
151
152
  def ensure_rio_cx(arg0)
152
153
  return arg0 if arg0.kind_of?(::RIO::Rio)
153
154
  new_rio_cx(arg0)
@@ -156,11 +157,11 @@ module RIO
156
157
  def glob(*args,&block)
157
158
  chdir do
158
159
  if block_given?
159
- Impl::U.glob(*args) do |ent|
160
+ fs.glob(*args) do |ent|
160
161
  yield new_rio_cx(self,ent)
161
162
  end
162
163
  else
163
- return Impl::U.glob(*args).map { |ent| new_rio_cx(self,ent) }
164
+ return fs.glob(*args).map { |ent| new_rio_cx(self,ent) }
164
165
  end
165
166
  end
166
167
  end
@@ -181,7 +182,6 @@ module RIO
181
182
  def entries(*args,&block) _set_select('entries',*args,&block) end
182
183
 
183
184
  def each(*args,&block)
184
- # p callstr('each',*args)
185
185
  each_(*args,&block)
186
186
  end
187
187
 
@@ -230,10 +230,16 @@ module RIO
230
230
  args = cx['skip_args'] || []
231
231
  self.skipentries(*args)
232
232
  end
233
- def handle_ent_(estr,selfstr,sel,&block)
233
+ def ent_to_rio_(ent,indir)
234
+ if indir
235
+ new_rio_cx(indir.rl,ent)
236
+ else
237
+ new_rio_cx(ent)
238
+ end
239
+ end
240
+ def handle_ent_(ent,indir,sel,&block)
234
241
  begin
235
- erio = new_rio_cx(selfstr ? Impl::U.join(selfstr,estr) : estr )
236
-
242
+ erio = ent_to_rio_(ent,indir)
237
243
  if stream_iter?
238
244
  _add_stream_iter_cx(erio).each(&block) if erio.file? and sel.match?(erio)
239
245
  else
@@ -253,10 +259,10 @@ module RIO
253
259
  #p "#{callstr('each_',*args)} sel=#{cx['sel'].inspect} nosel=#{cx['nosel'].inspect}"
254
260
  handle_skipped()
255
261
  sel = Match::Entry::Selector.new(cx['entry_sel'])
256
- selfstr = (self.to_s == '.' ? nil : self.to_s)
257
- self.ioh.each do |estr|
258
- next if
259
- handle_ent_(estr,selfstr,sel,&block) unless estr =~ /^\.(\.)?$/
262
+ indir = (self.to_s == '.' ? nil : self)
263
+ self.ioh.each do |ent|
264
+ #next if
265
+ handle_ent_(ent,indir,sel,&block) unless ent =~ /^\.(\.)?$/
260
266
  end
261
267
  closeoneof? ? self.close : self
262
268
  end
@@ -264,9 +270,9 @@ module RIO
264
270
  #p "#{callstr('each_',*args)} sel=#{cx['sel'].inspect} nosel=#{cx['nosel'].inspect}"
265
271
  handle_skipped()
266
272
  sel = Match::Entry::Selector.new(cx['entry_sel'])
267
- selfstr = (self.to_s == '.' ? nil : self.to_s)
268
- while estr = self.ioh.read
269
- handle_ent_(estr,selfstr,sel,&block) unless estr =~ /^\.(\.)?$/
273
+ indir = (self.to_s == '.' ? nil : self)
274
+ while ent = self.ioh.read
275
+ handle_ent_(ent,indir,sel,&block) unless ent =~ /^\.(\.)?$/
270
276
  end
271
277
  closeoneof? ? self.close : self
272
278
  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
@@ -57,13 +57,14 @@ module RIO
57
57
  end
58
58
  module NonExisting
59
59
  include ExistOrNot
60
+ def empty?() false end
60
61
  end
61
62
 
62
63
  module Existing
63
64
  include ExistOrNot
64
65
 
65
- def chmod(mod) rtn_self { Impl::U.chmod(mod,fspath) } end
66
- def chown(owner,group) rtn_self { Impl::U.chown(owner,group,fspath) } end
66
+ def chmod(mod) rtn_self { fs.chmod(mod,fspath) } end
67
+ def chown(owner,group) rtn_self { fs.chown(owner,group,fspath) } end
67
68
  def must_exist() self end
68
69
 
69
70
  def rename(*args,&block)
@@ -72,7 +73,7 @@ module RIO
72
73
  else
73
74
  rtn_reset {
74
75
  dst = ensure_rio(args.shift)
75
- Impl::U.mv(self,dst,*args)
76
+ fs.mv(self,dst,*args)
76
77
  dst.reset
77
78
  }
78
79
  end
@@ -83,7 +84,7 @@ module RIO
83
84
  else
84
85
  rtn_reset {
85
86
  dst = ensure_rio(args.shift)
86
- Impl::U.mv(self,dst,*args)
87
+ fs.mv(self,dst,*args)
87
88
  dst.reset
88
89
  self.rl = dst.rl.clone
89
90
  }
@@ -117,12 +118,13 @@ module RIO
117
118
 
118
119
  require 'pathname'
119
120
  def realpath
120
- new_rio(Impl::U.realpath(fspath))
121
+ new_rio(fs.realpath(fspath))
121
122
  end
122
123
  def mountpoint?
123
- Impl::U.mountpoint?(fspath)
124
+ fs.mountpoint?(fspath)
124
125
  end
125
-
126
+ def empty?() self.to_a.empty? end
127
+
126
128
  end
127
129
 
128
130
  end
data/lib/rio/ops/file.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
@@ -39,24 +39,24 @@ require 'rio/cp'
39
39
  require 'rio/piper/cp'
40
40
  require 'rio/ops/either'
41
41
 
42
- module RIO
43
- module Impl
44
- module U
45
- def self.copy(s,d)
46
- require 'fileutils'
47
- ::FileUtils.cp(s.to_s,d.to_s)
48
- end
49
- def self.rm(s)
50
- require 'fileutils'
51
- ::FileUtils.rm(s.to_s)
52
- end
53
- def self.touch(s)
54
- require 'fileutils'
55
- ::FileUtils.touch(s.to_s)
56
- end
57
- end
58
- end
59
- end
42
+ # module RIO
43
+ # module Impl
44
+ # module U
45
+ # def self.copy(s,d)
46
+ # require 'fileutils'
47
+ # ::FileUtils.cp(s.to_s,d.to_s)
48
+ # end
49
+ # def self.rm(s)
50
+ # require 'fileutils'
51
+ # ::FileUtils.rm(s.to_s)
52
+ # end
53
+ # def self.touch(s)
54
+ # require 'fileutils'
55
+ # ::FileUtils.touch(s.to_s)
56
+ # end
57
+ # end
58
+ # end
59
+ # end
60
60
  module RIO
61
61
  module Ops
62
62
  module File
@@ -73,15 +73,19 @@ module RIO
73
73
  def selective?
74
74
  %w[stream_sel stream_nosel].any? { |k| cx.has_key?(k) }
75
75
  end
76
+ def empty?()
77
+ self.selective? ? self.to_a.empty? : self.size == 0
78
+ end
76
79
  def rm(*args)
77
80
  rtn_reset {
78
- Impl::U.rm(self,*args)
81
+ fs.rm(self,*args)
79
82
  }
80
83
  end
81
84
  alias :delete :rm
82
85
  alias :delete! :rm
83
-
84
- def touch(*args) rtn_self { Impl::U.touch(self,*args) } end
86
+ def touch(*args) rtn_self { fs.touch(self.to_s,*args) } end
87
+ def truncate(sz=0) rtn_reset { fs.truncate(self.to_s,sz) } end
88
+ def clear() truncate(0) end
85
89
  end
86
90
  module NonExisting
87
91
  include ExistOrNot
@@ -90,7 +94,7 @@ module RIO
90
94
  def rm(*args) rtn_self { ; } end
91
95
  alias delete rm
92
96
  alias delete! rm
93
- def touch(*args) rtn_reset { Impl::U.touch(self,*args) } end
97
+ def touch(*args) rtn_reset { fs.touch(self,*args) } end
94
98
  end
95
99
  end
96
100
  end
data/lib/rio/ops/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
@@ -35,47 +35,49 @@
35
35
  # The documented interface and behavior is subject to change without notice.</b>
36
36
 
37
37
 
38
- require 'rio/impl/path'
38
+ #require 'rio/impl/path'
39
39
  module RIO
40
40
  module Ops #:nodoc: all
41
41
  module Path
42
42
  module Test
43
- def blockdev?(*args) Impl::U.blockdev?(self.to_s,*args) end
44
- def chardev?(*args) Impl::U.chardev?(self.to_s,*args) end
45
- def directory?(*args) Impl::U.directory?(self.to_s,*args) end
46
- def exist?(*args) Impl::U.exist?(self.to_s,*args) end
47
- def file?(*args) Impl::U.file?(self.to_s,*args) end
48
- def pipe?(*args) Impl::U.pipe?(self.to_s,*args) end
49
- def socket?(*args) Impl::U.socket?(self.to_s,*args) end
50
- def symlink?(*args) Impl::U.symlink?(self.to_s,*args) end
43
+ def blockdev?(*args) fs.blockdev?(self.to_s,*args) end
44
+ def chardev?(*args) fs.chardev?(self.to_s,*args) end
45
+ def directory?(*args) fs.directory?(self.to_s,*args) end
46
+ def exist?(*args) fs.exist?(self.to_s,*args) end
47
+ def file?(*args)
48
+ fs.file?(self.to_s,*args)
49
+ end
50
+ def pipe?(*args) fs.pipe?(self.to_s,*args) end
51
+ def socket?(*args) fs.socket?(self.to_s,*args) end
52
+ def symlink?(*args) fs.symlink?(self.to_s,*args) end
51
53
  alias :dir? :directory?
52
54
  def open?() not self.closed? end
53
55
  def closed?() self.ioh.nil? end
54
56
  end
55
57
  module Status
56
58
  include Test
57
- def fnmatch(*args) Impl::U.fnmatch(self.to_s,*args) end
58
- def fnmatch?(*args) Impl::U.fnmatch?(self.to_s,*args) end
59
- def ftype(*args) Impl::U.ftype(self.to_s,*args) end
60
- def stat(*args) Impl::U.stat(self.to_s,*args) end
61
- def atime(*args) Impl::U.atime(self.to_s,*args) end
62
- def ctime(*args) Impl::U.ctime(self.to_s,*args) end
63
- def mtime(*args) Impl::U.mtime(self.to_s,*args) end
64
- def executable?(*args) Impl::U.executable?(self.to_s,*args) end
65
- def executable_real?(*args) Impl::U.executable_real?(self.to_s,*args) end
66
- def readable?(*args) Impl::U.readable?(self.to_s,*args) end
67
- def readable_real?(*args) Impl::U.readable_real?(self.to_s,*args) end
68
- def writable?(*args) Impl::U.writable?(self.to_s,*args) end
69
- def writable_real?(*args) Impl::U.writable_real?(self.to_s,*args) end
70
- def sticky?(*args) Impl::U.sticky?(self.to_s,*args) end
71
- def owned?(*args) Impl::U.owned?(self.to_s,*args) end
72
- def grpowned?(*args) Impl::U.grpowned?(self.to_s,*args) end
73
- def setgid?(*args) Impl::U.setgid?(self.to_s,*args) end
74
- def setuid?(*args) Impl::U.setuid?(self.to_s,*args) end
75
- def size(*args) Impl::U.size(self.to_s,*args) end
76
- def size?(*args) Impl::U.size?(self.to_s,*args) end
77
- def zero?(*args) Impl::U.zero?(self.to_s,*args) end
78
- def root?(*args) Impl::U.root?(self.to_s) end
59
+ def fnmatch(*args) fs.fnmatch(self.to_s,*args) end
60
+ def fnmatch?(*args) fs.fnmatch?(self.to_s,*args) end
61
+ def ftype(*args) fs.ftype(self.to_s,*args) end
62
+ def stat(*args) fs.stat(self.to_s,*args) end
63
+ def atime(*args) fs.atime(self.to_s,*args) end
64
+ def ctime(*args) fs.ctime(self.to_s,*args) end
65
+ def mtime(*args) fs.mtime(self.to_s,*args) end
66
+ def executable?(*args) fs.executable?(self.to_s,*args) end
67
+ def executable_real?(*args) fs.executable_real?(self.to_s,*args) end
68
+ def readable?(*args) fs.readable?(self.to_s,*args) end
69
+ def readable_real?(*args) fs.readable_real?(self.to_s,*args) end
70
+ def writable?(*args) fs.writable?(self.to_s,*args) end
71
+ def writable_real?(*args) fs.writable_real?(self.to_s,*args) end
72
+ def sticky?(*args) fs.sticky?(self.to_s,*args) end
73
+ def owned?(*args) fs.owned?(self.to_s,*args) end
74
+ def grpowned?(*args) fs.grpowned?(self.to_s,*args) end
75
+ def setgid?(*args) fs.setgid?(self.to_s,*args) end
76
+ def setuid?(*args) fs.setuid?(self.to_s,*args) end
77
+ def size(*args) fs.size(self.to_s,*args) end
78
+ def size?(*args) fs.size?(self.to_s,*args) end
79
+ def zero?(*args) fs.zero?(self.to_s,*args) end
80
+ def root?(*args) fs.root?(self.to_s) end
79
81
 
80
82
  end
81
83
  module URI
@@ -131,17 +133,17 @@ module RIO
131
133
  module Query
132
134
  def expand_path(*args)
133
135
  args[0] = args[0].to_s unless args.empty?
134
- new_rio(RL.fs2url(Impl::U.expand_path(self.to_s,*args)))
136
+ new_rio(RL.fs2url(fs.expand_path(self.to_s,*args)))
135
137
  end
136
138
  def extname(*args)
137
- en = Impl::U.extname(rl.path_no_slash,*args)
139
+ en = fs.extname(rl.path_no_slash,*args)
138
140
  (en.empty? ? nil : en)
139
141
  end
140
142
  def split()
141
143
  require 'rio/to_rio'
142
144
  parts = self.rl.split
143
145
  # map to rios and extend the array with to_array
144
- parts.map { |arl| rio(arl) }.extend(ToRio::Array)
146
+ parts.map { |arl| new_rio(arl) }.extend(ToRio::Array)
145
147
  end
146
148
  def basename(*args)
147
149
  unless args.empty?
@@ -149,15 +151,15 @@ module RIO
149
151
  self.ext(ex)
150
152
  end
151
153
  #p self.ext?.inspect
152
- fn = Impl::U.basename(rl.path_no_slash,self.ext?)
154
+ fn = fs.basename(rl.path_no_slash,self.ext?)
153
155
  new_rio(fn,{:base => _calc_base()})
154
156
  end
155
157
  def filename()
156
- fn = Impl::U.basename(rl.path_no_slash)
158
+ fn = fs.basename(rl.path_no_slash)
157
159
  new_rio(fn,{:base => _calc_base()})
158
160
  end
159
161
  def _calc_base()
160
- dn = Impl::U.dirname(rl.path_no_slash)
162
+ dn = fs.dirname(rl.path_no_slash)
161
163
  dn[0] == ?/ ? dn : self.base.to_url + dn + '/' #'
162
164
  # if dn[0] == ?/
163
165
  # dn
@@ -168,7 +170,7 @@ module RIO
168
170
  private :_calc_base
169
171
 
170
172
  def dirname(*args)
171
- #new_rio(Impl::U.dirname(rl.path_no_slash,*args))
173
+ #new_rio(fs.dirname(rl.path_no_slash,*args))
172
174
  new_rio(rl.dirname)
173
175
  end
174
176
 
@@ -278,10 +280,10 @@ module RIO
278
280
  dst = self.ensure_rio(d)
279
281
  dst /= self.filename if dst.directory?
280
282
  if self.abs?
281
- Impl::U.symlink(self,dst)
283
+ fs.symlink(self,dst)
282
284
  else
283
285
  #p "symlink(#{dst.route_to(self)},#{dst})"
284
- Impl::U.symlink(dst.route_to(self),dst.to_s)
286
+ fs.symlink(dst.route_to(self),dst.to_s)
285
287
  end
286
288
  dst.reset
287
289
  }
@@ -312,4 +314,4 @@ module RIO
312
314
  end
313
315
 
314
316
  end
315
- end # FS
317
+ end